Skip to content

Commit f71c6d3

Browse files
authored
Merge pull request sparkfun#23 from sparkfun/release_candidate
v1.1.3 - Release candidate
2 parents 94fb048 + 529b443 commit f71c6d3

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox SARA-R5 Arduino Library
2-
version=1.1.2
2+
version=1.1.3
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for the u-blox SARA-R5 LTE-M / NB-IoT modules with secure cloud<br/><br/>

src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4143,21 +4143,37 @@ SARA_R5_error_t SARA_R5::readMQTT(int* pQos, String* pTopic, uint8_t *readDest,
41434143
free(response);
41444144
return SARA_R5_ERROR_UNEXPECTED_RESPONSE;
41454145
}
4146+
4147+
err = SARA_R5_ERROR_SUCCESS;
41464148
searchPtr = strstr(searchPtr, "\"");
4147-
if (pTopic) {
4148-
searchPtr[topic_length+1] = '\0'; // zero terminate
4149-
*pTopic = searchPtr+1;
4150-
searchPtr[topic_length+1] = '\"'; // restore
4151-
}
4152-
searchPtr = strstr(searchPtr + topic_length + 2, "\"");
4153-
if (readDest) {
4154-
*bytesRead = (data_length > readLength) ? readLength : data_length;
4155-
memcpy(readDest, searchPtr+1, *bytesRead);
4149+
if (searchPtr!= NULL) {
4150+
if (pTopic) {
4151+
searchPtr[topic_length + 1] = '\0'; // zero terminate
4152+
*pTopic = searchPtr + 1;
4153+
searchPtr[topic_length + 1] = '\"'; // restore
4154+
}
4155+
searchPtr = strstr(searchPtr + topic_length + 2, "\"");
4156+
if (readDest && (searchPtr != NULL) && (response + responseLength >= searchPtr + data_length + 1) && (searchPtr[data_length + 1] == '"')) {
4157+
if (data_length > readLength) {
4158+
data_length = readLength;
4159+
if (_printDebug == true) {
4160+
_debugPort->print(F("readMQTT: error: trucate message"));
4161+
}
4162+
err = SARA_R5_ERROR_OUT_OF_MEMORY;
4163+
}
4164+
memcpy(readDest, searchPtr+1, data_length);
4165+
*bytesRead = data_length;
4166+
} else {
4167+
if (_printDebug == true) {
4168+
_debugPort->print(F("readMQTT: error: message end "));
4169+
}
4170+
err = SARA_R5_ERROR_UNEXPECTED_RESPONSE;
4171+
}
41564172
}
41574173
free(command);
41584174
free(response);
41594175

4160-
return (data_length > readLength) ? SARA_R5_ERROR_OUT_OF_MEMORY : SARA_R5_ERROR_SUCCESS;
4176+
return err;
41614177
}
41624178

41634179
SARA_R5_error_t SARA_R5::getMQTTprotocolError(int *error_code, int *error_code2)
@@ -4832,7 +4848,7 @@ SARA_R5_error_t SARA_R5::getFileContents(String filename, String *contents)
48324848
// A large file will completely fill the backlog buffer - but it will be pruned afterwards
48334849
// Note to self: if the file contents contain "OK\r\n" sendCommandWithResponse will return true too early...
48344850
// To try and avoid this, look for \"\r\nOK\r\n
4835-
const char fileReadTerm[] = "\"\r\nOK\r\n";
4851+
const char fileReadTerm[] = "\r\nOK\r\n"; //LARA-R6 returns "\"\r\n\r\nOK\r\n" while SARA-R5 return "\"\r\nOK\r\n";
48364852
err = sendCommandWithResponse(command, fileReadTerm,
48374853
response, (5 * SARA_R5_STANDARD_RESPONSE_TIMEOUT),
48384854
(fileSize + minimumResponseAllocation));
@@ -5958,6 +5974,7 @@ void SARA_R5::beginSerial(unsigned long baud)
59585974
delay(100);
59595975
if (_hardSerial != NULL)
59605976
{
5977+
_hardSerial->end();
59615978
_hardSerial->begin(baud);
59625979
}
59635980
#ifdef SARA_R5_SOFTWARE_SERIAL_ENABLED

src/SparkFun_u-blox_SARA-R5_Arduino_Library.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ class SARA_R5 : public Print
10261026
int readAvailable(char *inString);
10271027
char readChar(void);
10281028
int hwAvailable(void);
1029-
void beginSerial(unsigned long baud);
1029+
virtual void beginSerial(unsigned long baud);
10301030
void setTimeout(unsigned long timeout);
10311031
bool find(char *target);
10321032

0 commit comments

Comments
 (0)