diff --git a/library.properties b/library.properties index 5a44632..03274ff 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun u-blox GNSS Arduino Library -version=2.2.25 +version=2.2.26 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules

diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 6d68956..a399c33 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -7725,25 +7725,33 @@ bool SFE_UBLOX_GNSS::getProtocolVersion(uint16_t maxWait) // } // We will step through the payload looking at each extension field of 30 bytes - for (uint8_t extensionNumber = 0; extensionNumber < 10; extensionNumber++) + char *ptr; + for (uint8_t extensionNumber = 0; extensionNumber < ((packetCfg.len - 40) / 30); extensionNumber++) { - // Now we need to find "PROTVER=18.00" in the incoming byte stream - if ((payloadCfg[(30 * extensionNumber) + 0] == 'P') && (payloadCfg[(30 * extensionNumber) + 6] == 'R')) + ptr = strstr((const char *)&payloadCfg[(30 * extensionNumber)], "PROTVER="); // Check for PROTVER (should be in extension 2) + if (ptr != nullptr) { - moduleSWVersion->versionHigh = (payloadCfg[(30 * extensionNumber) + 8] - '0') * 10 + (payloadCfg[(30 * extensionNumber) + 9] - '0'); // Convert '18' to 18 - moduleSWVersion->versionLow = (payloadCfg[(30 * extensionNumber) + 11] - '0') * 10 + (payloadCfg[(30 * extensionNumber) + 12] - '0'); // Convert '00' to 00 - moduleSWVersion->moduleQueried = true; // Mark this data as new + ptr += strlen("PROTVER="); // Point to the protocol version + int protHi = 0; + int protLo = 0; + int scanned = sscanf(ptr, "%d.%d", &protHi, &protLo); + if (scanned == 2) // Check we extracted the firmware version successfully + { + moduleSWVersion->versionHigh = protHi; + moduleSWVersion->versionLow = protLo; + moduleSWVersion->moduleQueried = true; // Mark this data as new #ifndef SFE_UBLOX_REDUCED_PROG_MEM - if (_printDebug == true) - { - _debugSerial->print(F("Protocol version: ")); - _debugSerial->print(moduleSWVersion->versionHigh); - _debugSerial->print(F(".")); - _debugSerial->println(moduleSWVersion->versionLow); - } + if (_printDebug == true) + { + _debugSerial->print(F("Protocol version: ")); + _debugSerial->print(moduleSWVersion->versionHigh); + _debugSerial->print(F(".")); + _debugSerial->println(moduleSWVersion->versionLow); + } #endif - return (true); // Success! + return (true); // Success! + } } } diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index fedd63a..9f7245d 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -604,7 +604,7 @@ enum sfe_ublox_rxm_mode_e #ifndef MAX_PAYLOAD_SIZE // v2.0: keep this for backwards-compatibility, but this is largely superseded by setPacketCfgPayloadSize -#define MAX_PAYLOAD_SIZE 256 // We need ~220 bytes for getProtocolVersion on most ublox modules +#define MAX_PAYLOAD_SIZE 276 // We need >=250 bytes for getProtocolVersion on the NEO-F10N //#define MAX_PAYLOAD_SIZE 768 //Worst case: UBX_CFG_VALSET packet with 64 keyIDs each with 64 bit values #endif