-
Notifications
You must be signed in to change notification settings - Fork 2
Move SARA_R5 features #10
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
Conversation
LARA_R6 does not support these AT commands, as per #4 Moved into SARA-R5 class for now, but if other modules support these, they should be moved into a sub-class that can be inherited like the voice class
Should just use macros to not have duplicate definitions Also remove PSD and UTIME definitions due to existence in sara_r5.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just requested some tweaks:
- Use of string functions with buffer len is used.
- Format using 4 char indentation - our standard
- Tweak the constant delcars from
const char
toconst char const
@@ -42,125 +43,119 @@ | |||
|
|||
// ## Suported AT Commands | |||
// ### General | |||
const char SARA_R5_COMMAND_AT[] = "AT"; // AT "Test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all these constant defines:
const char const
Which is : const data type ('the string') and const pointer ('the pointer')
not just
const char
Which is just saying this symbol points to 'constant data'
We all make this mistake.
And if I was being really pedantic - I'd use const char * const
- the use of "[]" to declare a pointer array is valid, but off standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me, though I'll do that separately from this PR
src/sfe_sara_r5.cpp
Outdated
if (command == nullptr) | ||
return UBX_CELL_ERROR_OUT_OF_MEMORY; | ||
if (mode == UBX_CELL_UTIME_MODE_STOP) // stop UTIME does not require a sensor | ||
sprintf(command, "%s=%d", SARA_R5_GNSS_REQUEST_TIME, mode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use snprintf - throughout this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the same should be done in the other files, correct? I'll make a separate issue for this, since the scope of this PR is really just to move these functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - buffer overflows are painful, using proper string functions help.
@@ -0,0 +1,360 @@ | |||
#include "sfe_sara_r5.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File should use 4 char spacing, not 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do that as part of addressing #9 before the v1 branch is merged into main. Easy enough to run all the code through a formatter at the end
if (err == UBX_CELL_ERROR_SUCCESS) | ||
{ | ||
int mStore, sStore, scanned = 0; | ||
char *searchPtr = strstr(response, "+UTIME:"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use strnstr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the same should be done in the other files, correct? I'll make a separate issue for this, since the scope of this PR is really just to move these functions
Fixes #4
Not sure if it's best to move these features into
sfe_sara_r5.h
or an intermediate class like the voice class. If the latter is preferred, please suggest a name for it, because I don't know what to call it 🙃