diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 8a982f2..6acf8d2 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -1284,7 +1284,7 @@ bool SFE_UBLOX_GNSS::checkUbloxSpi(ubxPacket *incomingUBX, uint8_t requestedClas // If we are not receiving a sentence (currentSentence == NONE) and the byteReturned is 0xFF, // i.e. the module has no data for us, then delay for - if ((byteReturned == 0xFF) && (currentSentence == NONE)) + if ((byteReturned == 0xFF) && (currentSentence == SFE_UBLOX_SENTENCE_TYPE_NONE)) { digitalWrite(_csPin, HIGH); _spiPort->endTransaction(); @@ -1292,7 +1292,7 @@ bool SFE_UBLOX_GNSS::checkUbloxSpi(ubxPacket *incomingUBX, uint8_t requestedClas return (true); } - while ((byteReturned != 0xFF) || (currentSentence != NONE)) + while ((byteReturned != 0xFF) || (currentSentence != SFE_UBLOX_SENTENCE_TYPE_NONE)) { process(byteReturned, incomingUBX, requestedClass, requestedID); byteReturned = _spiPort->transfer(0xFF); @@ -1686,14 +1686,14 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r { if (_outputPort != NULL) _outputPort->write(incoming); // Echo this byte to the serial port - if ((currentSentence == NONE) || (currentSentence == NMEA)) + if ((currentSentence == SFE_UBLOX_SENTENCE_TYPE_NONE) || (currentSentence == SFE_UBLOX_SENTENCE_TYPE_NMEA)) { if (incoming == UBX_SYNCH_1) // UBX binary frames start with 0xB5, aka μ { // This is the start of a binary sentence. Reset flags. // We still don't know the response class ubxFrameCounter = 0; - currentSentence = UBX; + currentSentence = SFE_UBLOX_SENTENCE_TYPE_UBX; // Reset the packetBuf.counter even though we will need to reset it again when ubxFrameCounter == 2 packetBuf.counter = 0; ignoreThisPayload = false; // We should not ignore this payload - yet @@ -1703,12 +1703,12 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r else if (incoming == '$') { nmeaByteCounter = 0; // Reset the NMEA byte counter - currentSentence = NMEA; + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NMEA; } else if (incoming == 0xD3) // RTCM frames start with 0xD3 { rtcmFrameCounter = 0; - currentSentence = RTCM; + currentSentence = SFE_UBLOX_SENTENCE_TYPE_RTCM; } else { @@ -1717,13 +1717,13 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r } // Depending on the sentence, pass the character to the individual processor - if (currentSentence == UBX) + if (currentSentence == SFE_UBLOX_SENTENCE_TYPE_UBX) { // Decide what type of response this is if ((ubxFrameCounter == 0) && (incoming != UBX_SYNCH_1)) // ISO 'μ' - currentSentence = NONE; // Something went wrong. Reset. + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. else if ((ubxFrameCounter == 1) && (incoming != UBX_SYNCH_2)) // ASCII 'b' - currentSentence = NONE; // Something went wrong. Reset. + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. // Note to future self: // There may be some duplication / redundancy in the next few lines as processUBX will also // load information into packetBuf, but we'll do it here too for clarity @@ -1936,15 +1936,15 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r // Finally, increment the frame counter ubxFrameCounter++; } - else if (currentSentence == NMEA) // Process incoming NMEA mesages. Selectively log if desired. + else if (currentSentence == SFE_UBLOX_SENTENCE_TYPE_NMEA) // Process incoming NMEA mesages. Selectively log if desired. { if ((nmeaByteCounter == 0) && (incoming != '$')) { - currentSentence = NONE; // Something went wrong. Reset. (Almost certainly redundant!) + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. (Almost certainly redundant!) } else if ((nmeaByteCounter == 1) && (incoming != 'G')) { - currentSentence = NONE; // Something went wrong. Reset. + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. } else if ((nmeaByteCounter >= 0) && (nmeaByteCounter <= 5)) { @@ -2029,7 +2029,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r nmeaByteCounter++; // Increment the byte counter if (nmeaByteCounter == maxNMEAByteCount) // Check if we have processed too many bytes - currentSentence = NONE; // Something went wrong. Reset. + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. if (nmeaByteCounter == 0) // Check if we are done { @@ -2109,10 +2109,10 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r } } #endif - currentSentence = NONE; // All done! + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // All done! } } - else if (currentSentence == RTCM) + else if (currentSentence == SFE_UBLOX_SENTENCE_TYPE_RTCM) { currentSentence = processRTCMframe(incoming, &rtcmFrameCounter); // Deal with RTCM bytes } @@ -2876,7 +2876,7 @@ nmeaAutomaticFlags *SFE_UBLOX_GNSS::getNMEAFlagsPtr() // Byte 2: 10-bits of length of this packet including the first two-ish header bytes, + 6. // byte 3 + 4 bits: Msg type 12 bits // Example: D3 00 7C 43 F0 ... / 0x7C = 124+6 = 130 bytes in this packet, 0x43F = Msg type 1087 -SFE_UBLOX_GNSS::SentenceTypes SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) +SFE_UBLOX_GNSS::sfe_ublox_sentence_types_e SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) { static uint16_t rtcmLen = 0; @@ -2898,12 +2898,12 @@ SFE_UBLOX_GNSS::SentenceTypes SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, rtcmMsgType |= (incoming >> 4); //Message Type, bits 0-7 }*/ - *rtcmFrameCounter++; + *rtcmFrameCounter = *rtcmFrameCounter + 1; processRTCM(incoming); // Here is where we expose this byte to the user // Reset and start looking for next sentence type when done - return (*rtcmFrameCounter == rtcmLen) ? NONE : RTCM; + return (*rtcmFrameCounter == rtcmLen) ? SFE_UBLOX_SENTENCE_TYPE_NONE : SFE_UBLOX_SENTENCE_TYPE_RTCM; } // This function is called for each byte of an RTCM frame @@ -2911,9 +2911,6 @@ SFE_UBLOX_GNSS::SentenceTypes SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, // Bytes can be piped to Serial or other interface. The consumer could be a radio or the internet (Ntrip broadcaster) void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming) { - uint8_t ignoreMe = incoming; - ignoreMe += 0; // Do something with incoming just to get rid of the pesky compiler warning! - // Radio.sendReliable((String)incoming); //An example of passing this byte to a radio //_debugSerial->write(incoming); //An example of passing this byte out the serial port @@ -2923,6 +2920,8 @@ void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming) // if(incoming < 0x10) _debugSerial->print(F("0")); // _debugSerial->print(incoming, HEX); // if(rtcmFrameCounter % 16 == 0) _debugSerial->println(); + + (void)incoming; // Do something with incoming just to get rid of the pesky compiler warning! } // Given a character, file it away into the uxb packet structure @@ -2995,7 +2994,7 @@ void SFE_UBLOX_GNSS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_ { incomingUBX->checksumB = incoming; - currentSentence = NONE; // We're done! Reset the sentence to being looking for a new start char + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // We're done! Reset the sentence to being looking for a new start char // Validate this sentence if ((incomingUBX->checksumA == rollingChecksumA) && (incomingUBX->checksumB == rollingChecksumB)) @@ -3163,7 +3162,7 @@ void SFE_UBLOX_GNSS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_ if (overrun || ((incomingUBX->counter == maximum_payload_size + 6) && (ignoreThisPayload == false))) { // Something has gone very wrong - currentSentence = NONE; // Reset the sentence to being looking for a new start char + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Reset the sentence to being looking for a new start char #ifndef SFE_UBLOX_REDUCED_PROG_MEM if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging { @@ -4620,9 +4619,6 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::sendCommand(ubxPacket *outgoingUBX, uint16_t // Returns false if sensor fails to respond to I2C traffic sfe_ublox_status_e SFE_UBLOX_GNSS::sendI2cCommand(ubxPacket *outgoingUBX, uint16_t maxWait) { - uint16_t ignoreMe = maxWait; - ignoreMe += 0; // Do something with maxWait just to avoid the pesky compiler warnings! - // From the integration guide: // "The receiver does not provide any write access except for writing UBX and NMEA messages to the // receiver, such as configuration or aiding data. Therefore, the register set mentioned in section Read @@ -4754,6 +4750,8 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::sendI2cCommand(ubxPacket *outgoingUBX, uint16 if (_i2cPort->endTransmission() != 0) return (SFE_UBLOX_STATUS_I2C_COMM_FAILURE); // Sensor did not ACK + (void)maxWait; // Do something with maxWait just to avoid the pesky compiler warnings! + return (SFE_UBLOX_STATUS_SUCCESS); } @@ -4784,7 +4782,7 @@ void SFE_UBLOX_GNSS::sendSerialCommand(ubxPacket *outgoingUBX) void SFE_UBLOX_GNSS::spiTransfer(uint8_t byteToTransfer) { uint8_t returnedByte = _spiPort->transfer(byteToTransfer); - if ((spiBufferIndex < getSpiTransactionSize()) && (returnedByte != 0xFF || currentSentence != NONE)) + if ((spiBufferIndex < getSpiTransactionSize()) && (returnedByte != 0xFF || currentSentence != SFE_UBLOX_SENTENCE_TYPE_NONE)) { spiBuffer[spiBufferIndex] = returnedByte; spiBufferIndex++; @@ -17497,8 +17495,7 @@ uint16_t SFE_UBLOX_GNSS::getMagAcc(uint16_t maxWait) // getGeoidSeparation is currently redundant. The geoid separation seems to only be provided in NMEA GGA and GNS messages. int32_t SFE_UBLOX_GNSS::getGeoidSeparation(uint16_t maxWait) { - uint16_t ignoreMe = maxWait; - ignoreMe += 0; // Do something with maxWait just to get rid of the pesky compiler warning + (void)maxWait; // Do something with maxWait just to get rid of the pesky compiler warning return (0); } diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index a7a2e3d..b929214 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -647,13 +647,13 @@ public: ~SFE_UBLOX_GNSS(void); // Depending on the sentence type the processor will load characters into different arrays - enum SentenceTypes + enum sfe_ublox_sentence_types_e { - NONE = 0, - NMEA, - UBX, - RTCM - } currentSentence = NONE; + SFE_UBLOX_SENTENCE_TYPE_NONE = 0, + SFE_UBLOX_SENTENCE_TYPE_NMEA, + SFE_UBLOX_SENTENCE_TYPE_UBX, + SFE_UBLOX_SENTENCE_TYPE_RTCM + } currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // A default of 250ms for maxWait seems fine for I2C but is not enough for SerialUSB. // If you know you are only going to be using I2C / Qwiic communication, you can @@ -747,7 +747,7 @@ public: void process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); // Processes NMEA and UBX binary sentences one byte at a time void processNMEA(char incoming) __attribute__((weak)); // Given a NMEA character, do something with it. User can overwrite if desired to use something like tinyGPS or MicroNMEA libraries - SentenceTypes processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) __attribute__((weak)); // Monitor the incoming bytes for start and length bytes + sfe_ublox_sentence_types_e processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) __attribute__((weak)); // Monitor the incoming bytes for start and length bytes void processRTCM(uint8_t incoming) __attribute__((weak)); // Given rtcm byte, do something with it. User can overwrite if desired to pipe bytes to radio, internet, etc. void processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); // Given a character, file it away into the uxb packet structure void processUBXpacket(ubxPacket *msg); // Once a packet has been received and validated, identify this packet's class/id and update internal flags