@@ -320,27 +320,33 @@ bool SARA_R5::processURCEvent(const char *event)
320
320
{
321
321
{ // URC: +UUSORD (Read Socket Data)
322
322
int socket, length;
323
- int ret = sscanf (event, " +UUSORD:%d,%d " , &socket, &length );
324
- if (ret == 2 )
323
+ char *searchPtr = strstr (event, " +UUSORD:" );
324
+ if (searchPtr != nullptr )
325
325
{
326
- if (_printDebug == true )
327
- _debugPort->println (F (" processReadEvent: read socket data" ));
328
- // From the SARA_R5 AT Commands Manual:
329
- // "For the UDP socket type the URC +UUSORD: <socket>,<length> notifies that a UDP packet has been received,
330
- // either when buffer is empty or after a UDP packet has been read and one or more packets are stored in the
331
- // buffer."
332
- // So we need to check if this is a TCP socket or a UDP socket:
333
- // If UDP, we call parseSocketReadIndicationUDP.
334
- // Otherwise, we call parseSocketReadIndication.
335
- if (_lastSocketProtocol[socket] == SARA_R5_UDP)
326
+ searchPtr += strlen (" +UUSORD:" ); // Move searchPtr to first character - probably a space
327
+ while (*searchPtr == ' ' ) searchPtr++; // skip spaces
328
+ int ret = sscanf (event, " %d,%d" , &socket, &length);
329
+ if (ret == 2 )
336
330
{
337
331
if (_printDebug == true )
338
- _debugPort->println (F (" processReadEvent: received +UUSORD but socket is UDP. Calling parseSocketReadIndicationUDP" ));
339
- parseSocketReadIndicationUDP (socket, length);
332
+ _debugPort->println (F (" processReadEvent: read socket data" ));
333
+ // From the SARA_R5 AT Commands Manual:
334
+ // "For the UDP socket type the URC +UUSORD: <socket>,<length> notifies that a UDP packet has been received,
335
+ // either when buffer is empty or after a UDP packet has been read and one or more packets are stored in the
336
+ // buffer."
337
+ // So we need to check if this is a TCP socket or a UDP socket:
338
+ // If UDP, we call parseSocketReadIndicationUDP.
339
+ // Otherwise, we call parseSocketReadIndication.
340
+ if (_lastSocketProtocol[socket] == SARA_R5_UDP)
341
+ {
342
+ if (_printDebug == true )
343
+ _debugPort->println (F (" processReadEvent: received +UUSORD but socket is UDP. Calling parseSocketReadIndicationUDP" ));
344
+ parseSocketReadIndicationUDP (socket, length);
345
+ }
346
+ else
347
+ parseSocketReadIndication (socket, length);
348
+ return true ;
340
349
}
341
- else
342
- parseSocketReadIndication (socket, length);
343
- return true ;
344
350
}
345
351
}
346
352
{ // URC: +UUSORF (Receive From command (UDP only))
0 commit comments