-
Notifications
You must be signed in to change notification settings - Fork 518
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
[msom] Add GNSS test FQC command #2721
Changes from all commits
f6228ff
1eed3cd
8c3e4eb
bc6b2e1
76e9ca2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -519,7 +519,7 @@ static int callbackGPSGGA(int type, const char* buf, int len, bool* gnssLocked) | |
strlcpy(gpggaSentence, buf, MAX_GPGGA_STR_LEN); | ||
|
||
String lattitudeLongitude("LAT/LONG:"); | ||
int numberSattelites = 0; | ||
int numberSatellites = 0; | ||
|
||
const char * delimiters = ","; | ||
char * token = strtok(gpggaSentence, delimiters); | ||
|
@@ -543,10 +543,10 @@ static int callbackGPSGGA(int type, const char* buf, int len, bool* gnssLocked) | |
lattitudeLongitude.concat(token); | ||
break; | ||
case 8: // Number satellites | ||
numberSattelites = (int)String(token).toInt(); | ||
if (numberSattelites > 0) { | ||
numberSatellites = (int)String(token).toInt(); | ||
if (numberSatellites > 0) { | ||
*gnssLocked = true; | ||
Log.info("%s Satellites: %d", lattitudeLongitude.c_str(), numberSattelites); | ||
Log.info("%s Satellites: %d", lattitudeLongitude.c_str(), numberSatellites); | ||
} | ||
break; | ||
default: | ||
|
@@ -557,7 +557,18 @@ static int callbackGPSGGA(int type, const char* buf, int len, bool* gnssLocked) | |
return 1; | ||
} | ||
|
||
bool BurninTest::testGnss() { | ||
static int callbackQGPS(int type, const char* buf, int len, bool* cmdSuccess) { | ||
//Log.trace("%d : %s", strlen(buf), buf); | ||
|
||
// If string is `OK` or `+CME ERROR: 504` (ie GNSS already started) then GPS engine is enabled | ||
if (!strcmp(buf, "\r\n+CME ERROR: 504\r\n") || !strcmp(buf, "\r\nOK\r\n")) { | ||
*cmdSuccess = true; | ||
} | ||
return 0; | ||
} | ||
|
||
|
||
bool BurninTest::initGnss() { | ||
// Turn on GNSS + Modem | ||
pinMode(GNSS_ANT_PWR, OUTPUT); | ||
digitalWrite(GNSS_ANT_PWR, HIGH); | ||
|
@@ -568,25 +579,40 @@ bool BurninTest::testGnss() { | |
|
||
// Enable GNSS. It can take some time after the modem AT interface comes up for the GNSS engine to start | ||
const int RETRIES = 10; | ||
int r = 0; | ||
for (int i = 0; i < RETRIES && r != RESP_OK; i++) { | ||
r = Cellular.command("AT+QGPS=1\r\n"); | ||
|
||
bool success = false; | ||
for (int i = 0; i < RETRIES && !success; i++) { | ||
Cellular.command(callbackQGPS, &success, 5000, "AT+QGPS=1"); | ||
delay(1000); | ||
} | ||
|
||
if (r != RESP_OK) { | ||
strcpy(BurninErrorMessage, "AT+QGPS=1 failed, GNSS not enabled"); | ||
if (!success) { | ||
Log.error("AT+QGPS=1 failed, GNSS not enabled"); | ||
return false; | ||
} | ||
|
||
// Configure antenna for GNSS priority | ||
for (int i = 0; i < RETRIES && r != RESP_OK; i++) { | ||
r = Cellular.command("AT+QGPSCFG=\"priority\",0"); | ||
delay(1000); | ||
hal_device_hw_info deviceInfo = {}; | ||
hal_get_device_hw_info(&deviceInfo, nullptr); | ||
if (deviceInfo.ncp[0] == PLATFORM_NCP_QUECTEL_BG95_M5) { | ||
int r = 0; | ||
// Configure antenna for GNSS priority | ||
for (int i = 0; i < RETRIES && r != RESP_OK; i++) { | ||
r = Cellular.command("AT+QGPSCFG=\"priority\",0"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I just use the default 10 second timeout. I dont care about timing just that it succeeded. |
||
delay(1000); | ||
} | ||
|
||
if (r != RESP_OK) { | ||
Log.error("AT+QGPSCFG=\"priority\",0 failed, GNSS not prioritized"); | ||
return false; | ||
} | ||
} | ||
|
||
if (r != RESP_OK) { | ||
strcpy(BurninErrorMessage, "AT+QGPSCFG=\"priority\",0 failed, GNSS not prioritized"); | ||
return true; | ||
} | ||
|
||
bool BurninTest::testGnss() { | ||
if (!initGnss()) { | ||
strcpy(BurninErrorMessage, "Failed to initialize GNSS"); | ||
return false; | ||
} | ||
|
||
|
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.
This loop is used elsewhere as well. It would be handy to have a macro/template that wraps retry loops with delay. Don't worry about it today.