Merge pull request #11534 from kivaisan/handle_qisend_send_fail

Cellular: Handle SEND FAIL and ERROR response
pull/11561/head
Martin Kojtal 2019-09-24 13:30:32 +02:00 committed by GitHub
commit e1cfb7b908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -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;

View File

@ -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__);