File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -380,3 +380,44 @@ void ATCmdParser::abort()
380
380
{
381
381
_aborted = true ;
382
382
}
383
+
384
+ bool ATCmdParser::process_oob ()
385
+ {
386
+ if (!_fh->readable ()) {
387
+ return false ;
388
+ }
389
+
390
+ int i = 0 ;
391
+ while (true ) {
392
+ // Receive next character
393
+ int c = getc ();
394
+ if (c < 0 ) {
395
+ return false ;
396
+ }
397
+ _buffer[i++] = c;
398
+ _buffer[i] = 0 ;
399
+
400
+ // Check for oob data
401
+ struct oob *oob = _oobs;
402
+ while ( oob ) {
403
+ if (i == (int )oob->len && memcmp (
404
+ oob->prefix , _buffer, oob->len ) == 0 ) {
405
+ debug_if (_dbg_on, " AT! %s\r\n " , oob->prefix );
406
+ oob->cb ();
407
+ return true ;
408
+ }
409
+ oob = oob->next ;
410
+ }
411
+
412
+ // Clear the buffer when we hit a newline or ran out of space
413
+ // running out of space usually means we ran into binary data
414
+ if (i+1 >= _buffer_size ||
415
+ strcmp (&_buffer[i-_output_delim_size], _output_delimiter) == 0 ) {
416
+
417
+ debug_if (_dbg_on, " AT< %s" , _buffer);
418
+ i = 0 ;
419
+ }
420
+ }
421
+ }
422
+
423
+
Original file line number Diff line number Diff line change @@ -288,6 +288,16 @@ class ATCmdParser : private NonCopyable<ATCmdParser>
288
288
* recv operation.
289
289
*/
290
290
void abort ();
291
+
292
+ /* *
293
+ * Process out-of-band data
294
+ *
295
+ * Process out-of-band data in the receive buffer. This function
296
+ * returns immediately if there is no data to process.
297
+ *
298
+ * @return true if oob data processed, false otherwise
299
+ */
300
+ bool process_oob (void );
291
301
};
292
302
} // namespace mbed
293
303
You can’t perform that action at this time.
0 commit comments