mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: Handle SEND FAIL and ERROR response
QISEND command can respond either SEND OK, SEND FAIL or ERROR. If response is not SEND OK, sent bytes should not be checked but error should be reported.pull/11534/head
parent
d0b5ba6d84
commit
1768b653ec
|
@ -300,12 +300,17 @@ nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_sendto_impl(CellularSoc
|
|||
_at.write_bytes((uint8_t *)data, size);
|
||||
_at.resp_start();
|
||||
_at.set_stop_tag("\r\n");
|
||||
// Possible responses are SEND OK, SEND FAIL or ERROR.
|
||||
char response[16];
|
||||
response[0] = '\0';
|
||||
_at.read_string(response, sizeof(response));
|
||||
_at.resp_stop();
|
||||
if (strcmp(response, "SEND OK") != 0) {
|
||||
return NSAPI_ERROR_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
// Get the sent count after sending
|
||||
|
||||
nsapi_size_or_error_t err = _at.at_cmd_int("+QISEND", "=", sent_len_after, "%d%d", socket->id, 0);
|
||||
|
||||
if (err == NSAPI_ERROR_OK) {
|
||||
sent_len = sent_len_after - sent_len_before;
|
||||
return sent_len;
|
||||
|
|
|
@ -440,7 +440,14 @@ nsapi_size_or_error_t QUECTEL_M26_CellularStack::socket_sendto_impl(CellularSock
|
|||
_at.write_bytes((uint8_t *)data, sent_len);
|
||||
_at.resp_start();
|
||||
_at.set_stop_tag("\r\n");
|
||||
// Possible responses are SEND OK, SEND FAIL or ERROR.
|
||||
char response[16];
|
||||
response[0] = '\0';
|
||||
_at.read_string(response, sizeof(response));
|
||||
_at.resp_stop();
|
||||
if (strcmp(response, "SEND OK") != 0) {
|
||||
return NSAPI_ERROR_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (_at.get_last_error() != NSAPI_ERROR_OK) {
|
||||
tr_error("QUECTEL_M26_CellularStack:%s:%u:[NSAPI_ERROR_DEVICE_ERROR]", __FUNCTION__, __LINE__);
|
||||
|
|
Loading…
Reference in New Issue