@@ -1430,45 +1430,6 @@ boolean SFE_UBLOX_GPS::getSurveyStatus(uint16_t maxWait)
1430
1430
return (true );
1431
1431
}
1432
1432
1433
- // Given a message number turns on a message ID for output over a given portID (UART, I2C, SPI, USB, etc)
1434
- // To disable a message, set secondsBetween messages to 0
1435
- // Note: This function will return false if the message is already enabled
1436
- // For base station RTK output we need to enable various sentences
1437
-
1438
- // NEO-M8P has four:
1439
- // 1005 = 0xF5 0x05 - Stationary RTK reference ARP
1440
- // 1077 = 0xF5 0x4D - GPS MSM7
1441
- // 1087 = 0xF5 0x57 - GLONASS MSM7
1442
- // 1230 = 0xF5 0xE6 - GLONASS code-phase biases, set to once every 10 seconds
1443
-
1444
- // ZED-F9P has six:
1445
- // 1005, 1074, 1084, 1094, 1124, 1230
1446
-
1447
- // Much of this configuration is not documented and instead discerned from u-center binary console
1448
- boolean SFE_UBLOX_GPS::enableRTCMmessage (uint8_t messageNumber, uint8_t portID, uint8_t secondsBetweenMessages, uint16_t maxWait)
1449
- {
1450
- packetCfg.cls = UBX_CLASS_CFG;
1451
- packetCfg.id = UBX_CFG_MSG;
1452
- packetCfg.len = 8 ;
1453
- packetCfg.startingSpot = 0 ;
1454
-
1455
- // Clear packet payload
1456
- for (uint8_t x = 0 ; x < packetCfg.len ; x++)
1457
- packetCfg.payload [x] = 0 ;
1458
-
1459
- packetCfg.payload [0 ] = UBX_RTCM_MSB; // MSB, always 0xF5. Interesting, these are not little endian
1460
- packetCfg.payload [1 ] = messageNumber; // LSB
1461
- packetCfg.payload [2 + portID] = secondsBetweenMessages; // Byte 2 is I2C, byte 3 is UART1, etc.
1462
-
1463
- return (sendCommand (packetCfg, maxWait));
1464
- }
1465
-
1466
- // Disable a given message on a given port by setting secondsBetweenMessages to zero
1467
- boolean SFE_UBLOX_GPS::disableRTCMmessage (uint8_t messageNumber, uint8_t portID, uint16_t maxWait)
1468
- {
1469
- return (enableRTCMmessage (messageNumber, portID, 0 , maxWait));
1470
- }
1471
-
1472
1433
// Loads the payloadCfg array with the current protocol bits located the UBX-CFG-PRT register for a given port
1473
1434
boolean SFE_UBLOX_GPS::getPortSettings (uint8_t portID, uint16_t maxWait)
1474
1435
{
@@ -1639,24 +1600,76 @@ boolean SFE_UBLOX_GPS::setAutoPVT(boolean enable, boolean implicitUpdate, uint16
1639
1600
return ok;
1640
1601
}
1641
1602
1642
- boolean SFE_UBLOX_GPS::setCFG_MSG (uint8_t msgClass, uint8_t messageID, uint8_t rate, uint16_t maxWait)
1603
+ // Configure a given message type for a given port (UART1, I2C, SPI, etc)
1604
+ boolean SFE_UBLOX_GPS::configureMessage (uint8_t msgClass, uint8_t msgID, uint8_t portID, uint8_t sendRate, uint16_t maxWait)
1643
1605
{
1644
1606
packetCfg.cls = UBX_CLASS_CFG;
1645
1607
packetCfg.id = UBX_CFG_MSG;
1646
- packetCfg.len = 3 ;
1608
+ packetCfg.len = 8 ;
1647
1609
packetCfg.startingSpot = 0 ;
1648
- payloadCfg[0 ] = msgClass;
1649
- payloadCfg[1 ] = messageID;
1650
- payloadCfg[2 ] = rate;
1651
1610
1652
- bool ok = sendCommand (packetCfg, maxWait);
1653
- return ok;
1611
+ // Clear packet payload
1612
+ for (uint8_t x = 0 ; x < packetCfg.len ; x++)
1613
+ packetCfg.payload [x] = 0 ;
1614
+
1615
+ packetCfg.payload [0 ] = msgClass;
1616
+ packetCfg.payload [1 ] = msgID;
1617
+ 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.
1618
+
1619
+ return (sendCommand (packetCfg, maxWait));
1620
+ }
1621
+
1622
+ // Enable a given message type, default of 1 per update rate (usually 1 per second)
1623
+ boolean SFE_UBLOX_GPS::enableMessage (uint8_t msgClass, uint8_t msgID, uint8_t portID, uint8_t rate, uint16_t maxWait)
1624
+ {
1625
+ return (configureMessage (msgClass, msgID, portID, rate, maxWait));
1626
+ }
1627
+ // Disable a given message type on a given port
1628
+ boolean SFE_UBLOX_GPS::disableMessage (uint8_t msgClass, uint8_t msgID, uint8_t portID, uint16_t maxWait)
1629
+ {
1630
+ return (configureMessage (msgClass, msgID, portID, 0 , maxWait));
1631
+ }
1632
+
1633
+ boolean SFE_UBLOX_GPS::enableNMEAMessage (uint8_t msgID, uint8_t portID, uint8_t rate, uint16_t maxWait)
1634
+ {
1635
+ return (configureMessage (UBX_CLASS_NMEA, msgID, portID, rate, maxWait));
1636
+ }
1637
+ boolean SFE_UBLOX_GPS::disableNMEAMessage (uint8_t msgID, uint8_t portID, uint16_t maxWait)
1638
+ {
1639
+ return (enableNMEAMessage (msgID, portID, 0 , maxWait));
1640
+ }
1641
+
1642
+ // Given a message number turns on a message ID for output over a given portID (UART, I2C, SPI, USB, etc)
1643
+ // To disable a message, set secondsBetween messages to 0
1644
+ // Note: This function will return false if the message is already enabled
1645
+ // For base station RTK output we need to enable various sentences
1646
+
1647
+ // NEO-M8P has four:
1648
+ // 1005 = 0xF5 0x05 - Stationary RTK reference ARP
1649
+ // 1077 = 0xF5 0x4D - GPS MSM7
1650
+ // 1087 = 0xF5 0x57 - GLONASS MSM7
1651
+ // 1230 = 0xF5 0xE6 - GLONASS code-phase biases, set to once every 10 seconds
1652
+
1653
+ // ZED-F9P has six:
1654
+ // 1005, 1074, 1084, 1094, 1124, 1230
1655
+
1656
+ // Much of this configuration is not documented and instead discerned from u-center binary console
1657
+ boolean SFE_UBLOX_GPS::enableRTCMmessage (uint8_t messageNumber, uint8_t portID, uint8_t sendRate, uint16_t maxWait)
1658
+ {
1659
+ return (configureMessage (UBX_RTCM_MSB, messageNumber, portID, sendRate, maxWait));
1660
+ }
1661
+
1662
+ // Disable a given message on a given port by setting secondsBetweenMessages to zero
1663
+ boolean SFE_UBLOX_GPS::disableRTCMmessage (uint8_t messageNumber, uint8_t portID, uint16_t maxWait)
1664
+ {
1665
+ return (enableRTCMmessage (messageNumber, portID, 0 , maxWait));
1654
1666
}
1655
1667
1656
1668
// Add a new geofence using UBX-CFG-GEOFENCE
1657
1669
boolean SFE_UBLOX_GPS::addGeofence (int32_t latitude, int32_t longitude, uint32_t radius, byte confidence, byte pinPolarity, byte pin, uint16_t maxWait)
1658
1670
{
1659
- if (currentGeofenceParams.numFences >= 4 ) return (false ); // Quit if we already have four geofences defined
1671
+ if (currentGeofenceParams.numFences >= 4 )
1672
+ return (false ); // Quit if we already have four geofences defined
1660
1673
1661
1674
// Store the new geofence parameters
1662
1675
currentGeofenceParams.lats [currentGeofenceParams.numFences ] = latitude;
@@ -1669,10 +1682,10 @@ boolean SFE_UBLOX_GPS::addGeofence(int32_t latitude, int32_t longitude, uint32_t
1669
1682
packetCfg.len = (currentGeofenceParams.numFences * 12 ) + 8 ;
1670
1683
packetCfg.startingSpot = 0 ;
1671
1684
1672
- payloadCfg[0 ] = 0 ; // Message version = 0x00
1685
+ payloadCfg[0 ] = 0 ; // Message version = 0x00
1673
1686
payloadCfg[1 ] = currentGeofenceParams.numFences ; // numFences
1674
- payloadCfg[2 ] = confidence; // confLvl = Confidence level 0-4 (none, 68%, 95%, 99.7%, 99.99%)
1675
- payloadCfg[3 ] = 0 ; // reserved1
1687
+ payloadCfg[2 ] = confidence; // confLvl = Confidence level 0-4 (none, 68%, 95%, 99.7%, 99.99%)
1688
+ payloadCfg[3 ] = 0 ; // reserved1
1676
1689
if (pin > 0 )
1677
1690
{
1678
1691
payloadCfg[4 ] = 1 ; // enable PIO combined fence state
@@ -1682,8 +1695,8 @@ boolean SFE_UBLOX_GPS::addGeofence(int32_t latitude, int32_t longitude, uint32_t
1682
1695
payloadCfg[4 ] = 0 ; // disable PIO combined fence state
1683
1696
}
1684
1697
payloadCfg[5 ] = pinPolarity; // PIO pin polarity (0 = low means inside, 1 = low means outside (or unknown))
1685
- payloadCfg[6 ] = pin; // PIO pin
1686
- payloadCfg[7 ] = 0 ; // reserved2
1698
+ payloadCfg[6 ] = pin; // PIO pin
1699
+ payloadCfg[7 ] = 0 ; // reserved2
1687
1700
payloadCfg[8 ] = currentGeofenceParams.lats [0 ] & 0xFF ;
1688
1701
payloadCfg[9 ] = currentGeofenceParams.lats [0 ] >> 8 ;
1689
1702
payloadCfg[10 ] = currentGeofenceParams.lats [0 ] >> 16 ;
@@ -1696,7 +1709,8 @@ boolean SFE_UBLOX_GPS::addGeofence(int32_t latitude, int32_t longitude, uint32_t
1696
1709
payloadCfg[17 ] = currentGeofenceParams.rads [0 ] >> 8 ;
1697
1710
payloadCfg[18 ] = currentGeofenceParams.rads [0 ] >> 16 ;
1698
1711
payloadCfg[19 ] = currentGeofenceParams.rads [0 ] >> 24 ;
1699
- if (currentGeofenceParams.numFences >= 2 ) {
1712
+ if (currentGeofenceParams.numFences >= 2 )
1713
+ {
1700
1714
payloadCfg[20 ] = currentGeofenceParams.lats [1 ] & 0xFF ;
1701
1715
payloadCfg[21 ] = currentGeofenceParams.lats [1 ] >> 8 ;
1702
1716
payloadCfg[22 ] = currentGeofenceParams.lats [1 ] >> 16 ;
@@ -1710,7 +1724,8 @@ boolean SFE_UBLOX_GPS::addGeofence(int32_t latitude, int32_t longitude, uint32_t
1710
1724
payloadCfg[30 ] = currentGeofenceParams.rads [1 ] >> 16 ;
1711
1725
payloadCfg[31 ] = currentGeofenceParams.rads [1 ] >> 24 ;
1712
1726
}
1713
- if (currentGeofenceParams.numFences >= 3 ) {
1727
+ if (currentGeofenceParams.numFences >= 3 )
1728
+ {
1714
1729
payloadCfg[32 ] = currentGeofenceParams.lats [2 ] & 0xFF ;
1715
1730
payloadCfg[33 ] = currentGeofenceParams.lats [2 ] >> 8 ;
1716
1731
payloadCfg[34 ] = currentGeofenceParams.lats [2 ] >> 16 ;
@@ -1724,7 +1739,8 @@ boolean SFE_UBLOX_GPS::addGeofence(int32_t latitude, int32_t longitude, uint32_t
1724
1739
payloadCfg[42 ] = currentGeofenceParams.rads [2 ] >> 16 ;
1725
1740
payloadCfg[43 ] = currentGeofenceParams.rads [2 ] >> 24 ;
1726
1741
}
1727
- if (currentGeofenceParams.numFences >= 4 ) {
1742
+ if (currentGeofenceParams.numFences >= 4 )
1743
+ {
1728
1744
payloadCfg[44 ] = currentGeofenceParams.lats [3 ] & 0xFF ;
1729
1745
payloadCfg[45 ] = currentGeofenceParams.lats [3 ] >> 8 ;
1730
1746
payloadCfg[46 ] = currentGeofenceParams.lats [3 ] >> 16 ;
@@ -1790,17 +1806,21 @@ boolean SFE_UBLOX_GPS::getGeofenceState(geofenceState ¤tGeofenceState, uin
1790
1806
packetCfg.startingSpot = 0 ;
1791
1807
1792
1808
if (sendCommand (packetCfg, maxWait) == false ) // Ask module for the geofence status. Loads into payloadCfg.
1793
- return (false );
1809
+ return (false );
1794
1810
1795
- currentGeofenceState.status = payloadCfg[5 ]; // Extract the status
1811
+ currentGeofenceState.status = payloadCfg[5 ]; // Extract the status
1796
1812
currentGeofenceState.numFences = payloadCfg[6 ]; // Extract the number of geofences
1797
1813
currentGeofenceState.combState = payloadCfg[7 ]; // Extract the combined state of all geofences
1798
- if (currentGeofenceState.numFences > 0 ) currentGeofenceState.states [0 ] = payloadCfg[8 ]; // Extract geofence 1 state
1799
- if (currentGeofenceState.numFences > 1 ) currentGeofenceState.states [1 ] = payloadCfg[10 ]; // Extract geofence 2 state
1800
- if (currentGeofenceState.numFences > 2 ) currentGeofenceState.states [2 ] = payloadCfg[12 ]; // Extract geofence 3 state
1801
- if (currentGeofenceState.numFences > 3 ) currentGeofenceState.states [3 ] = payloadCfg[14 ]; // Extract geofence 4 state
1814
+ if (currentGeofenceState.numFences > 0 )
1815
+ currentGeofenceState.states [0 ] = payloadCfg[8 ]; // Extract geofence 1 state
1816
+ if (currentGeofenceState.numFences > 1 )
1817
+ currentGeofenceState.states [1 ] = payloadCfg[10 ]; // Extract geofence 2 state
1818
+ if (currentGeofenceState.numFences > 2 )
1819
+ currentGeofenceState.states [2 ] = payloadCfg[12 ]; // Extract geofence 3 state
1820
+ if (currentGeofenceState.numFences > 3 )
1821
+ currentGeofenceState.states [3 ] = payloadCfg[14 ]; // Extract geofence 4 state
1802
1822
1803
- return (true );
1823
+ return (true );
1804
1824
}
1805
1825
1806
1826
// Power Save Mode
@@ -1843,7 +1863,7 @@ boolean SFE_UBLOX_GPS::powerSaveMode(bool power_save, uint16_t maxWait)
1843
1863
{
1844
1864
payloadCfg[1 ] = 0 ; // Continuous Mode
1845
1865
}
1846
-
1866
+
1847
1867
packetCfg.len = 2 ;
1848
1868
packetCfg.startingSpot = 0 ;
1849
1869
@@ -1984,7 +2004,6 @@ uint32_t SFE_UBLOX_GPS::getTimeOfWeek(uint16_t maxWait /* = 250*/)
1984
2004
return (timeOfWeek);
1985
2005
}
1986
2006
1987
-
1988
2007
int32_t SFE_UBLOX_GPS::getHighResLatitude (uint16_t maxWait /* = 250*/ )
1989
2008
{
1990
2009
if (highResModuleQueried.highResLatitude == false )
@@ -2227,9 +2246,9 @@ boolean SFE_UBLOX_GPS::getProtocolVersion(uint16_t maxWait)
2227
2246
if (sendCommand (packetCfg, maxWait) == false )
2228
2247
return (false ); // If command send fails then bail
2229
2248
2230
- // Let's make sure we wait for the ACK too (sendCommand will have returned as soon as the module sent its response)
2231
- // This is only required because we are doing multiple sendCommands in quick succession using the same class and ID
2232
- waitForResponse (UBX_CLASS_MON, UBX_MON_VER, 100 ); // But we'll only wait for 100msec max
2249
+ // Let's make sure we wait for the ACK too (sendCommand will have returned as soon as the module sent its response)
2250
+ // This is only required because we are doing multiple sendCommands in quick succession using the same class and ID
2251
+ waitForResponse (UBX_CLASS_MON, UBX_MON_VER, 100 ); // But we'll only wait for 100msec max
2233
2252
2234
2253
if (_printDebug == true )
2235
2254
{
@@ -2250,7 +2269,7 @@ boolean SFE_UBLOX_GPS::getProtocolVersion(uint16_t maxWait)
2250
2269
{
2251
2270
versionHigh = (payloadCfg[8 ] - ' 0' ) * 10 + (payloadCfg[9 ] - ' 0' ); // Convert '18' to 18
2252
2271
versionLow = (payloadCfg[11 ] - ' 0' ) * 10 + (payloadCfg[12 ] - ' 0' ); // Convert '00' to 00
2253
- return (true ); // This function returns a boolean (so we can't return versionLow)
2272
+ return (true ); // This function returns a boolean (so we can't return versionLow)
2254
2273
}
2255
2274
}
2256
2275
0 commit comments