@@ -1642,89 +1642,89 @@ boolean SFE_UBLOX_GPS::setAutoPVT(boolean enable, boolean implicitUpdate, uint16
16421642// Add a new geofence using UBX-CFG-GEOFENCE
16431643boolean SFE_UBLOX_GPS::addGeofence (int32_t  latitude, int32_t  longitude, uint32_t  radius, byte confidence, byte pinPolarity, byte pin, uint16_t  maxWait)
16441644{
1645- if  (currentGeofenceParams.numFences  >= 4 ) return (false ); //  Quit if we already have four geofences defined
1646- 
1647- //  Store the new geofence parameters
1648- lats [currentGeofenceParams.numFences ] = latitude;
1649- longs [currentGeofenceParams.numFences ] = longitude;
1650- rads [currentGeofenceParams.numFences ] = radius;
1651- numFences  = currentGeofenceParams.numFences  + 1 ; //  Increment the number of fences
1652- 
1653- cls  = UBX_CLASS_CFG;
1654- id  = UBX_CFG_GEOFENCE;
1655- len  = (currentGeofenceParams.numFences  * 12 ) + 8 ;
1656- startingSpot  = 0 ;
1657- 
1658- 0 ] = 0 ; //  Message version = 0x00
1659- 1 ] = currentGeofenceParams.numFences ; //  numFences
1660- 2 ] = confidence; //  confLvl = Confidence level 0-4 (none, 68%, 95%, 99.7%, 99.99%)
1661- 3 ] = 0 ; //  reserved1
1662- if  (pin > 0 )
1663- 
1664- 4 ] = 1 ; //  enable PIO combined fence state
1665- 
1666- else 
1667- 
1668- 4 ] = 0 ; //  disable PIO combined fence state
1669- 
1670- 5 ] = pinPolarity; //  PIO pin polarity (0 = low means inside, 1 = low means outside (or unknown))
1671- 6 ] = pin; //  PIO pin
1672- 7 ] = 0 ; // reserved2
1673- 8 ] = currentGeofenceParams.lats [0 ] & 0xFF ;
1674- 9 ] = currentGeofenceParams.lats [0 ] >> 8 ;
1675- 10 ] = currentGeofenceParams.lats [0 ] >> 16 ;
1676- 11 ] = currentGeofenceParams.lats [0 ] >> 24 ;
1677- 12 ] = currentGeofenceParams.longs [0 ] & 0xFF ;
1678- 13 ] = currentGeofenceParams.longs [0 ] >> 8 ;
1679- 14 ] = currentGeofenceParams.longs [0 ] >> 16 ;
1680- 15 ] = currentGeofenceParams.longs [0 ] >> 24 ;
1681- 16 ] = currentGeofenceParams.rads [0 ] & 0xFF ;
1682- 17 ] = currentGeofenceParams.rads [0 ] >> 8 ;
1683- 18 ] = currentGeofenceParams.rads [0 ] >> 16 ;
1684- 19 ] = currentGeofenceParams.rads [0 ] >> 24 ;
1685- if  (currentGeofenceParams.numFences  >= 2 ) {
1686- 20 ] = currentGeofenceParams.lats [1 ] & 0xFF ;
1687- 21 ] = currentGeofenceParams.lats [1 ] >> 8 ;
1688- 22 ] = currentGeofenceParams.lats [1 ] >> 16 ;
1689- 23 ] = currentGeofenceParams.lats [1 ] >> 24 ;
1690- 24 ] = currentGeofenceParams.longs [1 ] & 0xFF ;
1691- 25 ] = currentGeofenceParams.longs [1 ] >> 8 ;
1692- 26 ] = currentGeofenceParams.longs [1 ] >> 16 ;
1693- 27 ] = currentGeofenceParams.longs [1 ] >> 24 ;
1694- 28 ] = currentGeofenceParams.rads [1 ] & 0xFF ;
1695- 29 ] = currentGeofenceParams.rads [1 ] >> 8 ;
1696- 30 ] = currentGeofenceParams.rads [1 ] >> 16 ;
1697- 31 ] = currentGeofenceParams.rads [1 ] >> 24 ;
1698- 
1699- if  (currentGeofenceParams.numFences  >= 3 ) {
1700- 32 ] = currentGeofenceParams.lats [2 ] & 0xFF ;
1701- 33 ] = currentGeofenceParams.lats [2 ] >> 8 ;
1702- 34 ] = currentGeofenceParams.lats [2 ] >> 16 ;
1703- 35 ] = currentGeofenceParams.lats [2 ] >> 24 ;
1704- 36 ] = currentGeofenceParams.longs [2 ] & 0xFF ;
1705- 37 ] = currentGeofenceParams.longs [2 ] >> 8 ;
1706- 38 ] = currentGeofenceParams.longs [2 ] >> 16 ;
1707- 39 ] = currentGeofenceParams.longs [2 ] >> 24 ;
1708- 40 ] = currentGeofenceParams.rads [2 ] & 0xFF ;
1709- 41 ] = currentGeofenceParams.rads [2 ] >> 8 ;
1710- 42 ] = currentGeofenceParams.rads [2 ] >> 16 ;
1711- 43 ] = currentGeofenceParams.rads [2 ] >> 24 ;
1712- 
1713- if  (currentGeofenceParams.numFences  >= 4 ) {
1714- 44 ] = currentGeofenceParams.lats [3 ] & 0xFF ;
1715- 45 ] = currentGeofenceParams.lats [3 ] >> 8 ;
1716- 46 ] = currentGeofenceParams.lats [3 ] >> 16 ;
1717- 47 ] = currentGeofenceParams.lats [3 ] >> 24 ;
1718- 48 ] = currentGeofenceParams.longs [3 ] & 0xFF ;
1719- 49 ] = currentGeofenceParams.longs [3 ] >> 8 ;
1720- 50 ] = currentGeofenceParams.longs [3 ] >> 16 ;
1721- 51 ] = currentGeofenceParams.longs [3 ] >> 24 ;
1722- 52 ] = currentGeofenceParams.rads [3 ] & 0xFF ;
1723- 53 ] = currentGeofenceParams.rads [3 ] >> 8 ;
1724- 54 ] = currentGeofenceParams.rads [3 ] >> 16 ;
1725- 55 ] = currentGeofenceParams.rads [3 ] >> 24 ;
1726- 
1727- return  (sendCommand (packetCfg, maxWait)); // Wait for ack
1645+   if  (currentGeofenceParams.numFences  >= 4 ) return (false ); //  Quit if we already have four geofences defined
1646+ 
1647+   //  Store the new geofence parameters
1648+   currentGeofenceParams.lats [currentGeofenceParams.numFences ] = latitude;
1649+   currentGeofenceParams.longs [currentGeofenceParams.numFences ] = longitude;
1650+   currentGeofenceParams.rads [currentGeofenceParams.numFences ] = radius;
1651+   currentGeofenceParams.numFences  = currentGeofenceParams.numFences  + 1 ; //  Increment the number of fences
1652+ 
1653+   packetCfg.cls  = UBX_CLASS_CFG;
1654+   packetCfg.id  = UBX_CFG_GEOFENCE;
1655+   packetCfg.len  = (currentGeofenceParams.numFences  * 12 ) + 8 ;
1656+   packetCfg.startingSpot  = 0 ;
1657+ 
1658+   payloadCfg[0 ] = 0 ; //  Message version = 0x00
1659+   payloadCfg[1 ] = currentGeofenceParams.numFences ; //  numFences
1660+   payloadCfg[2 ] = confidence; //  confLvl = Confidence level 0-4 (none, 68%, 95%, 99.7%, 99.99%)
1661+   payloadCfg[3 ] = 0 ; //  reserved1
1662+   if  (pin > 0 )
1663+   {
1664+   payloadCfg[4 ] = 1 ; //  enable PIO combined fence state
1665+   }
1666+   else 
1667+   {
1668+   payloadCfg[4 ] = 0 ; //  disable PIO combined fence state
1669+   }
1670+   payloadCfg[5 ] = pinPolarity; //  PIO pin polarity (0 = low means inside, 1 = low means outside (or unknown))
1671+   payloadCfg[6 ] = pin; //  PIO pin
1672+   payloadCfg[7 ] = 0 ; // reserved2
1673+   payloadCfg[8 ] = currentGeofenceParams.lats [0 ] & 0xFF ;
1674+   payloadCfg[9 ] = currentGeofenceParams.lats [0 ] >> 8 ;
1675+   payloadCfg[10 ] = currentGeofenceParams.lats [0 ] >> 16 ;
1676+   payloadCfg[11 ] = currentGeofenceParams.lats [0 ] >> 24 ;
1677+   payloadCfg[12 ] = currentGeofenceParams.longs [0 ] & 0xFF ;
1678+   payloadCfg[13 ] = currentGeofenceParams.longs [0 ] >> 8 ;
1679+   payloadCfg[14 ] = currentGeofenceParams.longs [0 ] >> 16 ;
1680+   payloadCfg[15 ] = currentGeofenceParams.longs [0 ] >> 24 ;
1681+   payloadCfg[16 ] = currentGeofenceParams.rads [0 ] & 0xFF ;
1682+   payloadCfg[17 ] = currentGeofenceParams.rads [0 ] >> 8 ;
1683+   payloadCfg[18 ] = currentGeofenceParams.rads [0 ] >> 16 ;
1684+   payloadCfg[19 ] = currentGeofenceParams.rads [0 ] >> 24 ;
1685+   if  (currentGeofenceParams.numFences  >= 2 ) {
1686+   payloadCfg[20 ] = currentGeofenceParams.lats [1 ] & 0xFF ;
1687+   payloadCfg[21 ] = currentGeofenceParams.lats [1 ] >> 8 ;
1688+   payloadCfg[22 ] = currentGeofenceParams.lats [1 ] >> 16 ;
1689+   payloadCfg[23 ] = currentGeofenceParams.lats [1 ] >> 24 ;
1690+   payloadCfg[24 ] = currentGeofenceParams.longs [1 ] & 0xFF ;
1691+   payloadCfg[25 ] = currentGeofenceParams.longs [1 ] >> 8 ;
1692+   payloadCfg[26 ] = currentGeofenceParams.longs [1 ] >> 16 ;
1693+   payloadCfg[27 ] = currentGeofenceParams.longs [1 ] >> 24 ;
1694+   payloadCfg[28 ] = currentGeofenceParams.rads [1 ] & 0xFF ;
1695+   payloadCfg[29 ] = currentGeofenceParams.rads [1 ] >> 8 ;
1696+   payloadCfg[30 ] = currentGeofenceParams.rads [1 ] >> 16 ;
1697+   payloadCfg[31 ] = currentGeofenceParams.rads [1 ] >> 24 ;
1698+   }
1699+   if  (currentGeofenceParams.numFences  >= 3 ) {
1700+   payloadCfg[32 ] = currentGeofenceParams.lats [2 ] & 0xFF ;
1701+   payloadCfg[33 ] = currentGeofenceParams.lats [2 ] >> 8 ;
1702+   payloadCfg[34 ] = currentGeofenceParams.lats [2 ] >> 16 ;
1703+   payloadCfg[35 ] = currentGeofenceParams.lats [2 ] >> 24 ;
1704+   payloadCfg[36 ] = currentGeofenceParams.longs [2 ] & 0xFF ;
1705+   payloadCfg[37 ] = currentGeofenceParams.longs [2 ] >> 8 ;
1706+   payloadCfg[38 ] = currentGeofenceParams.longs [2 ] >> 16 ;
1707+   payloadCfg[39 ] = currentGeofenceParams.longs [2 ] >> 24 ;
1708+   payloadCfg[40 ] = currentGeofenceParams.rads [2 ] & 0xFF ;
1709+   payloadCfg[41 ] = currentGeofenceParams.rads [2 ] >> 8 ;
1710+   payloadCfg[42 ] = currentGeofenceParams.rads [2 ] >> 16 ;
1711+   payloadCfg[43 ] = currentGeofenceParams.rads [2 ] >> 24 ;
1712+   }
1713+   if  (currentGeofenceParams.numFences  >= 4 ) {
1714+   payloadCfg[44 ] = currentGeofenceParams.lats [3 ] & 0xFF ;
1715+   payloadCfg[45 ] = currentGeofenceParams.lats [3 ] >> 8 ;
1716+   payloadCfg[46 ] = currentGeofenceParams.lats [3 ] >> 16 ;
1717+   payloadCfg[47 ] = currentGeofenceParams.lats [3 ] >> 24 ;
1718+   payloadCfg[48 ] = currentGeofenceParams.longs [3 ] & 0xFF ;
1719+   payloadCfg[49 ] = currentGeofenceParams.longs [3 ] >> 8 ;
1720+   payloadCfg[50 ] = currentGeofenceParams.longs [3 ] >> 16 ;
1721+   payloadCfg[51 ] = currentGeofenceParams.longs [3 ] >> 24 ;
1722+   payloadCfg[52 ] = currentGeofenceParams.rads [3 ] & 0xFF ;
1723+   payloadCfg[53 ] = currentGeofenceParams.rads [3 ] >> 8 ;
1724+   payloadCfg[54 ] = currentGeofenceParams.rads [3 ] >> 16 ;
1725+   payloadCfg[55 ] = currentGeofenceParams.rads [3 ] >> 24 ;
1726+   }
1727+   return  (sendCommand (packetCfg, maxWait)); // Wait for ack
17281728}
17291729
17301730// Clear all geofences using UBX-CFG-GEOFENCE
@@ -1789,53 +1789,6 @@ boolean SFE_UBLOX_GPS::getGeofenceState(geofenceState ¤tGeofenceState, uin
17891789 return (true );
17901790}
17911791
1792- // Power Save Mode
1793- // Enables/Disables Low Power Mode using UBX-CFG-RXM
1794- boolean SFE_UBLOX_GPS::powerSaveMode (bool  power_save, uint16_t  maxWait)
1795- {
1796- //  Let's begin by checking the Protocol Version as UBX_CFG_RXM is not supported on the ZED (protocol >= 27)
1797- uint8_t  protVer = getProtocolVersionHigh ();
1798- /* 
1799- if (_printDebug == true) 
1800- { 
1801- _debugSerial->print("Protocol version is "); 
1802- _debugSerial->println(protVer); 
1803- } 
1804- */ 
1805- if  (protVer >= 27 )
1806- {
1807- debugPrintln ((char  *)" powerSaveMode (UBX-CFG-RXM) is not supported by this protocol version" 
1808- return  (false );
1809- }
1810- 
1811- //  Now let's change the power setting using UBX-CFG-RXM
1812- packetCfg.cls  = UBX_CLASS_CFG;
1813- packetCfg.id  = UBX_CFG_RXM;
1814- packetCfg.len  = 0 ;
1815- packetCfg.startingSpot  = 0 ;
1816- 
1817- if  (sendCommand (packetCfg, maxWait) == false ) // Ask module for the current power management settings. Loads into payloadCfg.
1818- return  (false );
1819- 
1820- //  Let's make sure we wait for the ACK too (sendCommand will have returned as soon as the module sent its response)
1821- //  This is only required because we are doing two sendCommands in quick succession using the same class and ID
1822- waitForResponse (UBX_CLASS_CFG, UBX_CFG_RXM, 100 ); //  But we'll only wait for 100msec max
1823- 
1824- if  (power_save)
1825- {
1826- payloadCfg[1 ] = 1 ; //  Power Save Mode
1827- }
1828- else 
1829- {
1830- payloadCfg[1 ] = 0 ; //  Continuous Mode
1831- }
1832- 
1833- packetCfg.len  = 2 ;
1834- packetCfg.startingSpot  = 0 ;
1835- 
1836- return  (sendCommand (packetCfg, maxWait)); // Wait for ack
1837- }
1838- 
18391792// Given a spot in the payload array, extract four bytes and build a long
18401793uint32_t  SFE_UBLOX_GPS::extractLong (uint8_t  spotToStart)
18411794{
@@ -2180,7 +2133,7 @@ uint16_t SFE_UBLOX_GPS::getPDOP(uint16_t maxWait)
21802133uint8_t  SFE_UBLOX_GPS::getProtocolVersionHigh (uint16_t  maxWait)
21812134{
21822135 if  (moduleQueried.versionNumber  == false )
2183-  getProtocolVersion (maxWait );
2136+  getProtocolVersion ();
21842137 moduleQueried.versionNumber  = false ;
21852138 return  (versionHigh);
21862139}
@@ -2190,7 +2143,7 @@ uint8_t SFE_UBLOX_GPS::getProtocolVersionHigh(uint16_t maxWait)
21902143uint8_t  SFE_UBLOX_GPS::getProtocolVersionLow (uint16_t  maxWait)
21912144{
21922145 if  (moduleQueried.versionNumber  == false )
2193-  getProtocolVersion (maxWait );
2146+  getProtocolVersion ();
21942147 moduleQueried.versionNumber  = false ;
21952148 return  (versionLow);
21962149}
@@ -2213,10 +2166,6 @@ boolean SFE_UBLOX_GPS::getProtocolVersion(uint16_t maxWait)
22132166 if  (sendCommand (packetCfg, maxWait) == false )
22142167 return  (false ); // If command send fails then bail
22152168
2216- //  Let's make sure we wait for the ACK too (sendCommand will have returned as soon as the module sent its response)
2217- //  This is only required because we are doing multiple sendCommands in quick succession using the same class and ID
2218- waitForResponse (UBX_CLASS_MON, UBX_MON_VER, 100 ); //  But we'll only wait for 100msec max
2219- 
22202169 if  (_printDebug == true )
22212170 {
22222171 _debugSerial->print (" Extension " 
@@ -2236,7 +2185,7 @@ boolean SFE_UBLOX_GPS::getProtocolVersion(uint16_t maxWait)
22362185 {
22372186 versionHigh = (payloadCfg[8 ] - ' 0' 10  + (payloadCfg[9 ] - ' 0' // Convert '18' to 18
22382187 versionLow = (payloadCfg[11 ] - ' 0' 10  + (payloadCfg[12 ] - ' 0' // Convert '00' to 00
2239-  return  (true );  //  This function returns a boolean (so we can't return  versionLow)
2188+  return  (versionLow); 
22402189 }
22412190 }
22422191
0 commit comments