Skip to content

Commit 5c49f16

Browse files
committed
Increase AT timeout to 10s in AT_CellularSMS::send_sms
For some devices sending can be slow (as an example see SIM800, it can be up to 60s), command is being run properly but default timeout is returning an invalid error. See https://www.elecrow.com/wiki/images/2/20/SIM800_Series_AT_Command_Manual_V1.09.pdf
1 parent baf6a30 commit 5c49f16

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

connectivity/cellular/source/framework/AT/AT_CellularSMS.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c
420420
}
421421

422422
_at.lock();
423+
_at.set_at_timeout(10s);
423424

424425
int write_size = 0;
425426

@@ -437,6 +438,7 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c
437438
// sending can be cancelled by giving <ESC> character (IRA 27).
438439
_at.cmd_start(ESC);
439440
_at.cmd_stop();
441+
_at.restore_at_timeout();
440442
_at.unlock();
441443
return write_size;
442444
}
@@ -482,6 +484,7 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c
482484
pdu_str = create_pdu(phone_number, message + i * concatenated_sms_length, pdu_len,
483485
sms_count, i + 1, header_len);
484486
if (!pdu_str) {
487+
_at.restore_at_timeout();
485488
_at.unlock();
486489
return NSAPI_ERROR_NO_MEMORY;
487490
}
@@ -509,6 +512,7 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c
509512
// sending can be cancelled by giving <ESC> character (IRA 27).
510513
_at.cmd_start(ESC);
511514
_at.cmd_stop();
515+
_at.restore_at_timeout();
512516
_at.unlock();
513517
delete [] pdu_str;
514518
return msg_write_len;
@@ -523,13 +527,15 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c
523527
delete [] pdu_str;
524528
remaining_len -= concatenated_sms_length;
525529
if (_at.get_last_error() != NSAPI_ERROR_OK) {
530+
_at.restore_at_timeout();
526531
return _at.unlock_return_error();
527532
}
528533
}
529534
}
530535

531536
_sms_message_ref_number++;
532537
nsapi_error_t ret = _at.get_last_error();
538+
_at.restore_at_timeout();
533539
_at.unlock();
534540

535541
return (ret == NSAPI_ERROR_OK) ? msg_len : ret;

0 commit comments

Comments
 (0)