Skip to content

Commit 3c0d6f0

Browse files
authored
Merge pull request #8790 from AriParkkila/cell-urc-cb
Cellular: Fix ATHandler URC processing
2 parents fdca1e3 + 3d79b50 commit 3c0d6f0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

features/cellular/framework/AT/ATHandler.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char
7272
_previous_at_timeout(timeout),
7373
_at_send_delay(send_delay),
7474
_last_response_stop(0),
75-
_processing(false),
75+
_oob_queued(false),
7676
_ref_count(1),
7777
_is_fh_usable(true),
7878
_stop_tag(NULL),
@@ -223,9 +223,8 @@ bool ATHandler::find_urc_handler(const char *prefix)
223223

224224
void ATHandler::event()
225225
{
226-
// _processing must be set before filehandle write/read to avoid repetitive sigio events
227-
if (!_processing) {
228-
_processing = true;
226+
if (!_oob_queued) {
227+
_oob_queued = true;
229228
(void) _queue.call(Callback<void(void)>(this, &ATHandler::process_oob));
230229
}
231230
}
@@ -235,14 +234,12 @@ void ATHandler::lock()
235234
#ifdef AT_HANDLER_MUTEX
236235
_fileHandleMutex.lock();
237236
#endif
238-
_processing = true;
239237
clear_error();
240238
_start_time = rtos::Kernel::get_ms_count();
241239
}
242240

243241
void ATHandler::unlock()
244242
{
245-
_processing = false;
246243
#ifdef AT_HANDLER_MUTEX
247244
_fileHandleMutex.unlock();
248245
#endif
@@ -283,19 +280,22 @@ void ATHandler::process_oob()
283280
return;
284281
}
285282
lock();
283+
_oob_queued = false;
286284
if (_fileHandle->readable() || (_recv_pos < _recv_len)) {
287285
tr_debug("AT OoB readable %d, len %u", _fileHandle->readable(), _recv_len - _recv_pos);
288286
_current_scope = NotSet;
289287
uint32_t timeout = _at_timeout;
290-
_at_timeout = PROCESS_URC_TIME;
291288
while (true) {
289+
_at_timeout = timeout;
292290
if (match_urc()) {
293291
if (!(_fileHandle->readable() || (_recv_pos < _recv_len))) {
294292
break; // we have nothing to read anymore
295293
}
296294
} else if (mem_str(_recv_buff, _recv_len, CRLF, CRLF_LENGTH)) { // If no match found, look for CRLF and consume everything up to CRLF
295+
_at_timeout = PROCESS_URC_TIME;
297296
consume_to_tag(CRLF, true);
298297
} else {
298+
_at_timeout = PROCESS_URC_TIME;
299299
if (!fill_buffer()) {
300300
reset_buffer(); // consume anything that could not be handled
301301
break;

features/cellular/framework/AT/ATHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class ATHandler {
218218
uint16_t _at_send_delay;
219219
uint64_t _last_response_stop;
220220

221-
bool _processing;
221+
bool _oob_queued;
222222
int32_t _ref_count;
223223
bool _is_fh_usable;
224224

0 commit comments

Comments
 (0)