Skip to content

Commit ccec6b9

Browse files
committed
Check return value for assisted GPS
1 parent 8b3f60e commit ccec6b9

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/ArduinoCellular.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,20 +231,24 @@ bool ArduinoCellular::enableGPS(bool assisted){
231231
this->debugStream->println("Enabling GPS...");
232232
}
233233

234+
String response;
235+
234236
if(assisted){
235-
sendATCommand("AT+QGPSCFG=\"agpsposmode\",33488767");
237+
response = sendATCommand("+QGPSCFG=\"agpsposmode\",33488767", 10000);
236238
} else {
237-
sendATCommand("AT+QGPSCFG=\"agpsposmode\",8388608");
239+
// Sets the 23rd bit to 1 to enable standalone GPS
240+
response = sendATCommand("+QGPSCFG=\"agpsposmode\",8388608", 10000);
238241
}
239242

240-
//modem.sendAT(GF("+UTIME=1,1"));
241-
//modem.waitResponse();
242-
//modem.sendAT(GF("+UGPIOC=23,0,1"));
243-
244-
//modem.waitResponse();
243+
if(response.indexOf("OK") == -1){
244+
if(this->debugStream != nullptr){
245+
this->debugStream->println("Failed to set GPS mode.");
246+
this->debugStream->println("Response: " + response);
247+
}
248+
return false;
249+
}
245250

246251
return modem.enableGPS();
247-
//delay(10000);
248252
}
249253

250254
String ArduinoCellular::sendATCommand(const char * command, unsigned long timeout){

0 commit comments

Comments
 (0)