File tree Expand file tree Collapse file tree 5 files changed +35
-13
lines changed Expand file tree Collapse file tree 5 files changed +35
-13
lines changed Original file line number Diff line number Diff line change @@ -343,7 +343,8 @@ void gnssFirmwareBeginUpdate()
343343 serialGNSS->begin (serialBaud, SERIAL_8N1, pin_GnssUart_RX, pin_GnssUart_TX);
344344
345345 // Echo everything to/from GNSS
346- while (1 )
346+ task.endDirectConnectMode = false ;
347+ while (!task.endDirectConnectMode )
347348 {
348349 static unsigned long lastSerial = millis (); // Temporary fix for buttonless Flex
349350
@@ -356,7 +357,7 @@ void gnssFirmwareBeginUpdate()
356357 if (serialGNSS->available ()) // Note: use if, not while
357358 Serial.write (serialGNSS->read ());
358359
359- // Button task will gnssFirmwareRemoveUpdate and restart
360+ // Button task will set task.endDirectConnectMode true
360361
361362 // Temporary fix for buttonless Flex. TODO - remove
362363 if ((productVariant == RTK_FLEX) && ((millis () - lastSerial) > 30000 ))
@@ -378,6 +379,13 @@ void gnssFirmwareBeginUpdate()
378379 ESP.restart ();
379380 }
380381 }
382+
383+ // Remove all the special file. See #763 . Do the file removal in the loop
384+ gnssFirmwareRemoveUpdate ();
385+
386+ systemFlush (); // Complete prints
387+
388+ ESP.restart ();
381389}
382390
383391// ----------------------------------------
Original file line number Diff line number Diff line change @@ -2101,7 +2101,8 @@ void um980FirmwareBeginUpdate()
21012101 bool inBootMode = false ;
21022102
21032103 // Echo everything to/from UM980
2104- while (1 )
2104+ task.endDirectConnectMode = false ;
2105+ while (!task.endDirectConnectMode )
21052106 {
21062107 // Data coming from UM980 to external USB
21072108 if (serialGNSS->available ()) // Note: use if, not while
@@ -2129,8 +2130,15 @@ void um980FirmwareBeginUpdate()
21292130 }
21302131 }
21312132
2132- // Button task will um980FirmwareRemoveUpdate and restart
2133+ // Button task will set task.endDirectConnectMode true
21332134 }
2135+
2136+ // Remove the special file. See #763 . Do the file removal in the loop
2137+ um980FirmwareRemoveUpdate ();
2138+
2139+ systemFlush (); // Complete prints
2140+
2141+ ESP.restart ();
21342142}
21352143
21362144// ----------------------------------------
@@ -2146,7 +2154,7 @@ bool um980FirmwareCheckUpdate()
21462154// ----------------------------------------
21472155void um980FirmwareRemoveUpdate ()
21482156{
2149- return gnssFirmwareRemoveUpdateFile (" /updateUm980Firmware.txt" );
2157+ gnssFirmwareRemoveUpdateFile (" /updateUm980Firmware.txt" );
21502158}
21512159
21522160// ----------------------------------------
Original file line number Diff line number Diff line change @@ -554,7 +554,8 @@ void beginLoraFirmwareUpdate()
554554
555555 // Push any incoming ESP32 UART0 to UART1 or UART2 and vice versa
556556 // Infinite loop until button is pressed
557- while (1 )
557+ task.endDirectConnectMode = false ;
558+ while (!task.endDirectConnectMode )
558559 {
559560 static unsigned long lastSerial = millis (); // Temporary fix for buttonless Flex
560561
@@ -567,7 +568,7 @@ void beginLoraFirmwareUpdate()
567568 if (serialGNSS->available ()) // Note: use if, not while
568569 Serial.write (serialGNSS->read ());
569570
570- // Button task will removeUpdateLoraFirmware and restart
571+ // Button task will set task.endDirectConnectMode true
571572
572573 // Temporary fix for buttonless Flex. TODO - remove
573574 if ((productVariant == RTK_FLEX) && ((millis () - lastSerial) > 30000 ))
@@ -589,6 +590,13 @@ void beginLoraFirmwareUpdate()
589590 ESP.restart ();
590591 }
591592 }
593+
594+ // Remove the special file. See #763 . Do the file removal in the loop
595+ removeUpdateLoraFirmware ();
596+
597+ systemFlush (); // Complete prints
598+
599+ ESP.restart ();
592600}
593601
594602void loraSetupTransmit ()
Original file line number Diff line number Diff line change @@ -2077,15 +2077,11 @@ void buttonCheckTask(void *e)
20772077 delay (300 );
20782078 beepOff ();
20792079
2080- // Remove all the special files
2081- removeUpdateLoraFirmware ();
2082- um980FirmwareRemoveUpdate ();
2083- gnssFirmwareRemoveUpdate ();
2084-
20852080 systemPrintln (" Exiting direct connection (passthrough) mode" );
20862081 systemFlush (); // Complete prints
20872082
2088- ESP.restart ();
2083+ // See #763 . Do the file removal in the loop
2084+ task.endDirectConnectMode = true ; // Indicate to loop that direct connection should be ended
20892085 }
20902086 }
20912087 // Torch is a special case. Handle tilt stop and web config mode
Original file line number Diff line number Diff line change @@ -2148,6 +2148,8 @@ struct struct_tasks
21482148 bool sdSizeCheckTaskStopRequest = false ;
21492149 bool updatePplTaskStopRequest = false ;
21502150 bool updateWebServerTaskStopRequest = false ;
2151+
2152+ volatile bool endDirectConnectMode = false ; // Set true by e.g. button task
21512153} task;
21522154
21532155#ifdef COMPILE_NETWORK
You can’t perform that action at this time.
0 commit comments