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
0 commit comments