Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Added getPowerSaveMode #99

Merged
merged 1 commit into from
Apr 22, 2020
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
34 changes: 31 additions & 3 deletions examples/Example18_PowerSaveMode/Example18_PowerSaveMode.ino
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 !!!***"));
Expand All @@ -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
Expand Down Expand Up @@ -132,4 +160,4 @@ void loop()

Serial.println();
}
}
}
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ getGeofenceState KEYWORD2
setDynamicModel KEYWORD2
getDynamicModel KEYWORD2
powerSaveMode KEYWORD2
getPowerSaveMode KEYWORD2

configureMessage KEYWORD2
enableMessage KEYWORD2
Expand Down
36 changes: 36 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/SparkFun_Ublox_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down