Skip to content

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

Merged
merged 4 commits into from
Dec 11, 2023
Merged

Move SARA_R5 features #10

merged 4 commits into from
Dec 11, 2023

Conversation

sfe-SparkFro
Copy link
Collaborator

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 🙃

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
Copy link
Member

@gigapod gigapod left a 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 to const char const

@@ -42,125 +43,119 @@

// ## Suported AT Commands
// ### General
const char SARA_R5_COMMAND_AT[] = "AT"; // AT "Test"
Copy link
Member

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.

Copy link
Collaborator Author

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

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);
Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Member

@gigapod gigapod Dec 4, 2023

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"
Copy link
Member

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

Copy link
Collaborator Author

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:");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use strnstr

Copy link
Collaborator Author

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

@sfe-SparkFro
Copy link
Collaborator Author

@gigapod I'm fine with those changes, but since they're beyond the scope of this PR and they all apply to other files, I've made separate issues for them and will work on those separately before the v1.0.0 branch gets merged into main. See #9, #11, and #12

@sfe-SparkFro sfe-SparkFro merged commit 7866459 into v1.0.0 Dec 11, 2023
@sfe-SparkFro sfe-SparkFro deleted the move_sara_r5_features branch December 11, 2023 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants