@@ -247,7 +247,7 @@ boolean SFE_UBLOX_GPS::setI2CAddress(uint8_t deviceAddress, uint16_t maxWait)
247247 // payloadCfg is now loaded with current bytes. Change only the ones we need to
248248 payloadCfg[4 ] = deviceAddress << 1 ; // DDC mode LSB
249249
250- if (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT)
250+ if (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT) // We are only expecting an ACK
251251 {
252252 // Success! Now change our internal global.
253253 _gpsI2Caddress = deviceAddress; // Store the I2C address from user
@@ -980,14 +980,7 @@ boolean SFE_UBLOX_GPS::isConnected()
980980 packetCfg.len = 0 ;
981981 packetCfg.startingSpot = 0 ;
982982
983- if (sendCommand (packetCfg) == SFE_UBLOX_STATUS_DATA_SENT)
984- {
985- return true ;
986- }
987- else
988- {
989- return false ;
990- }
983+ return (sendCommand (packetCfg) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are polling the RATE so we expect data and an ACK
991984 }
992985 return false ;
993986}
@@ -1269,10 +1262,7 @@ boolean SFE_UBLOX_GPS::saveConfiguration(uint16_t maxWait)
12691262 packetCfg.payload [4 ] = 0xFF ; // Set any bit in the saveMask field to save current config to Flash and BBR
12701263 packetCfg.payload [5 ] = 0xFF ;
12711264
1272- if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_SENT)
1273- return (false ); // If command send fails then bail
1274-
1275- return (true );
1265+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
12761266}
12771267
12781268// Save the selected configuration sub-sections to flash and BBR (battery backed RAM)
@@ -1293,10 +1283,7 @@ boolean SFE_UBLOX_GPS::saveConfigSelective(uint32_t configMask, uint16_t maxWait
12931283 packetCfg.payload [6 ] = (configMask >> 16 ) & 0xFF ;
12941284 packetCfg.payload [7 ] = (configMask >> 24 ) & 0xFF ;
12951285
1296- if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_SENT)
1297- return (false ); // If command send fails then bail
1298-
1299- return (true );
1286+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
13001287}
13011288
13021289// Reset module to factory defaults
@@ -1317,10 +1304,7 @@ boolean SFE_UBLOX_GPS::factoryDefault(uint16_t maxWait)
13171304 packetCfg.payload [8 ] = 0xFF ; // Set any bit in the loadMask field to discard current config and rebuild from lower non-volatile memory layers
13181305 packetCfg.payload [9 ] = 0xFF ;
13191306
1320- if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_SENT)
1321- return (false ); // If command send fails then bail
1322-
1323- return (true );
1307+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
13241308}
13251309
13261310// Given a group, ID and size, return the value of this config spot
@@ -1383,8 +1367,8 @@ uint8_t SFE_UBLOX_GPS::getVal8(uint32_t key, uint8_t layer, uint16_t maxWait)
13831367 _debugSerial->print (F (" getVal8: sendCommand returned: " ));
13841368 _debugSerial->println (statusString (retVal));
13851369 }
1386- if (retVal != SFE_UBLOX_STATUS_DATA_SENT)
1387- return (false ); // If command send fails then bail
1370+ if (retVal != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
1371+ return (0 ); // If command send fails then bail
13881372
13891373 // Verify the response is the correct length as compared to what the user called (did the module respond with 8-bits but the user called getVal32?)
13901374 // Response is 8 bytes plus cfg data
@@ -1433,11 +1417,7 @@ uint8_t SFE_UBLOX_GPS::setVal16(uint32_t key, uint16_t value, uint8_t layer, uin
14331417 payloadCfg[9 ] = value >> 8 * 1 ;
14341418
14351419 // Send VALSET command with this key and value
1436- if (sendCommand (packetCfg, maxWait) == false )
1437- return (false ); // If command send fails then bail
1438-
1439- // All done
1440- return (true );
1420+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
14411421}
14421422
14431423// Given a key, set an 8-bit value
@@ -1468,11 +1448,7 @@ uint8_t SFE_UBLOX_GPS::setVal8(uint32_t key, uint8_t value, uint8_t layer, uint1
14681448 payloadCfg[8 ] = value; // Value
14691449
14701450 // Send VALSET command with this key and value
1471- if (sendCommand (packetCfg, maxWait) == false )
1472- return (false ); // If command send fails then bail
1473-
1474- // All done
1475- return (true );
1451+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
14761452}
14771453
14781454// Given a key, set a 32-bit value
@@ -1506,11 +1482,7 @@ uint8_t SFE_UBLOX_GPS::setVal32(uint32_t key, uint32_t value, uint8_t layer, uin
15061482 payloadCfg[11 ] = value >> 8 * 3 ;
15071483
15081484 // Send VALSET command with this key and value
1509- if (sendCommand (packetCfg, maxWait) == false )
1510- return (false ); // If command send fails then bail
1511-
1512- // All done
1513- return (true );
1485+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
15141486}
15151487
15161488// Start defining a new UBX-CFG-VALSET ubxPacket
@@ -1682,11 +1654,7 @@ uint8_t SFE_UBLOX_GPS::sendCfgValset32(uint32_t key, uint32_t value, uint16_t ma
16821654 addCfgValset32 (key, value);
16831655
16841656 // Send VALSET command with this key and value
1685- if (sendCommand (packetCfg, maxWait) == false )
1686- return (false ); // If command send fails then bail
1687-
1688- // All done
1689- return (true );
1657+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
16901658}
16911659
16921660// Add a final keyID and value to an existing UBX-CFG-VALSET ubxPacket and send it
@@ -1697,11 +1665,7 @@ uint8_t SFE_UBLOX_GPS::sendCfgValset16(uint32_t key, uint16_t value, uint16_t ma
16971665 addCfgValset16 (key, value);
16981666
16991667 // Send VALSET command with this key and value
1700- if (sendCommand (packetCfg, maxWait) == false )
1701- return (false ); // If command send fails then bail
1702-
1703- // All done
1704- return (true );
1668+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
17051669}
17061670
17071671// Add a final keyID and value to an existing UBX-CFG-VALSET ubxPacket and send it
@@ -1712,11 +1676,7 @@ uint8_t SFE_UBLOX_GPS::sendCfgValset8(uint32_t key, uint8_t value, uint16_t maxW
17121676 addCfgValset8 (key, value);
17131677
17141678 // Send VALSET command with this key and value
1715- if (sendCommand (packetCfg, maxWait) == false )
1716- return (false ); // If command send fails then bail
1717-
1718- // All done
1719- return (true );
1679+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
17201680}
17211681
17221682// Get the current TimeMode3 settings - these contain survey in statuses
@@ -1727,7 +1687,7 @@ boolean SFE_UBLOX_GPS::getSurveyMode(uint16_t maxWait)
17271687 packetCfg.len = 0 ;
17281688 packetCfg.startingSpot = 0 ;
17291689
1730- return (sendCommand (packetCfg, maxWait));
1690+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are expecting data and an ACK
17311691}
17321692
17331693// Control Survey-In for NEO-M8P
@@ -1756,7 +1716,7 @@ boolean SFE_UBLOX_GPS::setSurveyMode(uint8_t mode, uint16_t observationTime, flo
17561716 payloadCfg[29 ] = svinAccLimit >> 8 ;
17571717 payloadCfg[30 ] = svinAccLimit >> 16 ;
17581718
1759- return (sendCommand (packetCfg, maxWait)); // Wait for ack
1719+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT) ; // We are only expecting an ACK
17601720}
17611721
17621722// Begin Survey-In for NEO-M8P
@@ -1787,7 +1747,7 @@ boolean SFE_UBLOX_GPS::getSurveyStatus(uint16_t maxWait)
17871747 packetCfg.len = 0 ;
17881748 packetCfg.startingSpot = 0 ;
17891749
1790- if (sendCommand (packetCfg, maxWait) == false )
1750+ if (( sendCommand (packetCfg, maxWait)) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
17911751 return (false ); // If command send fails then bail
17921752
17931753 // We got a response, now parse the bits into the svin structure
@@ -1812,7 +1772,7 @@ boolean SFE_UBLOX_GPS::getPortSettings(uint8_t portID, uint16_t maxWait)
18121772
18131773 payloadCfg[0 ] = portID;
18141774
1815- return (sendCommand (packetCfg, maxWait));
1775+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are expecting data and an ACK
18161776}
18171777
18181778// Configure a given port to output UBX, NMEA, RTCM3 or a combination thereof
@@ -1841,7 +1801,7 @@ boolean SFE_UBLOX_GPS::setPortOutput(uint8_t portID, uint8_t outStreamSettings,
18411801 // payloadCfg is now loaded with current bytes. Change only the ones we need to
18421802 payloadCfg[14 ] = outStreamSettings; // OutProtocolMask LSB - Set outStream bits
18431803
1844- return (sendCommand (packetCfg, maxWait));
1804+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
18451805}
18461806
18471807// Configure a given port to input UBX, NMEA, RTCM3 or a combination thereof
@@ -1862,7 +1822,7 @@ boolean SFE_UBLOX_GPS::setPortInput(uint8_t portID, uint8_t inStreamSettings, ui
18621822 // payloadCfg is now loaded with current bytes. Change only the ones we need to
18631823 payloadCfg[12 ] = inStreamSettings; // InProtocolMask LSB - Set inStream bits
18641824
1865- return (sendCommand (packetCfg, maxWait));
1825+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
18661826}
18671827
18681828// Configure a port to output UBX, NMEA, RTCM3 or a combination thereof
@@ -1903,16 +1863,17 @@ boolean SFE_UBLOX_GPS::setNavigationFrequency(uint8_t navFreq, uint16_t maxWait)
19031863 packetCfg.len = 0 ;
19041864 packetCfg.startingSpot = 0 ;
19051865
1906- if (sendCommand (packetCfg, maxWait) == false ) // This will load the payloadCfg array with current settings of the given register
1907- return (false ); // If command send fails then bail
1866+ // This will load the payloadCfg array with current settings of the given register
1867+ if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
1868+ return (false ); // If command send fails then bail
19081869
19091870 uint16_t measurementRate = 1000 / navFreq;
19101871
19111872 // payloadCfg is now loaded with current bytes. Change only the ones we need to
19121873 payloadCfg[0 ] = measurementRate & 0xFF ; // measRate LSB
19131874 payloadCfg[1 ] = measurementRate >> 8 ; // measRate MSB
19141875
1915- return (sendCommand (packetCfg, maxWait));
1876+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
19161877}
19171878
19181879// Get the rate at which the module is outputting nav solutions
@@ -1924,8 +1885,9 @@ uint8_t SFE_UBLOX_GPS::getNavigationFrequency(uint16_t maxWait)
19241885 packetCfg.len = 0 ;
19251886 packetCfg.startingSpot = 0 ;
19261887
1927- if (sendCommand (packetCfg, maxWait) == false ) // This will load the payloadCfg array with current settings of the given register
1928- return (0 ); // If command send fails then bail
1888+ // This will load the payloadCfg array with current settings of the given register
1889+ if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
1890+ return (0 ); // If command send fails then bail
19291891
19301892 uint16_t measurementRate = 0 ;
19311893
@@ -1968,7 +1930,7 @@ boolean SFE_UBLOX_GPS::setAutoPVT(boolean enable, boolean implicitUpdate, uint16
19681930 payloadCfg[1 ] = UBX_NAV_PVT;
19691931 payloadCfg[2 ] = enable ? 1 : 0 ; // rate relative to navigation freq.
19701932
1971- bool ok = sendCommand (packetCfg, maxWait);
1933+ boolean ok = (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
19721934 if (ok)
19731935 {
19741936 autoPVT = enable;
@@ -1994,7 +1956,7 @@ boolean SFE_UBLOX_GPS::configureMessage(uint8_t msgClass, uint8_t msgID, uint8_t
19941956 packetCfg.payload [1 ] = msgID;
19951957 packetCfg.payload [2 + portID] = sendRate; // Send rate is relative to the event a message is registered on. For example, if the rate of a navigation message is set to 2, the message is sent every 2nd navigation solution.
19961958
1997- return (sendCommand (packetCfg, maxWait));
1959+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
19981960}
19991961
20001962// Enable a given message type, default of 1 per update rate (usually 1 per second)
@@ -2132,7 +2094,7 @@ boolean SFE_UBLOX_GPS::addGeofence(int32_t latitude, int32_t longitude, uint32_t
21322094 payloadCfg[54 ] = currentGeofenceParams.rads [3 ] >> 16 ;
21332095 payloadCfg[55 ] = currentGeofenceParams.rads [3 ] >> 24 ;
21342096 }
2135- return (sendCommand (packetCfg, maxWait)); // Wait for ack
2097+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT) ; // We are only expecting an ACK
21362098}
21372099
21382100// Clear all geofences using UBX-CFG-GEOFENCE
@@ -2154,7 +2116,7 @@ boolean SFE_UBLOX_GPS::clearGeofences(uint16_t maxWait)
21542116
21552117 currentGeofenceParams.numFences = 0 ; // Zero the number of geofences currently in use
21562118
2157- return (sendCommand (packetCfg, maxWait)); // Wait for ack
2119+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT) ; // We are only expecting an ACK
21582120}
21592121
21602122// Clear the antenna control settings using UBX-CFG-ANT
@@ -2172,7 +2134,7 @@ boolean SFE_UBLOX_GPS::clearAntPIO(uint16_t maxWait)
21722134 payloadCfg[2 ] = 0xFF ; // Antenna pin configuration: set pinSwitch and pinSCD to 31
21732135 payloadCfg[3 ] = 0xFF ; // Antenna pin configuration: set pinOCD to 31, set reconfig bit
21742136
2175- return (sendCommand (packetCfg, maxWait)); // Wait for ack
2137+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT) ; // We are only expecting an ACK
21762138}
21772139
21782140// Returns the combined geofence state using UBX-NAV-GEOFENCE
@@ -2183,7 +2145,8 @@ boolean SFE_UBLOX_GPS::getGeofenceState(geofenceState ¤tGeofenceState, uin
21832145 packetCfg.len = 0 ;
21842146 packetCfg.startingSpot = 0 ;
21852147
2186- if (sendCommand (packetCfg, maxWait) == false ) // Ask module for the geofence status. Loads into payloadCfg.
2148+ // Ask module for the geofence status. Loads into payloadCfg.
2149+ if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
21872150 return (false );
21882151
21892152 currentGeofenceState.status = payloadCfg[5 ]; // Extract the status
@@ -2229,7 +2192,8 @@ boolean SFE_UBLOX_GPS::powerSaveMode(bool power_save, uint16_t maxWait)
22292192 packetCfg.len = 0 ;
22302193 packetCfg.startingSpot = 0 ;
22312194
2232- if (sendCommand (packetCfg, maxWait) == false ) // Ask module for the current power management settings. Loads into payloadCfg.
2195+ // Ask module for the current power management settings. Loads into payloadCfg.
2196+ if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
22332197 return (false );
22342198
22352199 if (power_save)
@@ -2244,7 +2208,7 @@ boolean SFE_UBLOX_GPS::powerSaveMode(bool power_save, uint16_t maxWait)
22442208 packetCfg.len = 2 ;
22452209 packetCfg.startingSpot = 0 ;
22462210
2247- return (sendCommand (packetCfg, maxWait)); // Wait for ack
2211+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT ); // We are only expecting an ACK
22482212}
22492213
22502214// Change the dynamic platform model using UBX-CFG-NAV5
@@ -2260,7 +2224,8 @@ boolean SFE_UBLOX_GPS::setDynamicModel(dynModel newDynamicModel, uint16_t maxWai
22602224 packetCfg.len = 0 ;
22612225 packetCfg.startingSpot = 0 ;
22622226
2263- if (sendCommand (packetCfg, maxWait) == false ) // Ask module for the current navigation model settings. Loads into payloadCfg.
2227+ // Ask module for the current navigation model settings. Loads into payloadCfg.
2228+ if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
22642229 return (false );
22652230
22662231 payloadCfg[0 ] = 0x01 ; // mask: set only the dyn bit (0)
@@ -2270,7 +2235,7 @@ boolean SFE_UBLOX_GPS::setDynamicModel(dynModel newDynamicModel, uint16_t maxWai
22702235 packetCfg.len = 36 ;
22712236 packetCfg.startingSpot = 0 ;
22722237
2273- return (sendCommand (packetCfg, maxWait)); // Wait for ack
2238+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT ); // We are only expecting an ACK
22742239}
22752240
22762241// Given a spot in the payload array, extract four bytes and build a long
@@ -2492,8 +2457,7 @@ boolean SFE_UBLOX_GPS::getHPPOSLLH(uint16_t maxWait)
24922457 packetCfg.id = UBX_NAV_HPPOSLLH;
24932458 packetCfg.len = 0 ;
24942459
2495- return sendCommand (packetCfg, maxWait);
2496- return (false ); // If command send fails then bail
2460+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are only expecting data (no ACK)
24972461}
24982462
24992463// Get the current 3D high precision positional accuracy - a fun thing to watch
@@ -2505,7 +2469,7 @@ uint32_t SFE_UBLOX_GPS::getPositionAccuracy(uint16_t maxWait)
25052469 packetCfg.len = 0 ;
25062470 packetCfg.startingSpot = 0 ;
25072471
2508- if (sendCommand (packetCfg, maxWait) == false )
2472+ if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are only expecting data (no ACK )
25092473 return (0 ); // If command send fails then bail
25102474
25112475 uint32_t tempAccuracy = extractLong (24 ); // We got a response, now extract a long beginning at a given position
@@ -2665,7 +2629,7 @@ boolean SFE_UBLOX_GPS::getProtocolVersion(uint16_t maxWait)
26652629 packetCfg.len = 0 ;
26662630 packetCfg.startingSpot = 40 ; // Start at first "extended software information" string
26672631
2668- if (sendCommand (packetCfg, maxWait) == false )
2632+ if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are only expecting data (no ACK )
26692633 return (false ); // If command send fails then bail
26702634
26712635 // Payload should now contain ~220 characters (depends on module type)
@@ -2741,7 +2705,7 @@ boolean SFE_UBLOX_GPS::getRELPOSNED(uint16_t maxWait)
27412705 packetCfg.len = 0 ;
27422706 packetCfg.startingSpot = 0 ;
27432707
2744- if (sendCommand (packetCfg, maxWait) == false )
2708+ if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are only expecting data (no ACK )
27452709 return (false ); // If command send fails then bail
27462710
27472711 // We got a response, now parse the bits
0 commit comments