From bb857a51b1a546881eff4f5ce084e04b19cd1e22 Mon Sep 17 00:00:00 2001 From: Pawel Jalocha Date: Mon, 21 Mar 2022 14:07:02 +0000 Subject: [PATCH] Fixed WiFi reconnect issue - before it would not connect the 2nd time --- main/aprs.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main/aprs.cpp b/main/aprs.cpp index 02b5c72..0d36348 100644 --- a/main/aprs.cpp +++ b/main/aprs.cpp @@ -80,7 +80,7 @@ static int APRS_RxMsg(const char *Msg) // Handle messages received from APRS return 0; } static int APRS_Dialog(void) // connect to APRS and talk to the server exchaging data -{ +{ uint32_t AcftID = Parameters.AcftID; // remember ID in case it changes int ConnErr=APRS_Socket.Connect(APRS_Host, APRS_Port); // connect to the APRS server if(ConnErr>=0) // if connection succesfull { uint8_t LoginLen = LoginLine(Line, 5); @@ -97,8 +97,9 @@ static int APRS_Dialog(void) // connect to APRS and talk to the se // APRS_Socket.setBlocking(0); int Write=APRS_Socket.Send(Line, LoginLen); // send login to the APRS server int LinePtr=0; - for( ; ; ) - { int Left = MaxLineLen-LinePtr; if(Left<128) break; // how much space left for receive data + for( ; ; ) // the dialog loop + { if(AcftID!=Parameters.AcftID) break; // stop when aircraft ID changes: we need to relogin + int Left = MaxLineLen-LinePtr; if(Left<128) break; // how much space left for receive data int Read=APRS_Socket.Receive(Line+LinePtr, Left-1); // read more data from the socket #ifdef DEBUG_PRINT if(Read<0) // if error then print it @@ -251,7 +252,7 @@ void vTaskAPRS(void* pvParameters) WIFI_IP.ip.addr = 0; WIFI_IP.gw.addr=0; for(uint8_t Idx=0; Idx<10; Idx++) // wait to obtain local IP from DHCP { vTaskDelay(1000); - if(WIFI_State.isConnected==1) break; + // if(WIFI_State.isConnected==1) break; if(WIFI_getLocalIP()) { if(WIFI_IP.ip.addr && WIFI_IP.gw.addr) break; } }