@@ -408,6 +408,11 @@ void ATHandler::skip_param(uint32_t count)
408
408
return ;
409
409
}
410
410
411
+ if (!_is_fh_usable) {
412
+ _last_err = NSAPI_ERROR_BUSY;
413
+ return ;
414
+ }
415
+
411
416
for (uint32_t i = 0 ; (i < count && !_stop_tag->found ); i++) {
412
417
size_t match_pos = 0 ;
413
418
while (true ) {
@@ -436,6 +441,10 @@ void ATHandler::skip_param(ssize_t len, uint32_t count)
436
441
if (_last_err || !_stop_tag || _stop_tag->found ) {
437
442
return ;
438
443
}
444
+ if (!_is_fh_usable) {
445
+ _last_err = NSAPI_ERROR_BUSY;
446
+ return ;
447
+ }
439
448
440
449
for (uint32_t i = 0 ; i < count; i++) {
441
450
ssize_t read_len = 0 ;
@@ -456,6 +465,10 @@ ssize_t ATHandler::read_bytes(uint8_t *buf, size_t len)
456
465
if (_last_err) {
457
466
return -1 ;
458
467
}
468
+ if (!_is_fh_usable) {
469
+ _last_err = NSAPI_ERROR_BUSY;
470
+ return -1 ;
471
+ }
459
472
460
473
bool debug_on = _debug_on;
461
474
size_t read_len = 0 ;
@@ -481,6 +494,10 @@ ssize_t ATHandler::read_string(char *buf, size_t size, bool read_even_stop_tag)
481
494
if (_last_err || !_stop_tag || (_stop_tag->found && read_even_stop_tag == false )) {
482
495
return -1 ;
483
496
}
497
+ if (!_is_fh_usable) {
498
+ _last_err = NSAPI_ERROR_BUSY;
499
+ return -1 ;
500
+ }
484
501
485
502
unsigned int len = 0 ;
486
503
size_t match_pos = 0 ;
@@ -547,6 +564,10 @@ ssize_t ATHandler::read_hex_string(char *buf, size_t size)
547
564
if (_last_err || !_stop_tag || _stop_tag->found ) {
548
565
return -1 ;
549
566
}
567
+ if (!_is_fh_usable) {
568
+ _last_err = NSAPI_ERROR_BUSY;
569
+ return -1 ;
570
+ }
550
571
551
572
size_t match_pos = 0 ;
552
573
@@ -620,6 +641,10 @@ int32_t ATHandler::read_int()
620
641
if (_last_err || !_stop_tag || _stop_tag->found ) {
621
642
return -1 ;
622
643
}
644
+ if (!_is_fh_usable) {
645
+ _last_err = NSAPI_ERROR_BUSY;
646
+ return -1 ;
647
+ }
623
648
624
649
char buff[BUFF_SIZE];
625
650
if (read_string (buff, sizeof (buff)) == 0 ) {
@@ -879,6 +904,10 @@ void ATHandler::resp_start(const char *prefix, bool stop)
879
904
if (_last_err) {
880
905
return ;
881
906
}
907
+ if (!_is_fh_usable) {
908
+ _last_err = NSAPI_ERROR_BUSY;
909
+ return ;
910
+ }
882
911
883
912
set_scope (NotSet);
884
913
// Try get as much data as possible
@@ -905,6 +934,10 @@ bool ATHandler::info_resp()
905
934
if (_last_err || _resp_stop.found ) {
906
935
return false ;
907
936
}
937
+ if (!_is_fh_usable) {
938
+ _last_err = NSAPI_ERROR_BUSY;
939
+ return false ;
940
+ }
908
941
909
942
if (_prefix_matched) {
910
943
_prefix_matched = false ;
@@ -935,6 +968,10 @@ bool ATHandler::info_elem(char start_tag)
935
968
if (_last_err) {
936
969
return false ;
937
970
}
971
+ if (!_is_fh_usable) {
972
+ _last_err = NSAPI_ERROR_BUSY;
973
+ return false ;
974
+ }
938
975
939
976
// If coming here after another info response element was started(looping), stop the previous one.
940
977
// Trying to handle stopping in this level instead of doing it in upper level.
@@ -1005,6 +1042,11 @@ bool ATHandler::consume_to_stop_tag()
1005
1042
return true ;
1006
1043
}
1007
1044
1045
+ if (!_is_fh_usable) {
1046
+ _last_err = NSAPI_ERROR_BUSY;
1047
+ return true ;
1048
+ }
1049
+
1008
1050
if (consume_to_tag ((const char *)_stop_tag->tag , true )) {
1009
1051
return true ;
1010
1052
}
@@ -1081,15 +1123,18 @@ const char *ATHandler::mem_str(const char *dest, size_t dest_len, const char *sr
1081
1123
1082
1124
void ATHandler::cmd_start (const char *cmd)
1083
1125
{
1126
+ if (_last_err != NSAPI_ERROR_OK) {
1127
+ return ;
1128
+ }
1129
+ if (!_is_fh_usable) {
1130
+ _last_err = NSAPI_ERROR_BUSY;
1131
+ return ;
1132
+ }
1084
1133
1085
1134
if (_at_send_delay) {
1086
1135
rtos::ThisThread::sleep_until (_last_response_stop + _at_send_delay);
1087
1136
}
1088
1137
1089
- if (_last_err != NSAPI_ERROR_OK) {
1090
- return ;
1091
- }
1092
-
1093
1138
(void )write (cmd, strlen (cmd));
1094
1139
1095
1140
_cmd_start = true ;
@@ -1136,6 +1181,10 @@ void ATHandler::cmd_stop()
1136
1181
if (_last_err != NSAPI_ERROR_OK) {
1137
1182
return ;
1138
1183
}
1184
+ if (!_is_fh_usable) {
1185
+ _last_err = NSAPI_ERROR_BUSY;
1186
+ return ;
1187
+ }
1139
1188
// Finish with CR
1140
1189
(void )write (_output_delimiter, strlen (_output_delimiter));
1141
1190
}
@@ -1152,6 +1201,10 @@ size_t ATHandler::write_bytes(const uint8_t *data, size_t len)
1152
1201
if (_last_err != NSAPI_ERROR_OK) {
1153
1202
return 0 ;
1154
1203
}
1204
+ if (!_is_fh_usable) {
1205
+ _last_err = NSAPI_ERROR_BUSY;
1206
+ return 0 ;
1207
+ }
1155
1208
1156
1209
return write (data, len);
1157
1210
}
@@ -1198,6 +1251,11 @@ bool ATHandler::check_cmd_send()
1198
1251
return false ;
1199
1252
}
1200
1253
1254
+ if (!_is_fh_usable) {
1255
+ _last_err = NSAPI_ERROR_BUSY;
1256
+ return false ;
1257
+ }
1258
+
1201
1259
// Don't write delimiter if flag was set so
1202
1260
if (!_use_delimiter) {
1203
1261
return true ;
@@ -1218,6 +1276,10 @@ bool ATHandler::check_cmd_send()
1218
1276
1219
1277
void ATHandler::flush ()
1220
1278
{
1279
+ if (!_is_fh_usable) {
1280
+ _last_err = NSAPI_ERROR_BUSY;
1281
+ return ;
1282
+ }
1221
1283
tr_debug (" AT flush" );
1222
1284
reset_buffer ();
1223
1285
while (fill_buffer (false )) {
@@ -1255,6 +1317,10 @@ void ATHandler::debug_print(const char *p, int len)
1255
1317
1256
1318
bool ATHandler::sync (int timeout_ms)
1257
1319
{
1320
+ if (!_is_fh_usable) {
1321
+ _last_err = NSAPI_ERROR_BUSY;
1322
+ return false ;
1323
+ }
1258
1324
tr_debug (" AT sync" );
1259
1325
lock ();
1260
1326
uint32_t timeout = _at_timeout;
0 commit comments