Skip to content

Commit

Permalink
Merge pull request #374 from sparkfun/Fix_#354
Browse files Browse the repository at this point in the history
Fix #354
  • Loading branch information
nseidle authored Jun 20, 2024
2 parents 36460b3 + 3984306 commit 06f6168
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Firmware/RTK_Everywhere/NVM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
89 changes: 58 additions & 31 deletions Firmware/RTK_Everywhere/ZED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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();
Expand Down Expand Up @@ -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()
{
Expand All @@ -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)
Expand All @@ -1716,20 +1740,23 @@ 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

settings.ubxConstellations[incoming].enabled ^= 1;

// 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)
Expand Down
8 changes: 4 additions & 4 deletions Firmware/RTK_Everywhere/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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_", },

Expand Down

0 comments on commit 06f6168

Please sign in to comment.