Skip to content

Commit b983e2c

Browse files
committed
Replace beginLBand with updateLBand
Rename updateLBand to updateLBandCorrections
1 parent 428ac7c commit b983e2c

File tree

3 files changed

+166
-116
lines changed

3 files changed

+166
-116
lines changed

Firmware/RTK_Everywhere/GNSS_Mosaic.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,6 +2615,7 @@ void GNSS_MOSAIC::update()
26152615
}
26162616

26172617
// Update spartnCorrectionsReceived
2618+
// Does this need if(online.lband_gnss) ? Not sure... TODO
26182619
if (millis() > (lastSpartnReception + (settings.correctionsSourcesLifetime_s * 1000))) // Timeout
26192620
{
26202621
if (spartnCorrectionsReceived) // If corrections were being received

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ volatile bool deadManWalking;
966966
settings.enablePrintRingBufferOffsets = false; \
967967
settings.enablePrintRoverAccuracy = true; \
968968
settings.enablePrintRtcSync = true; \
969-
settings.enablePrintSDBuffers = true; \
969+
settings.enablePrintSDBuffers = false; \
970970
settings.enablePrintStates = true; \
971971
settings.printBootTimes = true; \
972972
settings.printNetworkStatus = true; \
@@ -1160,9 +1160,6 @@ void setup()
11601160
DMW_b("gnss->configure");
11611161
gnss->configure(); // Requires settings. Configure GNSS module
11621162

1163-
DMW_b("beginLBand");
1164-
beginLBand(); // Begin L-Band
1165-
11661163
DMW_b("beginExternalEvent");
11671164
gnss->beginExternalEvent(); // Configure the event input
11681165

@@ -1290,7 +1287,10 @@ void loop()
12901287
networkUpdate(); // Maintain the network connections
12911288

12921289
DMW_c("updateLBand");
1293-
updateLBand(); // Check if we've recently received PointPerfect corrections or not
1290+
updateLBand(); // Update L-Band
1291+
1292+
DMW_c("updateLBandCorrections");
1293+
updateLBandCorrections(); // Check if we've recently received PointPerfect corrections or not
12941294

12951295
DMW_c("tiltUpdate");
12961296
tiltUpdate(); // Check if new lat/lon/alt have been calculated

Firmware/RTK_Everywhere/menuPP.ino

Lines changed: 160 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -729,161 +729,210 @@ long gpsToMjd(long GpsCycle, long GpsWeek, long GpsSeconds)
729729
// Global L-Band Routines
730730
//----------------------------------------
731731

732-
// Begin any L-Band hardware
732+
// Update any L-Band hardware
733733
// Check if NEO-D9S is connected. Configure if available.
734734
// If GNSS is mosaic-X5, configure LBandBeam1
735-
void beginLBand()
735+
void updateLBand()
736736
{
737737

738738
#ifdef COMPILE_L_BAND
739739
if (present.lband_neo)
740740
{
741-
if (i2cLBand.begin(*i2c_0, 0x43) ==
742-
false) // Connect to the u-blox NEO-D9S using Wire port. The D9S default I2C address is 0x43 (not 0x42)
741+
if (!online.lband_neo && settings.enablePointPerfectCorrections)
743742
{
744-
if (settings.debugCorrections == true)
743+
static bool lband_neo_can_not_begin = false;
744+
745+
if (lband_neo_can_not_begin)
746+
return;
747+
748+
// NEO-D9S is present but is not yet online. Try to begin the hardware
749+
if (i2cLBand.begin(*i2c_0, 0x43) ==
750+
false) // Connect to the u-blox NEO-D9S using Wire port. The D9S default I2C address is 0x43 (not 0x42)
751+
{
745752
systemPrintln("L-Band not detected");
746-
return;
747-
}
753+
lband_neo_can_not_begin = true;
754+
return;
755+
}
748756

749-
// Check the firmware version of the NEO-D9S. Based on Example21_ModuleInfo.
750-
if (i2cLBand.getModuleInfo(1100) == true) // Try to get the module info
751-
{
752-
// Reconstruct the firmware version
753-
snprintf(neoFirmwareVersion, sizeof(neoFirmwareVersion), "%s %d.%02d", i2cLBand.getFirmwareType(),
754-
i2cLBand.getFirmwareVersionHigh(), i2cLBand.getFirmwareVersionLow());
757+
// Check the firmware version of the NEO-D9S. Based on Example21_ModuleInfo.
758+
if (i2cLBand.getModuleInfo(1100) == true) // Try to get the module info
759+
{
760+
// Reconstruct the firmware version
761+
snprintf(neoFirmwareVersion, sizeof(neoFirmwareVersion), "%s %d.%02d", i2cLBand.getFirmwareType(),
762+
i2cLBand.getFirmwareVersionHigh(), i2cLBand.getFirmwareVersionLow());
755763

756-
printNEOInfo(); // Print module firmware version
757-
}
764+
printNEOInfo(); // Print module firmware version
765+
}
766+
else
767+
{
768+
systemPrintln("L-Band not detected");
769+
lband_neo_can_not_begin = true;
770+
return;
771+
}
758772

759-
gnss->update();
773+
// Update the GNSS position. Use the position to set the frequency if available
774+
gnss->update();
760775

761-
uint32_t LBandFreq;
762-
uint8_t fixType = gnss->getFixType();
763-
double latitude = gnss->getLatitude();
764-
double longitude = gnss->getLongitude();
765-
// If we have a fix, check which frequency to use
766-
if (fixType >= 2 && fixType <= 5) // 2D, 3D, 3D+DR, or Time
767-
{
768-
int r = 0; // Step through each geographic region
769-
for (; r < numRegionalAreas; r++)
776+
uint32_t LBandFreq;
777+
uint8_t fixType = gnss->getFixType();
778+
double latitude = gnss->getLatitude();
779+
double longitude = gnss->getLongitude();
780+
781+
// If we have a fix, check which frequency to use
782+
if (fixType >= 2 && fixType <= 5) // 2D, 3D, 3D+DR, or Time
770783
{
771-
if ((longitude >= Regional_Information_Table[r].area.lonWest) &&
772-
(longitude <= Regional_Information_Table[r].area.lonEast) &&
773-
(latitude >= Regional_Information_Table[r].area.latSouth) &&
774-
(latitude <= Regional_Information_Table[r].area.latNorth))
784+
int r = 0; // Step through each geographic region
785+
for (; r < numRegionalAreas; r++)
786+
{
787+
if ((longitude >= Regional_Information_Table[r].area.lonWest) &&
788+
(longitude <= Regional_Information_Table[r].area.lonEast) &&
789+
(latitude >= Regional_Information_Table[r].area.latSouth) &&
790+
(latitude <= Regional_Information_Table[r].area.latNorth))
791+
{
792+
LBandFreq = Regional_Information_Table[r].frequency;
793+
if (settings.debugCorrections == true)
794+
systemPrintf("Setting L-Band frequency to %s (%dHz)\r\n", Regional_Information_Table[r].name,
795+
LBandFreq);
796+
break;
797+
}
798+
}
799+
if (r == numRegionalAreas) // Geographic region not found
775800
{
776-
LBandFreq = Regional_Information_Table[r].frequency;
801+
LBandFreq = Regional_Information_Table[settings.geographicRegion].frequency;
777802
if (settings.debugCorrections == true)
778-
systemPrintf("Setting L-Band frequency to %s (%dHz)\r\n", Regional_Information_Table[r].name,
779-
LBandFreq);
780-
break;
803+
systemPrintf("Error: Unknown L-Band geographic region. Using %s (%dHz)\r\n",
804+
Regional_Information_Table[settings.geographicRegion].name, LBandFreq);
781805
}
782806
}
783-
if (r == numRegionalAreas) // Geographic region not found
807+
else
784808
{
785809
LBandFreq = Regional_Information_Table[settings.geographicRegion].frequency;
786810
if (settings.debugCorrections == true)
787-
systemPrintf("Error: Unknown L-Band geographic region. Using %s (%dHz)\r\n",
788-
Regional_Information_Table[settings.geographicRegion].name, LBandFreq);
811+
systemPrintf("No fix available for L-Band geographic region determination. Using %s (%dHz)\r\n",
812+
Regional_Information_Table[settings.geographicRegion].name, LBandFreq);
789813
}
790-
}
791-
else
792-
{
793-
LBandFreq = Regional_Information_Table[settings.geographicRegion].frequency;
794-
if (settings.debugCorrections == true)
795-
systemPrintf("No fix available for L-Band geographic region determination. Using %s (%dHz)\r\n",
796-
Regional_Information_Table[settings.geographicRegion].name, LBandFreq);
797-
}
798-
799-
bool response = true;
800-
response &= i2cLBand.newCfgValset();
801-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_CENTER_FREQUENCY, LBandFreq); // Default 1539812500 Hz
802-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_SEARCH_WINDOW, 2200); // Default 2200 Hz
803-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_SERVICE_ID, 0); // Default 1
804-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_SERVICE_ID, 21845); // Default 50821
805-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_DATA_RATE, 2400); // Default 2400 bps
806-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_DESCRAMBLER, 1); // Default 1
807-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_DESCRAMBLER_INIT, 26969); // Default 23560
808-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_PRESCRAMBLING, 0); // Default 0
809-
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_UNIQUE_WORD, 16238547128276412563ull);
810-
response &=
811-
i2cLBand.addCfgValset(UBLOX_CFG_MSGOUT_UBX_RXM_PMP_UART1, 0); // Diasable UBX-RXM-PMP on UART1. Not used.
812-
813-
response &= i2cLBand.sendCfgValset();
814814

815-
GNSS_ZED *zed = (GNSS_ZED *)gnss;
816-
response &= zed->lBandCommunicationEnable();
817-
818-
if (response == false)
819-
systemPrintln("L-Band failed to configure");
820-
821-
i2cLBand.softwareResetGNSSOnly(); // Do a restart
815+
bool response = true;
816+
response &= i2cLBand.newCfgValset();
817+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_CENTER_FREQUENCY, LBandFreq); // Default 1539812500 Hz
818+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_SEARCH_WINDOW, 2200); // Default 2200 Hz
819+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_SERVICE_ID, 0); // Default 1
820+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_SERVICE_ID, 21845); // Default 50821
821+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_DATA_RATE, 2400); // Default 2400 bps
822+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_DESCRAMBLER, 1); // Default 1
823+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_DESCRAMBLER_INIT, 26969); // Default 23560
824+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_USE_PRESCRAMBLING, 0); // Default 0
825+
response &= i2cLBand.addCfgValset(UBLOX_CFG_PMP_UNIQUE_WORD, 16238547128276412563ull);
826+
response &=
827+
i2cLBand.addCfgValset(UBLOX_CFG_MSGOUT_UBX_RXM_PMP_UART1, 0); // Disable UBX-RXM-PMP on UART1. Not used.
828+
829+
response &= i2cLBand.sendCfgValset();
830+
831+
GNSS_ZED *zed = (GNSS_ZED *)gnss;
832+
response &= zed->lBandCommunicationEnable();
833+
834+
if (response == false)
835+
{
836+
systemPrintln("L-Band failed to configure");
837+
lband_neo_can_not_begin = true;
838+
return;
839+
}
822840

823-
if (settings.debugCorrections == true)
824-
systemPrintln("L-Band online");
841+
i2cLBand.softwareResetGNSSOnly(); // Do a restart
825842

826-
gnss->applyPointPerfectKeys(); // Apply keys now, if we have them. This sets online.lbandCorrections
843+
if (settings.debugCorrections == true)
844+
systemPrintln("L-Band online");
827845

828-
online.lband_neo = true;
846+
online.lband_neo = true;
847+
}
848+
else if (online.lband_neo && settings.enablePointPerfectCorrections)
849+
{
850+
// L-Band is online. Apply the keys if they have changed
851+
// This may be redundant as PROVISIONING_KEYS_REMAINING also applies the keys
852+
static char previousKey[33] = "";
853+
if (strncmp(previousKey, settings.pointPerfectCurrentKey, 33) != 0)
854+
{
855+
strncpy(previousKey, settings.pointPerfectCurrentKey, 33);
856+
gnss->applyPointPerfectKeys(); // Apply keys now. This sets online.lbandCorrections
857+
if (settings.debugCorrections == true)
858+
systemPrintln("ZED-F9P PointPerfect keys applied");
859+
}
860+
}
829861
}
830862
#endif // COMPILE_L_BAND
831863
#ifdef COMPILE_MOSAICX5
832-
if (present.gnss_mosaicX5 && settings.enablePointPerfectCorrections)
864+
if (present.gnss_mosaicX5)
833865
{
834-
uint32_t LBandFreq;
835-
uint8_t fixType = gnss->getFixType();
836-
double latitude = gnss->getLatitude();
837-
double longitude = gnss->getLongitude();
838-
// If we have a fix, check which frequency to use
839-
if (fixType >= 1) // Stand-Alone PVT or better
866+
if (!online.lband_gnss && settings.enablePointPerfectCorrections)
840867
{
841-
int r = 0; // Step through each geographic region
842-
for (; r < numRegionalAreas; r++)
868+
static bool lband_gnss_can_not_begin = false;
869+
870+
if (lband_gnss_can_not_begin)
871+
return;
872+
873+
uint32_t LBandFreq;
874+
uint8_t fixType = gnss->getFixType();
875+
double latitude = gnss->getLatitude();
876+
double longitude = gnss->getLongitude();
877+
// If we have a fix, check which frequency to use
878+
if (fixType >= 1) // Stand-Alone PVT or better
843879
{
844-
if ((longitude >= Regional_Information_Table[r].area.lonWest) &&
845-
(longitude <= Regional_Information_Table[r].area.lonEast) &&
846-
(latitude >= Regional_Information_Table[r].area.latSouth) &&
847-
(latitude <= Regional_Information_Table[r].area.latNorth))
880+
int r = 0; // Step through each geographic region
881+
for (; r < numRegionalAreas; r++)
848882
{
849-
LBandFreq = Regional_Information_Table[r].frequency;
883+
if ((longitude >= Regional_Information_Table[r].area.lonWest) &&
884+
(longitude <= Regional_Information_Table[r].area.lonEast) &&
885+
(latitude >= Regional_Information_Table[r].area.latSouth) &&
886+
(latitude <= Regional_Information_Table[r].area.latNorth))
887+
{
888+
LBandFreq = Regional_Information_Table[r].frequency;
889+
if (settings.debugCorrections == true)
890+
systemPrintf("Setting L-Band frequency to %s (%dHz)\r\n", Regional_Information_Table[r].name,
891+
LBandFreq);
892+
break;
893+
}
894+
}
895+
if (r == numRegionalAreas) // Geographic region not found
896+
{
897+
LBandFreq = Regional_Information_Table[settings.geographicRegion].frequency;
850898
if (settings.debugCorrections == true)
851-
systemPrintf("Setting L-Band frequency to %s (%dHz)\r\n", Regional_Information_Table[r].name,
852-
LBandFreq);
853-
break;
899+
systemPrintf("Error: Unknown L-Band geographic region. Using %s (%dHz)\r\n",
900+
Regional_Information_Table[settings.geographicRegion].name, LBandFreq);
854901
}
855902
}
856-
if (r == numRegionalAreas) // Geographic region not found
903+
else
857904
{
858905
LBandFreq = Regional_Information_Table[settings.geographicRegion].frequency;
859906
if (settings.debugCorrections == true)
860-
systemPrintf("Error: Unknown L-Band geographic region. Using %s (%dHz)\r\n",
861-
Regional_Information_Table[settings.geographicRegion].name, LBandFreq);
907+
systemPrintf("No fix available for L-Band geographic region determination. Using %s (%dHz)\r\n",
908+
Regional_Information_Table[settings.geographicRegion].name, LBandFreq);
862909
}
863-
}
864-
else
865-
{
866-
LBandFreq = Regional_Information_Table[settings.geographicRegion].frequency;
867-
if (settings.debugCorrections == true)
868-
systemPrintf("No fix available for L-Band geographic region determination. Using %s (%dHz)\r\n",
869-
Regional_Information_Table[settings.geographicRegion].name, LBandFreq);
870-
}
871910

872-
bool result = true;
911+
bool result = true;
873912

874-
// If no SPARTN data is received, the L-Band may need a 'kick'. Turn L-Band off and back on again!
875-
GNSS_MOSAIC *mosaic = (GNSS_MOSAIC *)gnss;
913+
GNSS_MOSAIC *mosaic = (GNSS_MOSAIC *)gnss;
876914

877-
result &= mosaic->configureGNSSCOM(true); // Ensure LBandBeam1 is enabled on COM1
915+
result &= mosaic->configureGNSSCOM(true); // Ensure LBandBeam1 is enabled on COM1
878916

879-
result &= mosaic->configureLBand(true, LBandFreq); // Start L-Band
917+
result &= mosaic->configureLBand(true, LBandFreq); // Start L-Band
880918

881-
if (result == false)
882-
systemPrintln("mosaic-X5 L-Band failed to configure");
883-
else if (settings.debugCorrections == true)
884-
systemPrintln("mosaic-X5 L-Band online");
885-
886-
online.lband_gnss = result;
919+
if (result == false)
920+
{
921+
systemPrintln("mosaic-X5 L-Band failed to configure");
922+
lband_gnss_can_not_begin = true;
923+
}
924+
else
925+
{
926+
if (settings.debugCorrections == true)
927+
systemPrintln("mosaic-X5 L-Band online");
928+
online.lband_gnss = true;
929+
}
930+
}
931+
//else if (online.lband_gnss && settings.enablePointPerfectCorrections)
932+
{
933+
// If no SPARTN data is received, the L-Band may need a 'kick'. Turn L-Band off and back on again!
934+
// But gnss->update will do this. No need to do it here
935+
}
887936
}
888937
#endif // /COMPILE_MOSAICX5
889938
}
@@ -1092,7 +1141,7 @@ bool pointPerfectIsEnabled()
10921141
}
10931142

10941143
// Process any new L-Band from I2C
1095-
void updateLBand()
1144+
void updateLBandCorrections()
10961145
{
10971146
static unsigned long lbandLastReport;
10981147
static unsigned long lbandTimeFloatStarted; // Monitors the ZED during L-Band reception if a fix takes too long

0 commit comments

Comments
 (0)