Skip to content

v1.1.3 - Release candidate #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun u-blox SARA-R5 Arduino Library
version=1.1.2
version=1.1.3
author=SparkFun Electronics <[email protected]>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for the u-blox SARA-R5 LTE-M / NB-IoT modules with secure cloud<br/><br/>
Expand Down
39 changes: 28 additions & 11 deletions src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4143,21 +4143,37 @@ SARA_R5_error_t SARA_R5::readMQTT(int* pQos, String* pTopic, uint8_t *readDest,
free(response);
return SARA_R5_ERROR_UNEXPECTED_RESPONSE;
}

err = SARA_R5_ERROR_SUCCESS;
searchPtr = strstr(searchPtr, "\"");
if (pTopic) {
searchPtr[topic_length+1] = '\0'; // zero terminate
*pTopic = searchPtr+1;
searchPtr[topic_length+1] = '\"'; // restore
}
searchPtr = strstr(searchPtr + topic_length + 2, "\"");
if (readDest) {
*bytesRead = (data_length > readLength) ? readLength : data_length;
memcpy(readDest, searchPtr+1, *bytesRead);
if (searchPtr!= NULL) {
if (pTopic) {
searchPtr[topic_length + 1] = '\0'; // zero terminate
*pTopic = searchPtr + 1;
searchPtr[topic_length + 1] = '\"'; // restore
}
searchPtr = strstr(searchPtr + topic_length + 2, "\"");
if (readDest && (searchPtr != NULL) && (response + responseLength >= searchPtr + data_length + 1) && (searchPtr[data_length + 1] == '"')) {
if (data_length > readLength) {
data_length = readLength;
if (_printDebug == true) {
_debugPort->print(F("readMQTT: error: trucate message"));
}
err = SARA_R5_ERROR_OUT_OF_MEMORY;
}
memcpy(readDest, searchPtr+1, data_length);
*bytesRead = data_length;
} else {
if (_printDebug == true) {
_debugPort->print(F("readMQTT: error: message end "));
}
err = SARA_R5_ERROR_UNEXPECTED_RESPONSE;
}
}
free(command);
free(response);

return (data_length > readLength) ? SARA_R5_ERROR_OUT_OF_MEMORY : SARA_R5_ERROR_SUCCESS;
return err;
}

SARA_R5_error_t SARA_R5::getMQTTprotocolError(int *error_code, int *error_code2)
Expand Down Expand Up @@ -4832,7 +4848,7 @@ SARA_R5_error_t SARA_R5::getFileContents(String filename, String *contents)
// A large file will completely fill the backlog buffer - but it will be pruned afterwards
// Note to self: if the file contents contain "OK\r\n" sendCommandWithResponse will return true too early...
// To try and avoid this, look for \"\r\nOK\r\n
const char fileReadTerm[] = "\"\r\nOK\r\n";
const char fileReadTerm[] = "\r\nOK\r\n"; //LARA-R6 returns "\"\r\n\r\nOK\r\n" while SARA-R5 return "\"\r\nOK\r\n";
err = sendCommandWithResponse(command, fileReadTerm,
response, (5 * SARA_R5_STANDARD_RESPONSE_TIMEOUT),
(fileSize + minimumResponseAllocation));
Expand Down Expand Up @@ -5958,6 +5974,7 @@ void SARA_R5::beginSerial(unsigned long baud)
delay(100);
if (_hardSerial != NULL)
{
_hardSerial->end();
_hardSerial->begin(baud);
}
#ifdef SARA_R5_SOFTWARE_SERIAL_ENABLED
Expand Down
2 changes: 1 addition & 1 deletion src/SparkFun_u-blox_SARA-R5_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ class SARA_R5 : public Print
int readAvailable(char *inString);
char readChar(void);
int hwAvailable(void);
void beginSerial(unsigned long baud);
virtual void beginSerial(unsigned long baud);
void setTimeout(unsigned long timeout);
bool find(char *target);

Expand Down