@@ -308,10 +308,6 @@ bool SARA_R5::bufferedPoll(void)
308
308
}
309
309
}
310
310
311
- // This is a bug. event could be nullptr, and even if it is not it is pointing into
312
- // _saraRXBuffer meaning it is calling free on a random pointer whose memory
313
- // may be referenced later.
314
- // free(event);
315
311
_bufferedPollReentrant = false ;
316
312
317
313
return handled;
@@ -858,12 +854,12 @@ void SARA_R5::setHTTPCommandCallback(void (*httpCommandRequestCallback)(int prof
858
854
_httpCommandRequestCallback = httpCommandRequestCallback;
859
855
}
860
856
861
- void SARA_R5::setMQTTCommandCallback (void (*mqttCommandRequestCallback)(SARA_R5_mqtt_command_opcode_t command, int result))
857
+ void SARA_R5::setMQTTCommandCallback (void (*mqttCommandRequestCallback)(int command, int result))
862
858
{
863
859
_mqttCommandRequestCallback = mqttCommandRequestCallback;
864
860
}
865
861
866
- void SARA_R5::setFTPCommandCallback (void (*ftpCommandRequestCallback)(SARA_R5_ftp_command_opcode_t command, int result))
862
+ void SARA_R5::setFTPCommandCallback (void (*ftpCommandRequestCallback)(int command, int result))
867
863
{
868
864
_ftpCommandRequestCallback = ftpCommandRequestCallback;
869
865
}
@@ -1618,51 +1614,53 @@ int8_t SARA_R5::rssi(void)
1618
1614
1619
1615
SARA_R5_error_t SARA_R5::getExtSignalQuality (signal_quality& signal_quality)
1620
1616
{
1621
- char *command;
1622
- char *response;
1623
- SARA_R5_error_t err;
1617
+ char *command;
1618
+ char *response;
1619
+ SARA_R5_error_t err;
1624
1620
1625
- command = sara_r5_calloc_char (strlen (SARA_R5_EXT_SIGNAL_QUALITY) + 1 );
1626
- if (command == nullptr )
1627
- {
1628
- return SARA_R5_ERROR_OUT_OF_MEMORY;
1629
- }
1621
+ command = sara_r5_calloc_char (strlen (SARA_R5_EXT_SIGNAL_QUALITY) + 1 );
1622
+ if (command == nullptr )
1623
+ {
1624
+ return SARA_R5_ERROR_OUT_OF_MEMORY;
1625
+ }
1630
1626
1631
- sprintf (command, " %s" , SARA_R5_EXT_SIGNAL_QUALITY);
1627
+ sprintf (command, " %s" , SARA_R5_EXT_SIGNAL_QUALITY);
1632
1628
1633
- response = sara_r5_calloc_char (minimumResponseAllocation);
1634
- if (response == nullptr )
1635
- {
1636
- free (command);
1637
- return SARA_R5_ERROR_OUT_OF_MEMORY;
1638
- }
1629
+ response = sara_r5_calloc_char (minimumResponseAllocation);
1630
+ if (response == nullptr )
1631
+ {
1632
+ free (command);
1633
+ return SARA_R5_ERROR_OUT_OF_MEMORY;
1634
+ }
1639
1635
1640
- err = sendCommandWithResponse (command,
1641
- SARA_R5_RESPONSE_OK_OR_ERROR, response, 10000 ,
1642
- minimumResponseAllocation, AT_COMMAND);
1643
- if (err != SARA_R5_ERROR_SUCCESS)
1644
- {
1645
- free (command);
1646
- free (response);
1647
- return SARA_R5_ERROR_ERROR;
1648
- }
1636
+ err = sendCommandWithResponse (command,
1637
+ SARA_R5_RESPONSE_OK_OR_ERROR, response, 10000 ,
1638
+ minimumResponseAllocation, AT_COMMAND);
1639
+ if (err != SARA_R5_ERROR_SUCCESS)
1640
+ {
1641
+ free (command);
1642
+ free (response);
1643
+ return SARA_R5_ERROR_ERROR;
1644
+ }
1649
1645
1650
- int scanned = 0 ;
1651
- char *searchPtr = strstr (response, " +CESQ: " );
1652
- if (searchPtr != nullptr ) {
1653
- scanned = sscanf (searchPtr, " +CESQ: %u,%u,%u,%u,%u,%u" , &signal_quality.rxlev , &signal_quality.ber ,
1654
- &signal_quality.rscp , &signal_quality.enc0 , &signal_quality.rsrq , &signal_quality.rsrp );
1655
- }
1646
+ int scanned = 0 ;
1647
+ char *searchPtr = strstr (response, " +CESQ: " );
1648
+ if (searchPtr != nullptr )
1649
+ {
1650
+ while (*searchPtr == ' ' ) searchPtr++; // skip spaces
1651
+ scanned = sscanf (searchPtr, " %u,%u,%u,%u,%u,%u" , &signal_quality.rxlev , &signal_quality.ber ,
1652
+ &signal_quality.rscp , &signal_quality.enc0 , &signal_quality.rsrq , &signal_quality.rsrp );
1653
+ }
1656
1654
1657
- err = SARA_R5_ERROR_UNEXPECTED_RESPONSE;
1658
- if (scanned == 6 )
1659
- {
1660
- err = SARA_R5_ERROR_SUCCESS;
1661
- }
1655
+ err = SARA_R5_ERROR_UNEXPECTED_RESPONSE;
1656
+ if (scanned == 6 )
1657
+ {
1658
+ err = SARA_R5_ERROR_SUCCESS;
1659
+ }
1662
1660
1663
- free (command);
1664
- free (response);
1665
- return err;
1661
+ free (command);
1662
+ free (response);
1663
+ return err;
1666
1664
}
1667
1665
1668
1666
SARA_R5_registration_status_t SARA_R5::registration (bool eps)
@@ -5587,7 +5585,7 @@ SARA_R5_error_t SARA_R5::getFileBlock(const String& filename, char* buffer, size
5587
5585
sprintf (cmd, " at+urdblock=\" %s\" ,%zu,%zu\r\n " , filename.c_str (), offset, requested_length);
5588
5586
if (_printDebug == true )
5589
5587
{
5590
- _debugPort->printf (F ( " getFileBlock: sending command: %s\r\n " ) , cmd);
5588
+ _debugPort->printf (" getFileBlock: sending command: %s\r\n " , cmd);
5591
5589
}
5592
5590
sendCommand (cmd, false );
5593
5591
@@ -5618,7 +5616,7 @@ SARA_R5_error_t SARA_R5::getFileBlock(const String& filename, char* buffer, size
5618
5616
cmd[bytes_read] = 0 ;
5619
5617
if (_printDebug == true )
5620
5618
{
5621
- _debugPort->printf (F ( " getFileBlock: header: [%s]\r\n " ) , cmd);
5619
+ _debugPort->printf (" getFileBlock: header: [%s]\r\n " , cmd);
5622
5620
}
5623
5621
cmd[bytes_read - 2 ] = 0 ;
5624
5622
@@ -5628,7 +5626,7 @@ SARA_R5_error_t SARA_R5::getFileBlock(const String& filename, char* buffer, size
5628
5626
free (cmd);
5629
5627
if (_printDebug == true )
5630
5628
{
5631
- _debugPort->printf (F ( " getFileBlock: reading %zu bytes\r\n " ) , data_length);
5629
+ _debugPort->printf (" getFileBlock: reading %zu bytes\r\n " , data_length);
5632
5630
}
5633
5631
5634
5632
bytes_read = 0 ;
@@ -5643,7 +5641,7 @@ SARA_R5_error_t SARA_R5::getFileBlock(const String& filename, char* buffer, size
5643
5641
5644
5642
if (_printDebug == true )
5645
5643
{
5646
- _debugPort->printf (F ( " getFileBlock: read %zu bytes\r\n " ) , bytes_read);
5644
+ _debugPort->printf (" getFileBlock: read %zu bytes\r\n " , bytes_read);
5647
5645
}
5648
5646
5649
5647
return SARA_R5_ERROR_SUCCESS;
@@ -6717,11 +6715,6 @@ void SARA_R5::pruneBacklog()
6717
6715
// _debugPort->println(F("pruneBacklog: backlog is now empty"));
6718
6716
// }
6719
6717
// }
6720
-
6721
- // This is a bug. event could be nullptr, and even if it is not it is pointing into
6722
- // _saraResponseBacklog meaning it is calling free on a random pointer whose memory
6723
- // may be referenced later.
6724
- // free(event);
6725
6718
}
6726
6719
6727
6720
// GPS Helper Functions:
0 commit comments