Skip to content

Commit 6824306

Browse files
committed
Fix NTRIP Server
Add strlen() check of response Fix RTCM packet counting if checker turned off Add RSSI print during NTRIP I believe the NTRIP_SERVER_AUTHORIZATION was failing because the ntripServer->available() needs to be large enough for an ICY 200 OK check. Additionally, an AP that correctly forward port 2101 is needed. RTCM counting was not working if the checker was turned off. Fix: if checker is disabled, RTCM count is increased with every byte.
1 parent 7643497 commit 6824306

File tree

3 files changed

+44
-30
lines changed

3 files changed

+44
-30
lines changed

Firmware/RTK_Surveyor/NtripClient.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,10 @@ void ntripClientUpdate()
452452
}
453453
}
454454

455-
if (millis() - lastRSSIUpdate > 5000)
455+
if (millis() - lastWifiRSSIUpdate > 5000)
456456
{
457-
lastRSSIUpdate = millis();
458-
Serial.printf("WiFi RSSI: %d\n\r", WiFi.RSSI());
457+
lastWifiRSSIUpdate = millis();
458+
Serial.printf("NTRIP WiFi RSSI: %d\n\r", WiFi.RSSI());
459459
}
460460

461461
break;

Firmware/RTK_Surveyor/NtripServer.ino

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2-
NTRIP Server States:
2+
NTRIP Server States:
33
NTRIP_SERVER_OFF: Using Bluetooth or NTRIP server
44
NTRIP_SERVER_ON: WIFI_ON state
55
NTRIP_SERVER_WIFI_CONNECTING: Connecting to WiFi access point
@@ -44,7 +44,7 @@ NTRIP Server States:
4444
| | Close Server connection
4545
'------------------'
4646
47-
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
47+
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4848

4949
//----------------------------------------
5050
// Constants - compiled out
@@ -99,7 +99,7 @@ bool ntripServerConnectCaster()
9999

100100
//Note the connection to the NTRIP caster
101101
Serial.printf("Connected to %s:%d\n\r", settings.ntripServer_CasterHost,
102-
settings.ntripServer_CasterPort);
102+
settings.ntripServer_CasterPort);
103103

104104
//Build the authorization credentials message
105105
// * Mount point
@@ -192,10 +192,10 @@ bool ntripServerRtcmMessage(uint8_t data)
192192
//Wait for the preamble byte
193193
ntripServerCrcState = RTCM_TRANSPORT_STATE_WAIT_FOR_PREAMBLE_D3;
194194

195-
//Fall through
196-
// |
197-
// |
198-
// V
195+
//Fall through
196+
// |
197+
// |
198+
// V
199199

200200
//Wait for the preamble byte (0xd3)
201201
case RTCM_TRANSPORT_STATE_WAIT_FOR_PREAMBLE_D3:
@@ -368,8 +368,16 @@ void ntripServerProcessRTCM(uint8_t incoming)
368368
}
369369
previousMilliseconds = currentMilliseconds;
370370

371-
//Parse the RTCM message
372-
if ((!settings.enableNtripServerMessageParsing) || ntripServerRtcmMessage(incoming))
371+
//Pass this message to the RTCM checker
372+
bool passAlongIncomingByte = true;
373+
374+
//Check this byte with RTCM checker if enabled
375+
if (settings.enableNtripServerMessageParsing == true)
376+
passAlongIncomingByte &= ntripServerRtcmMessage(incoming);
377+
else
378+
rtcmPacketsSent++; //If not checking RTCM CRC, count every byte
379+
380+
if (passAlongIncomingByte)
373381
{
374382
ntripServer->write(incoming); //Send this byte to socket
375383
ntripServerBytesSent++;
@@ -396,7 +404,7 @@ void ntripServerStart()
396404

397405
//Start the NTRIP server if enabled
398406
if ((settings.ntripServer_StartAtSurveyIn == true)
399-
|| (settings.enableNtripServer == true))
407+
|| (settings.enableNtripServer == true))
400408
{
401409
//Display the heap state
402410
reportHeapNow();
@@ -487,7 +495,7 @@ void ntripServerUpdate()
487495
ntripServerSetState(NTRIP_SERVER_WIFI_CONNECTED);
488496

489497
// Start the SD card server
490-
// sdCardServerBegin(&server, true, true);
498+
// sdCardServerBegin(&server, true, true);
491499
}
492500
break;
493501

@@ -510,27 +518,27 @@ void ntripServerUpdate()
510518

511519
//Initiate the connection to the NTRIP caster
512520
case NTRIP_SERVER_CONNECTING:
513-
//Attempt a connection to the NTRIP caster
514-
if (!ntripServerConnectCaster())
515-
{
516-
log_d("NTRIP Server caster failed to connect. Trying again.");
521+
//Attempt a connection to the NTRIP caster
522+
if (!ntripServerConnectCaster())
523+
{
524+
log_d("NTRIP Server caster failed to connect. Trying again.");
517525

518-
//Assume service not available
519-
if (ntripServerConnectLimitReached())
520-
Serial.println("NTRIP Server failed to connect! Do you have your caster address and port correct?");
521-
}
522-
else
523-
{
524-
//Connection open to NTRIP caster, wait for the authorization response
525-
ntripServerTimer = millis();
526-
ntripServerSetState(NTRIP_SERVER_AUTHORIZATION);
527-
}
526+
//Assume service not available
527+
if (ntripServerConnectLimitReached())
528+
Serial.println("NTRIP Server failed to connect! Do you have your caster address and port correct?");
529+
}
530+
else
531+
{
532+
//Connection open to NTRIP caster, wait for the authorization response
533+
ntripServerTimer = millis();
534+
ntripServerSetState(NTRIP_SERVER_AUTHORIZATION);
535+
}
528536
break;
529537

530538
//Wait for authorization response
531539
case NTRIP_SERVER_AUTHORIZATION:
532540
//Check if caster service responded
533-
if (ntripServer->available() == 0)
541+
if (ntripServer->available() < strlen("ICY 200 OK")) //Wait until at least a few bytes have arrived
534542
{
535543
//Check for response timeout
536544
if (millis() - ntripServerTimer > 5000)
@@ -590,6 +598,12 @@ void ntripServerUpdate()
590598
}
591599
else
592600
cyclePositionLEDs();
601+
602+
if (millis() - lastWifiRSSIUpdate > 5000)
603+
{
604+
lastWifiRSSIUpdate = millis();
605+
Serial.printf("NTRIP WiFi RSSI: %d\n\r", WiFi.RSSI());
606+
}
593607
break;
594608
}
595609
#endif //COMPILE_WIFI

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ unsigned long rtcWaitTime = 0; //At poweron, we give the RTC a few seconds to up
454454
TaskHandle_t idleTaskHandle[MAX_CPU_CORES];
455455
uint32_t max_idle_count = MAX_IDLE_TIME_COUNT;
456456

457-
unsigned long lastRSSIUpdate = 0; //Print RSSI when connected every few seconds
457+
unsigned long lastWifiRSSIUpdate = 0; //Print RSSI when connected every few seconds
458458

459459
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
460460
/*

0 commit comments

Comments
 (0)