From 52fca372b9ce1628dc690164e3fc74487ed9e325 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 29 May 2023 14:54:19 +0100 Subject: [PATCH] Add support for module unique ID --- Firmware/RTK_Surveyor/Begin.ino | 6 ++++++ Firmware/RTK_Surveyor/Form.ino | 4 ++-- Firmware/RTK_Surveyor/NVM.ino | 5 +++++ Firmware/RTK_Surveyor/RTK_Surveyor.ino | 1 + Firmware/RTK_Surveyor/menuMessages.ino | 5 +++++ Firmware/RTK_Surveyor/menuSystem.ino | 2 ++ Firmware/RTK_Surveyor/settings.h | 1 + 7 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Firmware/RTK_Surveyor/Begin.ino b/Firmware/RTK_Surveyor/Begin.ino index 39c106754..4016d35c1 100644 --- a/Firmware/RTK_Surveyor/Begin.ino +++ b/Firmware/RTK_Surveyor/Begin.ino @@ -769,6 +769,12 @@ void beginGNSS() printZEDInfo(); // Print module type and firmware version } + UBX_SEC_UNIQID_data_t chipID; + if (theGNSS.getUniqueChipId(&chipID)) + { + snprintf(zedUniqueId, sizeof(zedUniqueId), "%s", theGNSS.getUniqueChipIdStr(&chipID)); + } + online.gnss = true; } diff --git a/Firmware/RTK_Surveyor/Form.ino b/Firmware/RTK_Surveyor/Form.ino index 205799959..1109fd7b9 100644 --- a/Firmware/RTK_Surveyor/Form.ino +++ b/Firmware/RTK_Surveyor/Form.ino @@ -586,8 +586,8 @@ void createSettingsString(char *newSettings) strcpy(apZedPlatform, "ZED-F9R"); char apZedFirmwareVersion[80]; - snprintf(apZedFirmwareVersion, sizeof(apZedFirmwareVersion), "%s Firmware: %s", apZedPlatform, - zedFirmwareVersion); + snprintf(apZedFirmwareVersion, sizeof(apZedFirmwareVersion), "%s Firmware: %s ID: %s", apZedPlatform, + zedFirmwareVersion, zedUniqueId); stringRecord(newSettings, "zedFirmwareVersion", apZedFirmwareVersion); stringRecord(newSettings, "zedFirmwareVersionInt", zedFirmwareVersionInt); } diff --git a/Firmware/RTK_Surveyor/NVM.ino b/Firmware/RTK_Surveyor/NVM.ino index d66ec9c49..2a69132ff 100644 --- a/Firmware/RTK_Surveyor/NVM.ino +++ b/Firmware/RTK_Surveyor/NVM.ino @@ -199,6 +199,8 @@ void recordSystemSettingsToFile(File *settingsFile) settingsFile->printf("%s=%s\r\n", "zedFirmwareVersion", zedFirmwareVersion); + settingsFile->printf("%s=%s\r\n", "zedUniqueId", zedUniqueId); + if (productVariant == RTK_FACET_LBAND) settingsFile->printf("%s=%s\r\n", "neoFirmwareVersion", neoFirmwareVersion); @@ -744,6 +746,9 @@ bool parseLine(char *str, Settings *settings) else if (strcmp(settingName, "zedFirmwareVersion") == 0) { } // Do nothing. Just read it to avoid 'Unknown setting' error + else if (strcmp(settingName, "zedUniqueId") == 0) + { + } // Do nothing. Just read it to avoid 'Unknown setting' error else if (strcmp(settingName, "neoFirmwareVersion") == 0) { } // Do nothing. Just read it to avoid 'Unknown setting' error diff --git a/Firmware/RTK_Surveyor/RTK_Surveyor.ino b/Firmware/RTK_Surveyor/RTK_Surveyor.ino index 886fd35b5..296537533 100644 --- a/Firmware/RTK_Surveyor/RTK_Surveyor.ino +++ b/Firmware/RTK_Surveyor/RTK_Surveyor.ino @@ -252,6 +252,7 @@ char neoFirmwareVersion[20]; // Output to system status menu. uint8_t zedFirmwareVersionInt = 0; // Controls which features (constellations) can be configured (v1.12 doesn't support // SBAS). Note: will fail above 2.55! uint8_t zedModuleType = PLATFORM_F9P; // Controls which messages are supported and configured +char zedUniqueId[11] = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 0 }; // Output to system status menu and log file. // Use Michael's lock/unlock methods to prevent the UART2 task from calling checkUblox during a sendCommand and // waitForResponse. Also prevents pushRawData from being called too. diff --git a/Firmware/RTK_Surveyor/menuMessages.ino b/Firmware/RTK_Surveyor/menuMessages.ino index 7194399ad..70927da04 100644 --- a/Firmware/RTK_Surveyor/menuMessages.ino +++ b/Firmware/RTK_Surveyor/menuMessages.ino @@ -615,6 +615,11 @@ void beginLogging(const char *customFileName) zedFirmwareVersion); // textID, buffer, sizeOfBuffer, text ubxFile->println(nmeaMessage); + // ZED-F9 unique chip ID + createNMEASentence(CUSTOM_NMEA_TYPE_ZED_UNIQUE_ID, nmeaMessage, sizeof(nmeaMessage), + zedUniqueId); // textID, buffer, sizeOfBuffer, text + ubxFile->println(nmeaMessage); + // Device BT MAC. See issue: https://github.com/sparkfun/SparkFun_RTK_Firmware/issues/346 char macAddress[5]; snprintf(macAddress, sizeof(macAddress), "%02X%02X", btMACAddress[4], btMACAddress[5]); diff --git a/Firmware/RTK_Surveyor/menuSystem.ino b/Firmware/RTK_Surveyor/menuSystem.ino index 28734809a..e0eb46093 100644 --- a/Firmware/RTK_Surveyor/menuSystem.ino +++ b/Firmware/RTK_Surveyor/menuSystem.ino @@ -17,6 +17,8 @@ void menuSystem() printZEDInfo(); + systemPrintf("Module unique chip ID: %s\r\n", zedUniqueId); + printCurrentConditions(); } else diff --git a/Firmware/RTK_Surveyor/settings.h b/Firmware/RTK_Surveyor/settings.h index c4618c739..069429917 100644 --- a/Firmware/RTK_Surveyor/settings.h +++ b/Firmware/RTK_Surveyor/settings.h @@ -134,6 +134,7 @@ typedef enum CUSTOM_NMEA_TYPE_PARSER_STATS, CUSTOM_NMEA_TYPE_CURRENT_DATE, CUSTOM_NMEA_TYPE_ARP_ECEF_XYZH, + CUSTOM_NMEA_TYPE_ZED_UNIQUE_ID, } customNmeaType_e; // Freeze and blink LEDs if we hit a bad error