Skip to content

Commit e1cfb7b

Browse files
authored
Merge pull request #11534 from kivaisan/handle_qisend_send_fail
Cellular: Handle SEND FAIL and ERROR response
2 parents 65d5c72 + 1768b65 commit e1cfb7b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,17 @@ nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_sendto_impl(CellularSoc
300300
_at.write_bytes((uint8_t *)data, size);
301301
_at.resp_start();
302302
_at.set_stop_tag("\r\n");
303+
// Possible responses are SEND OK, SEND FAIL or ERROR.
304+
char response[16];
305+
response[0] = '\0';
306+
_at.read_string(response, sizeof(response));
303307
_at.resp_stop();
308+
if (strcmp(response, "SEND OK") != 0) {
309+
return NSAPI_ERROR_DEVICE_ERROR;
310+
}
304311

305312
// Get the sent count after sending
306-
307313
nsapi_size_or_error_t err = _at.at_cmd_int("+QISEND", "=", sent_len_after, "%d%d", socket->id, 0);
308-
309314
if (err == NSAPI_ERROR_OK) {
310315
sent_len = sent_len_after - sent_len_before;
311316
return sent_len;

features/cellular/framework/targets/QUECTEL/M26/QUECTEL_M26_CellularStack.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,14 @@ nsapi_size_or_error_t QUECTEL_M26_CellularStack::socket_sendto_impl(CellularSock
440440
_at.write_bytes((uint8_t *)data, sent_len);
441441
_at.resp_start();
442442
_at.set_stop_tag("\r\n");
443+
// Possible responses are SEND OK, SEND FAIL or ERROR.
444+
char response[16];
445+
response[0] = '\0';
446+
_at.read_string(response, sizeof(response));
443447
_at.resp_stop();
448+
if (strcmp(response, "SEND OK") != 0) {
449+
return NSAPI_ERROR_DEVICE_ERROR;
450+
}
444451

445452
if (_at.get_last_error() != NSAPI_ERROR_OK) {
446453
tr_error("QUECTEL_M26_CellularStack:%s:%u:[NSAPI_ERROR_DEVICE_ERROR]", __FUNCTION__, __LINE__);

0 commit comments

Comments
 (0)