@@ -1430,45 +1430,6 @@ boolean SFE_UBLOX_GPS::getSurveyStatus(uint16_t maxWait)
14301430 return (true );
14311431}
14321432
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-
14721433// Loads the payloadCfg array with the current protocol bits located the UBX-CFG-PRT register for a given port
14731434boolean SFE_UBLOX_GPS::getPortSettings (uint8_t portID, uint16_t maxWait)
14741435{
@@ -1639,24 +1600,76 @@ boolean SFE_UBLOX_GPS::setAutoPVT(boolean enable, boolean implicitUpdate, uint16
16391600 return ok;
16401601}
16411602
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)
16431605{
16441606 packetCfg.cls = UBX_CLASS_CFG;
16451607 packetCfg.id = UBX_CFG_MSG;
1646- packetCfg.len = 3 ;
1608+ packetCfg.len = 8 ;
16471609 packetCfg.startingSpot = 0 ;
1648- payloadCfg[0 ] = msgClass;
1649- payloadCfg[1 ] = messageID;
1650- payloadCfg[2 ] = rate;
16511610
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));
16541666}
16551667
16561668// Add a new geofence using UBX-CFG-GEOFENCE
16571669boolean SFE_UBLOX_GPS::addGeofence (int32_t latitude, int32_t longitude, uint32_t radius, byte confidence, byte pinPolarity, byte pin, uint16_t maxWait)
16581670{
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
16601673
16611674 // Store the new geofence parameters
16621675 currentGeofenceParams.lats [currentGeofenceParams.numFences ] = latitude;
@@ -1669,10 +1682,10 @@ boolean SFE_UBLOX_GPS::addGeofence(int32_t latitude, int32_t longitude, uint32_t
16691682 packetCfg.len = (currentGeofenceParams.numFences * 12 ) + 8 ;
16701683 packetCfg.startingSpot = 0 ;
16711684
1672- payloadCfg[0 ] = 0 ; // Message version = 0x00
1685+ payloadCfg[0 ] = 0 ; // Message version = 0x00
16731686 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
16761689 if (pin > 0 )
16771690 {
16781691 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
16821695 payloadCfg[4 ] = 0 ; // disable PIO combined fence state
16831696 }
16841697 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
16871700 payloadCfg[8 ] = currentGeofenceParams.lats [0 ] & 0xFF ;
16881701 payloadCfg[9 ] = currentGeofenceParams.lats [0 ] >> 8 ;
16891702 payloadCfg[10 ] = currentGeofenceParams.lats [0 ] >> 16 ;
@@ -1696,7 +1709,8 @@ boolean SFE_UBLOX_GPS::addGeofence(int32_t latitude, int32_t longitude, uint32_t
16961709 payloadCfg[17 ] = currentGeofenceParams.rads [0 ] >> 8 ;
16971710 payloadCfg[18 ] = currentGeofenceParams.rads [0 ] >> 16 ;
16981711 payloadCfg[19 ] = currentGeofenceParams.rads [0 ] >> 24 ;
1699- if (currentGeofenceParams.numFences >= 2 ) {
1712+ if (currentGeofenceParams.numFences >= 2 )
1713+ {
17001714 payloadCfg[20 ] = currentGeofenceParams.lats [1 ] & 0xFF ;
17011715 payloadCfg[21 ] = currentGeofenceParams.lats [1 ] >> 8 ;
17021716 payloadCfg[22 ] = currentGeofenceParams.lats [1 ] >> 16 ;
@@ -1710,7 +1724,8 @@ boolean SFE_UBLOX_GPS::addGeofence(int32_t latitude, int32_t longitude, uint32_t
17101724 payloadCfg[30 ] = currentGeofenceParams.rads [1 ] >> 16 ;
17111725 payloadCfg[31 ] = currentGeofenceParams.rads [1 ] >> 24 ;
17121726 }
1713- if (currentGeofenceParams.numFences >= 3 ) {
1727+ if (currentGeofenceParams.numFences >= 3 )
1728+ {
17141729 payloadCfg[32 ] = currentGeofenceParams.lats [2 ] & 0xFF ;
17151730 payloadCfg[33 ] = currentGeofenceParams.lats [2 ] >> 8 ;
17161731 payloadCfg[34 ] = currentGeofenceParams.lats [2 ] >> 16 ;
@@ -1724,7 +1739,8 @@ boolean SFE_UBLOX_GPS::addGeofence(int32_t latitude, int32_t longitude, uint32_t
17241739 payloadCfg[42 ] = currentGeofenceParams.rads [2 ] >> 16 ;
17251740 payloadCfg[43 ] = currentGeofenceParams.rads [2 ] >> 24 ;
17261741 }
1727- if (currentGeofenceParams.numFences >= 4 ) {
1742+ if (currentGeofenceParams.numFences >= 4 )
1743+ {
17281744 payloadCfg[44 ] = currentGeofenceParams.lats [3 ] & 0xFF ;
17291745 payloadCfg[45 ] = currentGeofenceParams.lats [3 ] >> 8 ;
17301746 payloadCfg[46 ] = currentGeofenceParams.lats [3 ] >> 16 ;
@@ -1790,17 +1806,21 @@ boolean SFE_UBLOX_GPS::getGeofenceState(geofenceState ¤tGeofenceState, uin
17901806 packetCfg.startingSpot = 0 ;
17911807
17921808 if (sendCommand (packetCfg, maxWait) == false ) // Ask module for the geofence status. Loads into payloadCfg.
1793- return (false );
1809+ return (false );
17941810
1795- currentGeofenceState.status = payloadCfg[5 ]; // Extract the status
1811+ currentGeofenceState.status = payloadCfg[5 ]; // Extract the status
17961812 currentGeofenceState.numFences = payloadCfg[6 ]; // Extract the number of geofences
17971813 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
18021822
1803- return (true );
1823+ return (true );
18041824}
18051825
18061826// Power Save Mode
@@ -1843,7 +1863,7 @@ boolean SFE_UBLOX_GPS::powerSaveMode(bool power_save, uint16_t maxWait)
18431863 {
18441864 payloadCfg[1 ] = 0 ; // Continuous Mode
18451865 }
1846-
1866+
18471867 packetCfg.len = 2 ;
18481868 packetCfg.startingSpot = 0 ;
18491869
@@ -1984,7 +2004,6 @@ uint32_t SFE_UBLOX_GPS::getTimeOfWeek(uint16_t maxWait /* = 250*/)
19842004 return (timeOfWeek);
19852005}
19862006
1987-
19882007int32_t SFE_UBLOX_GPS::getHighResLatitude (uint16_t maxWait /* = 250*/ )
19892008{
19902009 if (highResModuleQueried.highResLatitude == false )
@@ -2227,9 +2246,9 @@ boolean SFE_UBLOX_GPS::getProtocolVersion(uint16_t maxWait)
22272246 if (sendCommand (packetCfg, maxWait) == false )
22282247 return (false ); // If command send fails then bail
22292248
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
22332252
22342253 if (_printDebug == true )
22352254 {
@@ -2250,7 +2269,7 @@ boolean SFE_UBLOX_GPS::getProtocolVersion(uint16_t maxWait)
22502269 {
22512270 versionHigh = (payloadCfg[8 ] - ' 0' ) * 10 + (payloadCfg[9 ] - ' 0' ); // Convert '18' to 18
22522271 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)
22542273 }
22552274 }
22562275
0 commit comments