Skip to content
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

Merged
merged 5 commits into from
Jan 12, 2024
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
58 changes: 42 additions & 16 deletions user/applications/tinker/src/burnin_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:
Expand All @@ -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);
Expand All @@ -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++) {
Copy link
Contributor

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.

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

Choose a reason for hiding this comment

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

The AT+QGPSCFG="priority" command should take a maximum of 300ms to execute. I see you don't have a timeout on the command call.

Copy link
Member Author

Choose a reason for hiding this comment

The 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;
}

Expand Down
1 change: 1 addition & 0 deletions user/applications/tinker/src/burnin_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class BurninTest {

void setup(bool forceEnable = false);
void loop();
bool initGnss();

enum class BurninTestState : uint32_t {
NONE,
Expand Down
Loading