Skip to content

Commit 0aabc39

Browse files
committed
updates to Hello message from AgOpenGPS
only update last message time received from current AgOpenGPS IP switch to new AgOpenGPS IP Address when last Hello is more than 4 seconds ago when last Hello is more than 5 seconds ago, start broadcasting to 255
1 parent c5b2c10 commit 0aabc39

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

AOG_GPS_ESP32/src/headingAndPosition.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,9 @@ void headingAndPosition ( void* z ){
758758
else if( ( millis() - powerUnstableMillis ) / 60000 > 5){
759759
powerUnstable = false;
760760
}
761+
if( millis() - lastHelloReceivedMillis > 5000 ){
762+
ipDestination = IPAddress( 192, 168, 5, 255 );
763+
}
761764

762765
vTaskDelayUntil( &xLastWakeTime, xFrequency );
763766
}

AOG_GPS_ESP32/src/main.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,13 @@ void setup( void ) {
101101
switch( pgn ){
102102
case 32712: {
103103
// PGN32712, Hello from AgIO to module
104-
ipDestination = packet.remoteIP();
105-
lastHelloReceivedMillis = millis();
104+
IPAddress address = packet.remoteIP();
105+
if( ipDestination == address ){ // only send GPS to current AgOpenGPS
106+
lastHelloReceivedMillis = millis();
107+
} else if ( millis() - lastHelloReceivedMillis > 4000 ){ // AgOpenGPS Hello timed out
108+
ipDestination = address; // switch to new AgOpenGPS address
109+
lastHelloReceivedMillis = millis();
110+
}
106111
}
107112
break;
108113

0 commit comments

Comments
 (0)