diff --git a/examples/Example18_PowerSaveMode/Example18_PowerSaveMode.ino b/examples/Example18_PowerSaveMode/Example18_PowerSaveMode.ino index 291fcc1..49a479d 100644 --- a/examples/Example18_PowerSaveMode/Example18_PowerSaveMode.ino +++ b/examples/Example18_PowerSaveMode/Example18_PowerSaveMode.ino @@ -1,7 +1,7 @@ /* Power Save Mode By: Paul Clark (PaulZC) - Date: December 18th, 2019 + Date: April 22nd, 2020 Based extensively on Example3_GetPosition By: Nathan Seidle @@ -82,7 +82,7 @@ void loop() // Put the GNSS into power save mode // (If you want to disable power save mode, call myGPS.powerSaveMode(false) instead) // This will fail on the ZED (protocol version >= 27) as UBX-CFG-RXM is not supported - if (myGPS.powerSaveMode()) + if (myGPS.powerSaveMode()) // Defaults to true Serial.println(F("Power Save Mode enabled.")); else Serial.println(F("***!!! Power Save Mode FAILED !!!***")); @@ -95,6 +95,34 @@ void loop() else Serial.println(F("***!!! Power Save Disable FAILED !!!***")); } + + // Read and print the new low power mode + uint8_t lowPowerMode = myGPS.getPowerSaveMode(); + if (lowPowerMode == 255) + { + Serial.println(F("***!!! getPowerSaveMode FAILED !!!***")); + } + else + { + Serial.print(F("The low power mode is: ")); + Serial.print(lowPowerMode); + if (lowPowerMode == 0) + { + Serial.println(F(" (Continuous)")); + } + else if (lowPowerMode == 1) + { + Serial.println(F(" (Power Save)")); + } + else if (lowPowerMode == 4) + { + Serial.println(F(" (Continuous)")); + } + else + { + Serial.println(F(" (Unknown!)")); + } + } } //Query module every 10 seconds so it is easier to monitor the current draw @@ -132,4 +160,4 @@ void loop() Serial.println(); } -} \ No newline at end of file +} diff --git a/keywords.txt b/keywords.txt index 03b844c..7562d61 100644 --- a/keywords.txt +++ b/keywords.txt @@ -136,6 +136,7 @@ getGeofenceState KEYWORD2 setDynamicModel KEYWORD2 getDynamicModel KEYWORD2 powerSaveMode KEYWORD2 +getPowerSaveMode KEYWORD2 configureMessage KEYWORD2 enableMessage KEYWORD2 diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index ade8796..893f956 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -2510,6 +2510,42 @@ boolean SFE_UBLOX_GPS::powerSaveMode(bool power_save, uint16_t maxWait) return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK } +// Get Power Save Mode +// Returns the current Low Power Mode using UBX-CFG-RXM +// Returns 255 if the sendCommand fails +uint8_t SFE_UBLOX_GPS::getPowerSaveMode(uint16_t maxWait) +{ + // Let's begin by checking the Protocol Version as UBX_CFG_RXM is not supported on the ZED (protocol >= 27) + uint8_t protVer = getProtocolVersionHigh(maxWait); + /* + if (_printDebug == true) + { + _debugSerial->print(F("Protocol version is ")); + _debugSerial->println(protVer); + } + */ + if (protVer >= 27) + { + if (_printDebug == true) + { + _debugSerial->println(F("powerSaveMode (UBX-CFG-RXM) is not supported by this protocol version")); + } + return (255); + } + + // Now let's read the power setting using UBX-CFG-RXM + packetCfg.cls = UBX_CLASS_CFG; + packetCfg.id = UBX_CFG_RXM; + packetCfg.len = 0; + packetCfg.startingSpot = 0; + + //Ask module for the current power management settings. Loads into payloadCfg. + if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK + return (255); + + return (payloadCfg[1]); // Return the low power mode +} + //Change the dynamic platform model using UBX-CFG-NAV5 //Possible values are: //PORTABLE,STATIONARY,PEDESTRIAN,AUTOMOTIVE,SEA, diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index 640d564..9ff0a01 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -614,6 +614,7 @@ class SFE_UBLOX_GPS geofenceParams currentGeofenceParams; // Global to store the geofence parameters boolean powerSaveMode(bool power_save = true, uint16_t maxWait = 1100); + uint8_t getPowerSaveMode(uint16_t maxWait = 1100); // Returns 255 if the sendCommand fails //Change the dynamic platform model using UBX-CFG-NAV5 boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100);