1111 Set the board to "ESP32 Wrover Module"
1212
1313 Settings are pulled from ESP32's file system LittleFS.
14+
15+ Version history:
16+ 1.0: Initial release
17+ 1.1: Add TCP support
18+ The console can be accessed via TCP (COM3 is daisy chained to IPS1)
19+ On the v1.0 PCB, link:
20+ mosaic COM3 TX (TX3) to ESP32 GPIO 34
21+ mosaic COM3 RX (RX3) to ESP32 GPIO 23
1422*/
1523
1624// This is passed in from compiler extra flags
@@ -318,7 +326,7 @@ void setup()
318326{
319327 initializeGlobals (); // Initialize any global variables that can't be given default values
320328
321- beginConsole (false ); // UART0 for programming and debugging. Don't allow Alt pins to be used yet
329+ beginConsole (115200 , false ); // UART0 for programming and debugging. Don't allow Alt pins to be used yet
322330 systemPrintln ();
323331 systemPrintln ();
324332
@@ -382,8 +390,10 @@ void setup()
382390
383391 systemPrintf (" Boot time: %d\r\n " , millis ());
384392
385- serialConsole.flush (); // Complete any previous prints
386- beginConsole (true ); // Swap to Alt pins if TCP is enabled
393+ if (settings.enableTCPServer )
394+ systemPrintf (" TCP Server is enabled. Please connect on port %d to view the console\r\n " , settings.tcpServerPort );
395+
396+ beginConsole (115200 , true ); // Swap to Alt pins if TCP is enabled
387397}
388398
389399void loop ()
@@ -413,22 +423,30 @@ void loop()
413423// Once we have a fix, sync system clock to GNSS
414424void updateRTC ()
415425{
426+ static uint16_t syncAge = 0 ;
427+
416428 static bool firstTime = true ;
417429 if (firstTime)
418430 {
419431 gnssTimeUpdated[0 ] = false ; // This ensures gnssTimeUpdated[0] isn't stale
420432 firstTime = false ;
421433 }
422434
423- if (online.rtc == false ) // Only do this if the rtc has not been sync'd previously
435+ if (online.gnss == true ) // Only do this if the GNSS is online
424436 {
425- if (online. gnss == true ) // Only do this if the GNSS is online
437+ if (gnssTimeUpdated[ 0 ] ) // Only do this if we have fresh time
426438 {
427- if (gnssTimeUpdated[0 ])
428- {
429- gnssTimeUpdated[0 ] = false ;
439+ gnssTimeUpdated[0 ] = false ;
430440
431- if (gnssWNSet && gnssToWSet && gnssFineTime)
441+ syncAge++; // Update syncAge every second
442+ if (syncAge == 3600 ) // Wrap every hour
443+ syncAge = 0 ;
444+
445+ if (gnssWNSet && gnssToWSet && gnssFineTime) // Only do this if FineTime is set
446+ {
447+ // Only do this if the rtc has not been sync'd previously
448+ // or if it is an hour since the last sync
449+ if ((online.rtc == false ) || (syncAge == 0 ))
432450 {
433451 // To perform the time zone adjustment correctly, it's easiest if we convert the GNSS time and date
434452 // into Unix epoch first and then correct for the arrival time
@@ -443,11 +461,14 @@ void updateRTC()
443461
444462 online.rtc = true ;
445463
446- systemPrint (" System time set to: " );
447- systemPrintln (rtc.getDateTime (true ));
464+ if (settings.enablePrintRtcSync )
465+ {
466+ systemPrint (" System time set to: " );
467+ systemPrintln (rtc.getDateTime (true ));
468+ }
448469 }
449470 }
450- } // End online.gnss
451- } // End online.rtc
471+ }
472+ }
452473}
453474
0 commit comments