Add setMainTalkerID and setHighPrecisionMode

This commit is contained in:
PaulZC
2022-01-13 10:38:20 +00:00
parent 34b982841a
commit a1814e32ab
5 changed files with 115 additions and 34 deletions
@@ -1707,7 +1707,9 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
{
uint8_t *lengthPtr = getNMEAWorkingLengthPtr(); // Get a pointer to the working copy length
uint8_t *nmeaPtr = getNMEAWorkingNMEAPtr(); // Get a pointer to the working copy NMEA data
uint8_t nmeaMaxLength = getNMEAMaxLength();
*lengthPtr = 6; // Set the working copy length
memset(nmeaPtr, 0, nmeaMaxLength); // Clear the working copy
memcpy(nmeaPtr, &nmeaAddressField[0], 6); // Copy the start character and address field into the working copy
}
@@ -12020,6 +12022,54 @@ void SFE_UBLOX_GNSS::logHNRPVT(bool enabled)
// ***** Helper Functions for NMEA Logging / Processing
// Set the mainTalkerId used by NMEA messages - allows all NMEA messages except GSV to be prefixed with GP instead of GN
bool SFE_UBLOX_GNSS::setMainTalkerID(sfe_ublox_talker_ids_e id, uint16_t maxWait)
{
//Get the current extended NMEA protocol configuration (V1)
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_NMEA;
packetCfg.len = 0;
packetCfg.startingSpot = 0;
//Ask module for the current settings. Loads into payloadCfg.
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
return (false);
payloadCfg[9] = (uint8_t)id;
packetCfg.len = 20;
packetCfg.startingSpot = 0;
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
}
// Enable/Disable NMEA High Precision Mode - include extra decimal places in the Lat and Lon
bool SFE_UBLOX_GNSS::setHighPrecisionMode(bool enable, uint16_t maxWait)
{
//Get the current extended NMEA protocol configuration (V1)
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_NMEA;
packetCfg.len = 0;
packetCfg.startingSpot = 0;
//Ask module for the current settings. Loads into payloadCfg.
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
return (false);
if (enable)
{
payloadCfg[3] |= (1 << 3); // Set the highPrec flag
payloadCfg[3] &= ~((1 << 0) | (1 << 2)); // Clear the compat and limit82 flags
}
else
payloadCfg[3] &= ~(1 << 3); // Clear the highPrec flag
packetCfg.len = 20;
packetCfg.startingSpot = 0;
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
}
// Log selected NMEA messages to file buffer - if the messages are enabled and if the file buffer exists
// User needs to call setFileBufferSize before .begin
void SFE_UBLOX_GNSS::setNMEALoggingMask(uint32_t messages)
+26 -9
View File
@@ -522,6 +522,18 @@ enum sfe_ublox_mga_ack_infocode_e
SFE_UBLOX_MGA_ACK_INFOCODE_TYPE_UNKNOWN
};
// The mainTalkerId, set by UBX-CFG-NMEA setMainTalkerID
enum sfe_ublox_talker_ids_e
{
SFE_UBLOX_MAIN_TALKER_ID_DEFAULT,
SFE_UBLOX_MAIN_TALKER_ID_GP,
SFE_UBLOX_MAIN_TALKER_ID_GL,
SFE_UBLOX_MAIN_TALKER_ID_GN,
SFE_UBLOX_MAIN_TALKER_ID_GA,
SFE_UBLOX_MAIN_TALKER_ID_GB,
SFE_UBLOX_MAIN_TALKER_ID_GQ
};
//-=-=-=-=-
#ifndef MAX_PAYLOAD_SIZE
@@ -1167,14 +1179,6 @@ public:
void flushHNRPVT(); //Mark all the data as read/stale
void logHNRPVT(bool enabled = true); // Log data to file buffer
// Helper functions for NMEA logging
void setNMEALoggingMask(uint32_t messages = SFE_UBLOX_FILTER_NMEA_ALL); // Add selected NMEA messages to file buffer - if enabled. Default to adding ALL messages to the file buffer
uint32_t getNMEALoggingMask(); // Return which NMEA messages are selected for logging to the file buffer - if enabled
// Helper functions to control which NMEA messages are passed to processNMEA
void setProcessNMEAMask(uint32_t messages = SFE_UBLOX_FILTER_NMEA_ALL); // Control which NMEA messages are passed to processNMEA. Default to passing ALL messages
uint32_t getProcessNMEAMask(); // Return which NMEA messages are passed to processNMEA
// Helper functions for CFG RATE
bool setNavigationFrequency(uint8_t navFreq, uint16_t maxWait = defaultMaxWait); //Set the number of nav solutions sent per second
@@ -1323,8 +1327,21 @@ public:
float getHNRpitch(uint16_t maxWait = defaultMaxWait); // Returned as degrees
float getHNRheading(uint16_t maxWait = defaultMaxWait); // Returned as degrees
// Set the mainTalkerId used by NMEA messages - allows all NMEA messages except GSV to be prefixed with GP instead of GN
bool setMainTalkerID(sfe_ublox_talker_ids_e id = SFE_UBLOX_MAIN_TALKER_ID_DEFAULT, uint16_t maxWait = defaultMaxWait);
// Enable/Disable NMEA High Precision Mode - include extra decimal places in the Lat and Lon
bool setHighPrecisionMode(bool enable = true, uint16_t maxWait = defaultMaxWait);
// Helper functions for NMEA logging
void setNMEALoggingMask(uint32_t messages = SFE_UBLOX_FILTER_NMEA_ALL); // Add selected NMEA messages to file buffer - if enabled. Default to adding ALL messages to the file buffer
uint32_t getNMEALoggingMask(); // Return which NMEA messages are selected for logging to the file buffer - if enabled
// Helper functions to control which NMEA messages are passed to processNMEA
void setProcessNMEAMask(uint32_t messages = SFE_UBLOX_FILTER_NMEA_ALL); // Control which NMEA messages are passed to processNMEA. Default to passing ALL messages
uint32_t getProcessNMEAMask(); // Return which NMEA messages are passed to processNMEA
// Support for "auto" storage of NMEA messages
uint8_t getLatestNMEAGPGGA(NMEA_GGA_data_t *data); // Return the most recent GPGGA: 0 = no data, 1 = stale data, 2 = fresh data
bool setNMEAGPGGAcallback(void (*callbackPointer)(NMEA_GGA_data_t)); //Enable a callback on the arrival of a GPGGA message
uint8_t getLatestNMEAGNGGA(NMEA_GGA_data_t *data); // Return the most recent GNGGA: 0 = no data, 1 = stale data, 2 = fresh data
+3 -3
View File
@@ -2250,11 +2250,11 @@ struct nmeaAutomaticFlags
};
// The max length for NMEA messages should be 82 bytes, but GGA messages can exceed that if they include the
// extra decimal places for "High Precision".
// extra decimal places for "High Precision Mode".
//
// To be safe, let's allocate 90 bytes to store the GGA message
// To be safe, let's allocate 100 bytes to store the GGA message
const uint8_t NMEA_GGA_MAX_LENGTH = 90;
const uint8_t NMEA_GGA_MAX_LENGTH = 100;
typedef struct
{