@@ -247,7 +247,7 @@ boolean SFE_UBLOX_GPS::setI2CAddress(uint8_t deviceAddress, uint16_t maxWait)
247
247
// payloadCfg is now loaded with current bytes. Change only the ones we need to
248
248
payloadCfg[4 ] = deviceAddress << 1 ; // DDC mode LSB
249
249
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
251
251
{
252
252
// Success! Now change our internal global.
253
253
_gpsI2Caddress = deviceAddress; // Store the I2C address from user
@@ -980,14 +980,7 @@ boolean SFE_UBLOX_GPS::isConnected()
980
980
packetCfg.len = 0 ;
981
981
packetCfg.startingSpot = 0 ;
982
982
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
991
984
}
992
985
return false ;
993
986
}
@@ -1269,10 +1262,7 @@ boolean SFE_UBLOX_GPS::saveConfiguration(uint16_t maxWait)
1269
1262
packetCfg.payload [4 ] = 0xFF ; // Set any bit in the saveMask field to save current config to Flash and BBR
1270
1263
packetCfg.payload [5 ] = 0xFF ;
1271
1264
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
1276
1266
}
1277
1267
1278
1268
// 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
1293
1283
packetCfg.payload [6 ] = (configMask >> 16 ) & 0xFF ;
1294
1284
packetCfg.payload [7 ] = (configMask >> 24 ) & 0xFF ;
1295
1285
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
1300
1287
}
1301
1288
1302
1289
// Reset module to factory defaults
@@ -1317,10 +1304,7 @@ boolean SFE_UBLOX_GPS::factoryDefault(uint16_t maxWait)
1317
1304
packetCfg.payload [8 ] = 0xFF ; // Set any bit in the loadMask field to discard current config and rebuild from lower non-volatile memory layers
1318
1305
packetCfg.payload [9 ] = 0xFF ;
1319
1306
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
1324
1308
}
1325
1309
1326
1310
// 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)
1383
1367
_debugSerial->print (F (" getVal8: sendCommand returned: " ));
1384
1368
_debugSerial->println (statusString (retVal));
1385
1369
}
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
1388
1372
1389
1373
// 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?)
1390
1374
// 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
1433
1417
payloadCfg[9 ] = value >> 8 * 1 ;
1434
1418
1435
1419
// 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
1441
1421
}
1442
1422
1443
1423
// 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
1468
1448
payloadCfg[8 ] = value; // Value
1469
1449
1470
1450
// 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
1476
1452
}
1477
1453
1478
1454
// 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
1506
1482
payloadCfg[11 ] = value >> 8 * 3 ;
1507
1483
1508
1484
// 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
1514
1486
}
1515
1487
1516
1488
// 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
1682
1654
addCfgValset32 (key, value);
1683
1655
1684
1656
// 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
1690
1658
}
1691
1659
1692
1660
// 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
1697
1665
addCfgValset16 (key, value);
1698
1666
1699
1667
// 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
1705
1669
}
1706
1670
1707
1671
// 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
1712
1676
addCfgValset8 (key, value);
1713
1677
1714
1678
// 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
1720
1680
}
1721
1681
1722
1682
// Get the current TimeMode3 settings - these contain survey in statuses
@@ -1727,7 +1687,7 @@ boolean SFE_UBLOX_GPS::getSurveyMode(uint16_t maxWait)
1727
1687
packetCfg.len = 0 ;
1728
1688
packetCfg.startingSpot = 0 ;
1729
1689
1730
- return (sendCommand (packetCfg, maxWait));
1690
+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are expecting data and an ACK
1731
1691
}
1732
1692
1733
1693
// Control Survey-In for NEO-M8P
@@ -1756,7 +1716,7 @@ boolean SFE_UBLOX_GPS::setSurveyMode(uint8_t mode, uint16_t observationTime, flo
1756
1716
payloadCfg[29 ] = svinAccLimit >> 8 ;
1757
1717
payloadCfg[30 ] = svinAccLimit >> 16 ;
1758
1718
1759
- return (sendCommand (packetCfg, maxWait)); // Wait for ack
1719
+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT) ; // We are only expecting an ACK
1760
1720
}
1761
1721
1762
1722
// Begin Survey-In for NEO-M8P
@@ -1787,7 +1747,7 @@ boolean SFE_UBLOX_GPS::getSurveyStatus(uint16_t maxWait)
1787
1747
packetCfg.len = 0 ;
1788
1748
packetCfg.startingSpot = 0 ;
1789
1749
1790
- if (sendCommand (packetCfg, maxWait) == false )
1750
+ if (( sendCommand (packetCfg, maxWait)) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
1791
1751
return (false ); // If command send fails then bail
1792
1752
1793
1753
// 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)
1812
1772
1813
1773
payloadCfg[0 ] = portID;
1814
1774
1815
- return (sendCommand (packetCfg, maxWait));
1775
+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are expecting data and an ACK
1816
1776
}
1817
1777
1818
1778
// 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,
1841
1801
// payloadCfg is now loaded with current bytes. Change only the ones we need to
1842
1802
payloadCfg[14 ] = outStreamSettings; // OutProtocolMask LSB - Set outStream bits
1843
1803
1844
- return (sendCommand (packetCfg, maxWait));
1804
+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
1845
1805
}
1846
1806
1847
1807
// 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
1862
1822
// payloadCfg is now loaded with current bytes. Change only the ones we need to
1863
1823
payloadCfg[12 ] = inStreamSettings; // InProtocolMask LSB - Set inStream bits
1864
1824
1865
- return (sendCommand (packetCfg, maxWait));
1825
+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
1866
1826
}
1867
1827
1868
1828
// 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)
1903
1863
packetCfg.len = 0 ;
1904
1864
packetCfg.startingSpot = 0 ;
1905
1865
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
1908
1869
1909
1870
uint16_t measurementRate = 1000 / navFreq;
1910
1871
1911
1872
// payloadCfg is now loaded with current bytes. Change only the ones we need to
1912
1873
payloadCfg[0 ] = measurementRate & 0xFF ; // measRate LSB
1913
1874
payloadCfg[1 ] = measurementRate >> 8 ; // measRate MSB
1914
1875
1915
- return (sendCommand (packetCfg, maxWait));
1876
+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
1916
1877
}
1917
1878
1918
1879
// Get the rate at which the module is outputting nav solutions
@@ -1924,8 +1885,9 @@ uint8_t SFE_UBLOX_GPS::getNavigationFrequency(uint16_t maxWait)
1924
1885
packetCfg.len = 0 ;
1925
1886
packetCfg.startingSpot = 0 ;
1926
1887
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
1929
1891
1930
1892
uint16_t measurementRate = 0 ;
1931
1893
@@ -1968,7 +1930,7 @@ boolean SFE_UBLOX_GPS::setAutoPVT(boolean enable, boolean implicitUpdate, uint16
1968
1930
payloadCfg[1 ] = UBX_NAV_PVT;
1969
1931
payloadCfg[2 ] = enable ? 1 : 0 ; // rate relative to navigation freq.
1970
1932
1971
- bool ok = sendCommand (packetCfg, maxWait);
1933
+ boolean ok = (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
1972
1934
if (ok)
1973
1935
{
1974
1936
autoPVT = enable;
@@ -1994,7 +1956,7 @@ boolean SFE_UBLOX_GPS::configureMessage(uint8_t msgClass, uint8_t msgID, uint8_t
1994
1956
packetCfg.payload [1 ] = msgID;
1995
1957
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.
1996
1958
1997
- return (sendCommand (packetCfg, maxWait));
1959
+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
1998
1960
}
1999
1961
2000
1962
// 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
2132
2094
payloadCfg[54 ] = currentGeofenceParams.rads [3 ] >> 16 ;
2133
2095
payloadCfg[55 ] = currentGeofenceParams.rads [3 ] >> 24 ;
2134
2096
}
2135
- return (sendCommand (packetCfg, maxWait)); // Wait for ack
2097
+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT) ; // We are only expecting an ACK
2136
2098
}
2137
2099
2138
2100
// Clear all geofences using UBX-CFG-GEOFENCE
@@ -2154,7 +2116,7 @@ boolean SFE_UBLOX_GPS::clearGeofences(uint16_t maxWait)
2154
2116
2155
2117
currentGeofenceParams.numFences = 0 ; // Zero the number of geofences currently in use
2156
2118
2157
- return (sendCommand (packetCfg, maxWait)); // Wait for ack
2119
+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT) ; // We are only expecting an ACK
2158
2120
}
2159
2121
2160
2122
// Clear the antenna control settings using UBX-CFG-ANT
@@ -2172,7 +2134,7 @@ boolean SFE_UBLOX_GPS::clearAntPIO(uint16_t maxWait)
2172
2134
payloadCfg[2 ] = 0xFF ; // Antenna pin configuration: set pinSwitch and pinSCD to 31
2173
2135
payloadCfg[3 ] = 0xFF ; // Antenna pin configuration: set pinOCD to 31, set reconfig bit
2174
2136
2175
- return (sendCommand (packetCfg, maxWait)); // Wait for ack
2137
+ return (( sendCommand (packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT) ; // We are only expecting an ACK
2176
2138
}
2177
2139
2178
2140
// Returns the combined geofence state using UBX-NAV-GEOFENCE
@@ -2183,7 +2145,8 @@ boolean SFE_UBLOX_GPS::getGeofenceState(geofenceState ¤tGeofenceState, uin
2183
2145
packetCfg.len = 0 ;
2184
2146
packetCfg.startingSpot = 0 ;
2185
2147
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
2187
2150
return (false );
2188
2151
2189
2152
currentGeofenceState.status = payloadCfg[5 ]; // Extract the status
@@ -2229,7 +2192,8 @@ boolean SFE_UBLOX_GPS::powerSaveMode(bool power_save, uint16_t maxWait)
2229
2192
packetCfg.len = 0 ;
2230
2193
packetCfg.startingSpot = 0 ;
2231
2194
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
2233
2197
return (false );
2234
2198
2235
2199
if (power_save)
@@ -2244,7 +2208,7 @@ boolean SFE_UBLOX_GPS::powerSaveMode(bool power_save, uint16_t maxWait)
2244
2208
packetCfg.len = 2 ;
2245
2209
packetCfg.startingSpot = 0 ;
2246
2210
2247
- return (sendCommand (packetCfg, maxWait)); // Wait for ack
2211
+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT ); // We are only expecting an ACK
2248
2212
}
2249
2213
2250
2214
// Change the dynamic platform model using UBX-CFG-NAV5
@@ -2260,7 +2224,8 @@ boolean SFE_UBLOX_GPS::setDynamicModel(dynModel newDynamicModel, uint16_t maxWai
2260
2224
packetCfg.len = 0 ;
2261
2225
packetCfg.startingSpot = 0 ;
2262
2226
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
2264
2229
return (false );
2265
2230
2266
2231
payloadCfg[0 ] = 0x01 ; // mask: set only the dyn bit (0)
@@ -2270,7 +2235,7 @@ boolean SFE_UBLOX_GPS::setDynamicModel(dynModel newDynamicModel, uint16_t maxWai
2270
2235
packetCfg.len = 36 ;
2271
2236
packetCfg.startingSpot = 0 ;
2272
2237
2273
- return (sendCommand (packetCfg, maxWait)); // Wait for ack
2238
+ return (sendCommand (packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT ); // We are only expecting an ACK
2274
2239
}
2275
2240
2276
2241
// 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)
2492
2457
packetCfg.id = UBX_NAV_HPPOSLLH;
2493
2458
packetCfg.len = 0 ;
2494
2459
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)
2497
2461
}
2498
2462
2499
2463
// 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)
2505
2469
packetCfg.len = 0 ;
2506
2470
packetCfg.startingSpot = 0 ;
2507
2471
2508
- if (sendCommand (packetCfg, maxWait) == false )
2472
+ if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are only expecting data (no ACK )
2509
2473
return (0 ); // If command send fails then bail
2510
2474
2511
2475
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)
2665
2629
packetCfg.len = 0 ;
2666
2630
packetCfg.startingSpot = 40 ; // Start at first "extended software information" string
2667
2631
2668
- if (sendCommand (packetCfg, maxWait) == false )
2632
+ if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are only expecting data (no ACK )
2669
2633
return (false ); // If command send fails then bail
2670
2634
2671
2635
// Payload should now contain ~220 characters (depends on module type)
@@ -2741,7 +2705,7 @@ boolean SFE_UBLOX_GPS::getRELPOSNED(uint16_t maxWait)
2741
2705
packetCfg.len = 0 ;
2742
2706
packetCfg.startingSpot = 0 ;
2743
2707
2744
- if (sendCommand (packetCfg, maxWait) == false )
2708
+ if (sendCommand (packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are only expecting data (no ACK )
2745
2709
return (false ); // If command send fails then bail
2746
2710
2747
2711
// We got a response, now parse the bits
0 commit comments