@@ -470,7 +470,7 @@ void ntripServerProcessRTCM(int serverIndex, uint8_t incoming)
470
470
// Indicate that the GNSS is providing correction data
471
471
else if (ntripServer->state == NTRIP_SERVER_WAIT_GNSS_DATA)
472
472
{
473
- ntripServerSetState (ntripServer , NTRIP_SERVER_CONNECTING);
473
+ ntripServerSetState (serverIndex , NTRIP_SERVER_CONNECTING);
474
474
}
475
475
}
476
476
@@ -509,20 +509,11 @@ void ntripServerRestart(int serverIndex)
509
509
// ----------------------------------------
510
510
// Update the state of the NTRIP server state machine
511
511
// ----------------------------------------
512
- void ntripServerSetState (NTRIP_SERVER_DATA *ntripServer , uint8_t newState)
512
+ void ntripServerSetState (int serverIndex , uint8_t newState)
513
513
{
514
- int serverIndex;
515
- for (serverIndex = 0 ; serverIndex < NTRIP_SERVER_MAX; serverIndex++)
516
- {
517
- if (ntripServer == &ntripServerArray[serverIndex])
518
- serverIndex = serverIndex;
519
- }
520
- if (serverIndex >= NTRIP_SERVER_MAX)
521
- {
522
- systemPrintf (" NTRIP Server: %p unknown NTRIP Server structure!\r\n " , (void *)ntripServer);
523
- return ;
524
- }
514
+ NTRIP_SERVER_DATA * ntripServer;
525
515
516
+ ntripServer = &ntripServerArray[serverIndex];
526
517
if (settings.debugNtripServerState )
527
518
{
528
519
if (ntripServer->state == newState)
@@ -606,7 +597,7 @@ void ntripServerStop(int serverIndex, bool shutdown)
606
597
if (settings.debugNtripServerState && (!settings.ntripServer_MountPoint [serverIndex][0 ]))
607
598
systemPrintf (" NTRIP Server %d mount point not configured!\r\n " , serverIndex);
608
599
networkConsumerRemove (NETWORK_CONSUMER (serverIndex), NETWORK_ANY, __FILE__, __LINE__);
609
- ntripServerSetState (ntripServer , NTRIP_SERVER_OFF);
600
+ ntripServerSetState (serverIndex , NTRIP_SERVER_OFF);
610
601
ntripServer->connectionAttempts = 0 ;
611
602
ntripServer->connectionAttemptTimeout = 0 ;
612
603
@@ -623,7 +614,7 @@ void ntripServerStop(int serverIndex, bool shutdown)
623
614
{
624
615
if (settings.debugNtripServerState )
625
616
systemPrintf (" ntripServerStop server %d start requested\r\n " , serverIndex);
626
- ntripServerSetState (ntripServer, NTRIP_SERVER_ON );
617
+ ntripServerSetState (serverIndex, NTRIP_SERVER_WAIT_FOR_NETWORK );
627
618
}
628
619
}
629
620
@@ -640,7 +631,8 @@ void ntripServerUpdate(int serverIndex)
640
631
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
641
632
642
633
// Shutdown the NTRIP server when the mode or setting changes
643
- DMW_ds (ntripServerSetState, ntripServer);
634
+ DMW_if
635
+ ntripServerSetState (serverIndex, ntripServer->state );
644
636
connected = networkConsumerIsConnected (NETWORK_CONSUMER (serverIndex));
645
637
enabled = ntripServerEnabled (serverIndex, &line);
646
638
if (!enabled && (ntripServer->state > NTRIP_SERVER_OFF))
@@ -661,7 +653,7 @@ void ntripServerUpdate(int serverIndex)
661
653
662
654
// Start the network
663
655
case NTRIP_SERVER_ON:
664
- ntripServerSetState (ntripServer , NTRIP_SERVER_WAIT_FOR_NETWORK);
656
+ ntripServerSetState (serverIndex , NTRIP_SERVER_WAIT_FOR_NETWORK);
665
657
break ;
666
658
667
659
// Wait for a network media connection
@@ -690,7 +682,7 @@ void ntripServerUpdate(int serverIndex)
690
682
691
683
// The network is available for the NTRIP server
692
684
networkUserAdd (NETWORK_CONSUMER (serverIndex), __FILE__, __LINE__);
693
- ntripServerSetState (ntripServer , NTRIP_SERVER_NETWORK_CONNECTED);
685
+ ntripServerSetState (serverIndex , NTRIP_SERVER_NETWORK_CONNECTED);
694
686
}
695
687
}
696
688
break ;
@@ -709,7 +701,7 @@ void ntripServerUpdate(int serverIndex)
709
701
rtcmPacketsSent = 0 ;
710
702
711
703
// Open socket to NTRIP caster
712
- ntripServerSetState (ntripServer , NTRIP_SERVER_WAIT_GNSS_DATA);
704
+ ntripServerSetState (serverIndex , NTRIP_SERVER_WAIT_GNSS_DATA);
713
705
}
714
706
break ;
715
707
@@ -736,7 +728,7 @@ void ntripServerUpdate(int serverIndex)
736
728
{
737
729
// Connection open to NTRIP caster, wait for the authorization response
738
730
ntripServer->timer = millis ();
739
- ntripServerSetState (ntripServer , NTRIP_SERVER_AUTHORIZATION);
731
+ ntripServerSetState (serverIndex , NTRIP_SERVER_AUTHORIZATION);
740
732
}
741
733
}
742
734
break ;
@@ -800,7 +792,7 @@ void ntripServerUpdate(int serverIndex)
800
792
// We don't use a task because we use I2C hardware (and don't have a semaphore).
801
793
online.ntripServer [serverIndex] = true ;
802
794
ntripServer->startTime = millis ();
803
- ntripServerSetState (ntripServer , NTRIP_SERVER_CASTING);
795
+ ntripServerSetState (serverIndex , NTRIP_SERVER_CASTING);
804
796
}
805
797
806
798
// Look for '401 Unauthorized'
0 commit comments