Skip to content

Commit 517d359

Browse files
committed
Correct caster response to banning. Add sandbox test.
Caster responds with '200' even when reporting ban or sourcetable. Correct the logic that tests for that. Also, added test for 'sandbox'.
1 parent 4b4c2a6 commit 517d359

File tree

1 file changed

+70
-60
lines changed

1 file changed

+70
-60
lines changed

Firmware/RTK_Surveyor/NtripClient.ino

Lines changed: 70 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -665,52 +665,80 @@ void ntripClientUpdate()
665665
// Look for various responses
666666
if (strstr(response, "200") != nullptr) //'200' found
667667
{
668-
// Timeout receiving NTRIP data, retry the NTRIP client connection
669-
if (online.rtc && online.gnss)
668+
// We got a response, now check it for possible errors
669+
if (strcasestr(response, "banned") != nullptr)
670670
{
671-
int hours;
672-
int minutes;
673-
int seconds;
674-
675-
seconds = rtc.getLocalEpoch() % SECONDS_IN_A_DAY;
676-
hours = seconds / SECONDS_IN_AN_HOUR;
677-
seconds -= hours * SECONDS_IN_AN_HOUR;
678-
minutes = seconds / SECONDS_IN_A_MINUTE;
679-
seconds -= minutes * SECONDS_IN_A_MINUTE;
680-
systemPrintf("NTRIP Client connected to %s:%d at %d:%02d:%02d\r\n",
681-
settings.ntripClient_CasterHost,
682-
settings.ntripClient_CasterPort,
683-
hours, minutes, seconds);
684-
}
685-
else
686-
systemPrintf("NTRIP Client connected to %s:%d\r\n",
687-
settings.ntripClient_CasterHost,
688-
settings.ntripClient_CasterPort);
671+
systemPrintf("NTRIP Client connected to caster but caster responded with problem: %s\r\n",
672+
response);
689673

690-
// Connection is now open, start the NTRIP receive data timer
691-
ntripClientTimer = millis();
674+
// Stop NTRIP client operations
675+
ntripClientShutdown();
676+
}
677+
else if (strcasestr(response, "sandbox") != nullptr)
678+
{
679+
systemPrintf("NTRIP Client connected to caster but caster responded with problem: %s\r\n",
680+
response);
692681

693-
if (settings.ntripClient_TransmitGGA == true)
682+
// Stop NTRIP client operations
683+
ntripClientShutdown();
684+
}
685+
else if (strcasestr(response, "SOURCETABLE") != nullptr)
694686
{
695-
// Set the Main Talker ID to "GP". The NMEA GGA messages will be GPGGA instead of GNGGA
696-
theGNSS.setVal8(UBLOX_CFG_NMEA_MAINTALKERID, 1);
697-
theGNSS.setNMEAGPGGAcallbackPtr(&pushGPGGA); // Set up the callback for GPGGA
698-
699-
float measurementFrequency = (1000.0 / settings.measurementRate) / settings.navigationRate;
700-
if (measurementFrequency < 0.2)
701-
measurementFrequency = 0.2; // 0.2Hz * 5 = 1 measurement every 5 seconds
702-
log_d("Adjusting GGA setting to %f", measurementFrequency);
703-
theGNSS.setVal8(
704-
UBLOX_CFG_MSGOUT_NMEA_ID_GGA_I2C,
705-
measurementFrequency); // Enable GGA over I2C. Tell the module to output GGA every second
706-
707-
lastGGAPush = millis() - NTRIPCLIENT_MS_BETWEEN_GGA; // Force immediate transmission of GGA message
687+
systemPrintf("Caster may not have mountpoint %s. Caster responded with problem: %s\r\n",
688+
settings.ntripClient_MountPoint, response);
689+
690+
// Stop NTRIP client operations
691+
ntripClientShutdown();
708692
}
693+
else
694+
{
695+
// We successfully connected
696+
// Timeout receiving NTRIP data, retry the NTRIP client connection
697+
if (online.rtc && online.gnss)
698+
{
699+
int hours;
700+
int minutes;
701+
int seconds;
702+
703+
seconds = rtc.getLocalEpoch() % SECONDS_IN_A_DAY;
704+
hours = seconds / SECONDS_IN_AN_HOUR;
705+
seconds -= hours * SECONDS_IN_AN_HOUR;
706+
minutes = seconds / SECONDS_IN_A_MINUTE;
707+
seconds -= minutes * SECONDS_IN_A_MINUTE;
708+
systemPrintf("NTRIP Client connected to %s:%d at %d:%02d:%02d\r\n",
709+
settings.ntripClient_CasterHost, settings.ntripClient_CasterPort, hours, minutes,
710+
seconds);
711+
}
712+
else
713+
systemPrintf("NTRIP Client connected to %s:%d\r\n", settings.ntripClient_CasterHost,
714+
settings.ntripClient_CasterPort);
715+
716+
// Connection is now open, start the NTRIP receive data timer
717+
ntripClientTimer = millis();
718+
719+
if (settings.ntripClient_TransmitGGA == true)
720+
{
721+
// Set the Main Talker ID to "GP". The NMEA GGA messages will be GPGGA instead of GNGGA
722+
theGNSS.setVal8(UBLOX_CFG_NMEA_MAINTALKERID, 1);
723+
theGNSS.setNMEAGPGGAcallbackPtr(&pushGPGGA); // Set up the callback for GPGGA
724+
725+
float measurementFrequency = (1000.0 / settings.measurementRate) / settings.navigationRate;
726+
if (measurementFrequency < 0.2)
727+
measurementFrequency = 0.2; // 0.2Hz * 5 = 1 measurement every 5 seconds
728+
log_d("Adjusting GGA setting to %f", measurementFrequency);
729+
theGNSS.setVal8(
730+
UBLOX_CFG_MSGOUT_NMEA_ID_GGA_I2C,
731+
measurementFrequency); // Enable GGA over I2C. Tell the module to output GGA every second
732+
733+
lastGGAPush =
734+
millis() - NTRIPCLIENT_MS_BETWEEN_GGA; // Force immediate transmission of GGA message
735+
}
709736

710-
// We don't use a task because we use I2C hardware (and don't have a semphore).
711-
online.ntripClient = true;
712-
ntripClientStartTime = millis();
713-
ntripClientSetState(NTRIP_CLIENT_CONNECTED);
737+
// We don't use a task because we use I2C hardware (and don't have a semphore).
738+
online.ntripClient = true;
739+
ntripClientStartTime = millis();
740+
ntripClientSetState(NTRIP_CLIENT_CONNECTED);
741+
}
714742
}
715743
else if (strstr(response, "401") != nullptr)
716744
{
@@ -722,31 +750,13 @@ void ntripClientUpdate()
722750
// Stop NTRIP client operations
723751
ntripClientShutdown();
724752
}
725-
else if (strstr(response, "banned") != nullptr)
726-
{
727-
// Look for 'HTTP/1.1 200 OK' and banned IP information
728-
systemPrintf("NTRIP Client connected to caster but caster responded with problem: %s\r\n", response);
729-
730-
// Stop NTRIP client operations
731-
ntripClientShutdown();
732-
}
733-
else if (strstr(response, "SOURCETABLE") != nullptr)
734-
{
735-
// Look for 'SOURCETABLE 200 OK'
736-
systemPrintf("Caster may not have mountpoint %s. Caster responded with problem: %s\r\n",
737-
settings.ntripClient_MountPoint, response);
738-
739-
// Stop NTRIP client operations
740-
ntripClientShutdown();
741-
}
742753
// Other errors returned by the caster
743754
else
744755
{
745756
systemPrintf("NTRIP Client connected but caster responded with problem: %s\r\n", response);
746757

747-
// Check for connection limit
748-
if (ntripClientConnectLimitReached())
749-
systemPrintln("NTRIP Client retry limit reached; do you have your caster address and port correct?");
758+
// Stop NTRIP client operations
759+
ntripClientShutdown();
750760
}
751761
}
752762
break;

0 commit comments

Comments
 (0)