Skip to content

Commit

Permalink
Implement GPS start mode ( vshymanskyy#642 )
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvervuurt committed Feb 9, 2024
1 parent 36a25d1 commit 1a9ec8e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/TinyGsmClientBG96.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class TinyGsmBG96 : public TinyGsmModem<TinyGsmBG96>,
*/
protected:
// enable GPS
bool enableGPSImpl() {
bool enableGPSImpl(GpsStartMode startMode = GPS_START_AUTO) {
sendAT(GF("+QGPS=1"));
if (waitResponse() != 1) { return false; }
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/TinyGsmClientSIM70xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class TinyGsmSim70xx : public TinyGsmModem<TinyGsmSim70xx<modemType>>,
*/
protected:
// enable GPS
bool enableGPSImpl() {
bool enableGPSImpl(GpsStartMode startMode = GPS_START_AUTO) {
thisModem().sendAT(GF("+CGNSPWR=1"));
if (thisModem().waitResponse() != 1) { return false; }
return true;
Expand Down
8 changes: 7 additions & 1 deletion src/TinyGsmClientSIM7600.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,13 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
*/
protected:
// enable GPS
bool enableGPSImpl() {
bool enableGPSImpl(GpsStartMode startMode = GPS_START_AUTO) {
switch (startMode) {
case GPS_START_COLD: sendAT(GF("+CGPSCOLD")); break;
case GPS_START_HOT: sendAT(GF("+CGPSHOT")); break;
default: sendAT(); break;
}
if (waitResponse() != 1) { return false; }
sendAT(GF("+CGPS=1"));
if (waitResponse() != 1) { return false; }
return true;
Expand Down
9 changes: 8 additions & 1 deletion src/TinyGsmClientSIM808.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS<TinyGsmSim808>, pu
*/
protected:
// enable GPS
bool enableGPSImpl() {
bool enableGPSImpl(GpsStartMode startMode = GPS_START_AUTO) {
sendAT(GF("+CGNSPWR=1"));
if (waitResponse() != 1) { return false; }
switch (startMode) {
case GPS_START_COLD: sendAT(GF("+CGPSRST="), 0); break;
case GPS_START_HOT: sendAT(GF("+CGPSRST="), 1); break;
case GPS_START_WARM: sendAT(GF("+CGPSRST="), 2); break;
default: return true;
}
if (waitResponse() != 1) { return false; }
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/TinyGsmClientSaraR4.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class TinyGsmSaraR4 : public TinyGsmModem<TinyGsmSaraR4>,
* I2C port, the GSM-based "Cell Locate" location will be returned instead.
*/
protected:
bool enableGPSImpl() {
bool enableGPSImpl(GpsStartMode startMode = GPS_START_AUTO) {
// AT+UGPS=<mode>[,<aid_mode>[,<GNSS_systems>]]
// <mode> - 0: GNSS receiver powered off, 1: on
// <aid_mode> - 0: no aiding (default)
Expand Down
2 changes: 1 addition & 1 deletion src/TinyGsmClientUBLOX.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class TinyGsmUBLOX : public TinyGsmModem<TinyGsmUBLOX>,
* I2C port, the GSM-based "Cell Locate" location will be returned instead.
*/
protected:
bool enableGPSImpl() {
bool enableGPSImpl(GpsStartMode startMode = GPS_START_AUTO) {
// AT+UGPS=<mode>[,<aid_mode>[,<GNSS_systems>]]
// <mode> - 0: GNSS receiver powered off, 1: on
// <aid_mode> - 0: no aiding (default)
Expand Down
13 changes: 10 additions & 3 deletions src/TinyGsmGPS.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@

#define TINY_GSM_MODEM_HAS_GPS

enum GpsStartMode {
GPS_START_AUTO = 0,
GPS_START_COLD = 1,
GPS_START_WARM = 2,
GPS_START_HOT = 3,
};

template <class modemType>
class TinyGsmGPS {
public:
/*
* GPS/GNSS/GLONASS location functions
*/
bool enableGPS() {
return thisModem().enableGPSImpl();
bool enableGPS(GpsStartMode startMode = GPS_START_AUTO) {
return thisModem().enableGPSImpl(startMode);
}
bool disableGPS() {
return thisModem().disableGPSImpl();
Expand Down Expand Up @@ -66,7 +73,7 @@ class TinyGsmGPS {
* GPS/GNSS/GLONASS location functions
*/

bool enableGPSImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED;
bool enableGPSImpl(GpsStartMode startMode = GPS_START_AUTO) TINY_GSM_ATTR_NOT_IMPLEMENTED;
bool disableGPSImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED;
String getGPSrawImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED;
bool getGPSImpl(float* lat, float* lon, float* speed = 0, float* alt = 0,
Expand Down

0 comments on commit 1a9ec8e

Please sign in to comment.