From 39843060d9a802b961259a41c574c7522886b459 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 20 Jun 2024 09:50:26 +0100 Subject: [PATCH] Fix #354 --- Firmware/RTK_Everywhere/NVM.ino | 2 +- Firmware/RTK_Everywhere/ZED.ino | 89 +++++++++++++++++++----------- Firmware/RTK_Everywhere/settings.h | 8 +-- 3 files changed, 63 insertions(+), 36 deletions(-) diff --git a/Firmware/RTK_Everywhere/NVM.ino b/Firmware/RTK_Everywhere/NVM.ino index 2f1af967f..babc43dad 100644 --- a/Firmware/RTK_Everywhere/NVM.ino +++ b/Firmware/RTK_Everywhere/NVM.ino @@ -346,7 +346,7 @@ void recordSystemSettingsToFile(File *settingsFile) // Record constellation settings for (int x = 0; x < rtkSettingsEntries[i].qualifier; x++) { - char tempString[50]; // ubxConstellation_BeiDou=1 + char tempString[50]; // constellation_BeiDou=1 snprintf(tempString, sizeof(tempString), "%s%s=%d", rtkSettingsEntries[i].name, settings.ubxConstellations[x].textName, settings.ubxConstellations[x].enabled); settingsFile->println(tempString); diff --git a/Firmware/RTK_Everywhere/ZED.ino b/Firmware/RTK_Everywhere/ZED.ino index 44dea9928..290c868de 100644 --- a/Firmware/RTK_Everywhere/ZED.ino +++ b/Firmware/RTK_Everywhere/ZED.ino @@ -1345,12 +1345,14 @@ bool zedSetConstellations(bool sendCompleteBatch) if (sendCompleteBatch) response &= theGNSS->newCfgValset(); - bool enableMe = settings.ubxConstellations[0].enabled; - response &= theGNSS->addCfgValset(settings.ubxConstellations[0].configKey, enableMe); // GPS - - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GPS_L1CA_ENA, settings.ubxConstellations[0].enabled); - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GPS_L2C_ENA, settings.ubxConstellations[0].enabled); - + // GPS + int gnssIndex = ubxConstellationIDToIndex(SFE_UBLOX_GNSS_ID_GPS); + bool enableMe = settings.ubxConstellations[gnssIndex].enabled; + response &= theGNSS->addCfgValset(settings.ubxConstellations[gnssIndex].configKey, enableMe); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GPS_L1CA_ENA, enableMe); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GPS_L2C_ENA, enableMe); + + // SBAS // v1.12 ZED-F9P firmware does not allow for SBAS control // Also, if we can't identify the version (99), skip SBAS enable if ((gnssFirmwareVersionInt == 112) || (gnssFirmwareVersionInt == 99)) @@ -1359,34 +1361,45 @@ bool zedSetConstellations(bool sendCompleteBatch) } else { - response &= theGNSS->addCfgValset(settings.ubxConstellations[1].configKey, - settings.ubxConstellations[1].enabled); // SBAS - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_SBAS_L1CA_ENA, settings.ubxConstellations[1].enabled); + gnssIndex = ubxConstellationIDToIndex(SFE_UBLOX_GNSS_ID_SBAS); + enableMe = settings.ubxConstellations[gnssIndex].enabled; + response &= theGNSS->addCfgValset(settings.ubxConstellations[gnssIndex].configKey, enableMe); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_SBAS_L1CA_ENA, enableMe); } + // GAL + gnssIndex = ubxConstellationIDToIndex(SFE_UBLOX_GNSS_ID_GALILEO); + enableMe = settings.ubxConstellations[gnssIndex].enabled; response &= - theGNSS->addCfgValset(settings.ubxConstellations[2].configKey, settings.ubxConstellations[2].enabled); // GAL - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GAL_E1_ENA, settings.ubxConstellations[2].enabled); - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GAL_E5B_ENA, settings.ubxConstellations[2].enabled); + theGNSS->addCfgValset(settings.ubxConstellations[gnssIndex].configKey, enableMe); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GAL_E1_ENA, enableMe); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GAL_E5B_ENA, enableMe); + // BDS + gnssIndex = ubxConstellationIDToIndex(SFE_UBLOX_GNSS_ID_BEIDOU); + enableMe = settings.ubxConstellations[gnssIndex].enabled; response &= - theGNSS->addCfgValset(settings.ubxConstellations[3].configKey, settings.ubxConstellations[3].enabled); // BDS - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_BDS_B1_ENA, settings.ubxConstellations[3].enabled); - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_BDS_B2_ENA, settings.ubxConstellations[3].enabled); + theGNSS->addCfgValset(settings.ubxConstellations[gnssIndex].configKey, enableMe); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_BDS_B1_ENA, enableMe); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_BDS_B2_ENA, enableMe); + // QZSS + gnssIndex = ubxConstellationIDToIndex(SFE_UBLOX_GNSS_ID_QZSS); + enableMe = settings.ubxConstellations[gnssIndex].enabled; response &= - theGNSS->addCfgValset(settings.ubxConstellations[4].configKey, settings.ubxConstellations[4].enabled); // QZSS - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_QZSS_L1CA_ENA, settings.ubxConstellations[4].enabled); - + theGNSS->addCfgValset(settings.ubxConstellations[gnssIndex].configKey, enableMe); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_QZSS_L1CA_ENA, enableMe); // UBLOX_CFG_SIGNAL_QZSS_L1S_ENA not supported on F9R in v1.21 and below - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_QZSS_L1S_ENA, settings.ubxConstellations[4].enabled); - - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_QZSS_L2C_ENA, settings.ubxConstellations[4].enabled); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_QZSS_L1S_ENA, enableMe); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_QZSS_L2C_ENA, enableMe); + // GLO + gnssIndex = ubxConstellationIDToIndex(SFE_UBLOX_GNSS_ID_GLONASS); + enableMe = settings.ubxConstellations[gnssIndex].enabled; response &= - theGNSS->addCfgValset(settings.ubxConstellations[5].configKey, settings.ubxConstellations[5].enabled); // GLO - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GLO_L1_ENA, settings.ubxConstellations[5].enabled); - response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GLO_L2_ENA, settings.ubxConstellations[5].enabled); + theGNSS->addCfgValset(settings.ubxConstellations[gnssIndex].configKey, enableMe); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GLO_L1_ENA, enableMe); + response &= theGNSS->addCfgValset(UBLOX_CFG_SIGNAL_GLO_L2_ENA, enableMe); if (sendCompleteBatch) response &= theGNSS->sendCfgValset(); @@ -1694,6 +1707,17 @@ char *zedGetRtcmLowDataRateString() return ((char *)"1074/1084/1094/1124 1Hz & 1005/1230 0.1Hz"); } +int ubxConstellationIDToIndex(int id) +{ + for (int x = 0; x < MAX_UBX_CONSTELLATIONS; x++) + { + if (settings.ubxConstellations[x].gnssID == id) + return x; + } + + return -1; // Should never be reached...! +} + // Controls the constellations that are used to generate a fix and logged void zedMenuConstellations() { @@ -1702,7 +1726,7 @@ void zedMenuConstellations() systemPrintln(); systemPrintln("Menu: Constellations"); - for (int x = 0; x < MAX_CONSTELLATIONS; x++) + for (int x = 0; x < MAX_UBX_CONSTELLATIONS; x++) { systemPrintf("%d) Constellation %s: ", x + 1, settings.ubxConstellations[x].textName); if (settings.ubxConstellations[x].enabled == true) @@ -1716,7 +1740,7 @@ void zedMenuConstellations() int incoming = getUserInputNumber(); // Returns EXIT, TIMEOUT, or long - if (incoming >= 1 && incoming <= MAX_CONSTELLATIONS) + if (incoming >= 1 && incoming <= MAX_UBX_CONSTELLATIONS) { incoming--; // Align choice to constellation array of 0 to 5 @@ -1724,12 +1748,15 @@ void zedMenuConstellations() // 3.10.6: To avoid cross-correlation issues, it is recommended that GPS and QZSS are always both enabled or // both disabled. - if (incoming == SFE_UBLOX_GNSS_ID_GPS || incoming == 4) // QZSS ID is 5 but array location is 4 + if (incoming == ubxConstellationIDToIndex(SFE_UBLOX_GNSS_ID_GPS)) // Match QZSS to GPS + { + settings.ubxConstellations[ubxConstellationIDToIndex(SFE_UBLOX_GNSS_ID_QZSS)].enabled = + settings.ubxConstellations[incoming].enabled; + } + if (incoming == ubxConstellationIDToIndex(SFE_UBLOX_GNSS_ID_QZSS)) // Match GPS to QZSS { - settings.ubxConstellations[SFE_UBLOX_GNSS_ID_GPS].enabled = - settings.ubxConstellations[incoming].enabled; // GPS ID is 0 and array location is 0 - settings.ubxConstellations[4].enabled = - settings.ubxConstellations[incoming].enabled; // QZSS ID is 5 but array location is 4 + settings.ubxConstellations[ubxConstellationIDToIndex(SFE_UBLOX_GNSS_ID_GPS)].enabled = + settings.ubxConstellations[incoming].enabled; } } else if (incoming == INPUT_RESPONSE_GETNUMBER_EXIT) diff --git a/Firmware/RTK_Everywhere/settings.h b/Firmware/RTK_Everywhere/settings.h index d5ee46eb6..2ef9e7fac 100644 --- a/Firmware/RTK_Everywhere/settings.h +++ b/Firmware/RTK_Everywhere/settings.h @@ -504,7 +504,7 @@ typedef struct // These are the allowable constellations to receive from and log (if enabled) // Tested with u-center v21.02 -#define MAX_CONSTELLATIONS 6 //(sizeof(ubxConstellations)/sizeof(ubxConstellation)) +#define MAX_UBX_CONSTELLATIONS 6 // Should be (sizeof(settings.ubxConstellations)/sizeof(ubxConstellation)). Tricky... // Print the base coordinates in different formats, depending on the type the user has entered // These are the different supported types @@ -1305,8 +1305,8 @@ struct Settings int8_t timeZoneSeconds = 0; // UBX (SX1276) - bool enableUART2UBXIn = false; // UBX Protocol In on UART2 - ubxConstellation ubxConstellations[MAX_CONSTELLATIONS] = { // Constellations monitored/used for fix + bool enableUART2UBXIn = false; // UBX Protocol In on UART2 + ubxConstellation ubxConstellations[MAX_UBX_CONSTELLATIONS] = { // Constellations monitored/used for fix {UBLOX_CFG_SIGNAL_BDS_ENA, SFE_UBLOX_GNSS_ID_BEIDOU, true, "BeiDou"}, {UBLOX_CFG_SIGNAL_GAL_ENA, SFE_UBLOX_GNSS_ID_GALILEO, true, "Galileo"}, {UBLOX_CFG_SIGNAL_GLO_ENA, SFE_UBLOX_GNSS_ID_GLONASS, true, "GLONASS"}, @@ -1802,7 +1802,7 @@ const RTK_Settings_Entry rtkSettingsEntries[] = // ublox GNSS Receiver { 0, 1, 1, 0, 1, 1, 0, 0, _bool, 0, & settings.enableUART2UBXIn, "enableUART2UBXIn", }, - { 1, 1, 1, 1, 1, 1, 0, 0, tUbxConst, MAX_CONSTELLATIONS, & settings.ubxConstellations[0], "constellation_", }, + { 1, 1, 1, 1, 1, 1, 0, 0, tUbxConst, MAX_UBX_CONSTELLATIONS, & settings.ubxConstellations[0], "constellation_", }, { 1, 0, 1, 1, 1, 1, 0, 0, tUbxMsgRt, MAX_UBX_MSG, & settings.ubxMessageRates[0], "ubxMessageRate_", }, { 1, 0, 1, 1, 1, 1, 0, 0, tUbMsgRtb, MAX_UBX_MSG_RTCM, & settings.ubxMessageRatesBase[0], "ubxMessageRateBase_", },