@@ -441,6 +441,82 @@ static bool wifiStationRunning;
441
441
static int wifiFailedConnectionAttempts = 0 ; // Count the number of connection attempts between restarts
442
442
static WiFiMulti *wifiMulti;
443
443
444
+ // *********************************************************************
445
+ // Set WiFi credentials
446
+ // Enable TCP connections
447
+ void menuWiFi ()
448
+ {
449
+ while (1 )
450
+ {
451
+ networkDisplayInterface (NETWORK_WIFI);
452
+
453
+ systemPrintln ();
454
+ systemPrintln (" Menu: WiFi Networks" );
455
+
456
+ for (int x = 0 ; x < MAX_WIFI_NETWORKS; x++)
457
+ {
458
+ systemPrintf (" %d) SSID %d: %s\r\n " , (x * 2 ) + 1 , x + 1 , settings.wifiNetworks [x].ssid );
459
+ systemPrintf (" %d) Password %d: %s\r\n " , (x * 2 ) + 2 , x + 1 , settings.wifiNetworks [x].password );
460
+ }
461
+
462
+ systemPrint (" a) Configure device via WiFi Access Point or connect to WiFi: " );
463
+ systemPrintf (" %s\r\n " , settings.wifiConfigOverAP ? " AP" : " WiFi" );
464
+
465
+ systemPrint (" c) Captive Portal: " );
466
+ systemPrintf (" %s\r\n " , settings.enableCaptivePortal ? " Enabled" : " Disabled" );
467
+
468
+ systemPrintln (" x) Exit" );
469
+
470
+ byte incoming = getUserInputCharacterNumber ();
471
+
472
+ if (incoming >= 1 && incoming <= MAX_WIFI_NETWORKS * 2 )
473
+ {
474
+ int arraySlot = ((incoming - 1 ) / 2 ); // Adjust incoming to array starting at 0
475
+
476
+ if (incoming % 2 == 1 )
477
+ {
478
+ systemPrintf (" Enter SSID network %d: " , arraySlot + 1 );
479
+ getUserInputString (settings.wifiNetworks [arraySlot].ssid ,
480
+ sizeof (settings.wifiNetworks [arraySlot].ssid ));
481
+ restartWiFi = true ; // If we are modifying the SSID table, force restart of WiFi
482
+ }
483
+ else
484
+ {
485
+ systemPrintf (" Enter Password for %s: " , settings.wifiNetworks [arraySlot].ssid );
486
+ getUserInputString (settings.wifiNetworks [arraySlot].password ,
487
+ sizeof (settings.wifiNetworks [arraySlot].password ));
488
+ restartWiFi = true ; // If we are modifying the SSID table, force restart of WiFi
489
+ }
490
+ }
491
+ else if (incoming == ' a' )
492
+ {
493
+ settings.wifiConfigOverAP ^= 1 ;
494
+ restartWiFi = true ;
495
+ }
496
+ else if (incoming == ' c' )
497
+ {
498
+ settings.enableCaptivePortal ^= 1 ;
499
+ }
500
+ else if (incoming == ' x' )
501
+ break ;
502
+ else if (incoming == INPUT_RESPONSE_GETCHARACTERNUMBER_EMPTY)
503
+ break ;
504
+ else if (incoming == INPUT_RESPONSE_GETCHARACTERNUMBER_TIMEOUT)
505
+ break ;
506
+ else
507
+ printUnknown (incoming);
508
+ }
509
+
510
+ // Erase passwords from empty SSID entries
511
+ for (int x = 0 ; x < MAX_WIFI_NETWORKS; x++)
512
+ {
513
+ if (strlen (settings.wifiNetworks [x].ssid ) == 0 )
514
+ strcpy (settings.wifiNetworks [x].password , " " );
515
+ }
516
+
517
+ clearBuffer (); // Empty buffer of any newline chars
518
+ }
519
+
444
520
// *********************************************************************
445
521
// Display the WiFi state
446
522
void wifiDisplayState ()
@@ -2659,83 +2735,6 @@ void RTK_WIFI::verifyTables()
2659
2735
// WiFi Routines
2660
2736
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2661
2737
2662
- // ----------------------------------------
2663
- // Set WiFi credentials
2664
- // Enable TCP connections
2665
- // ----------------------------------------
2666
- void menuWiFi ()
2667
- {
2668
- while (1 )
2669
- {
2670
- networkDisplayInterface (NETWORK_WIFI);
2671
-
2672
- systemPrintln ();
2673
- systemPrintln (" Menu: WiFi Networks" );
2674
-
2675
- for (int x = 0 ; x < MAX_WIFI_NETWORKS; x++)
2676
- {
2677
- systemPrintf (" %d) SSID %d: %s\r\n " , (x * 2 ) + 1 , x + 1 , settings.wifiNetworks [x].ssid );
2678
- systemPrintf (" %d) Password %d: %s\r\n " , (x * 2 ) + 2 , x + 1 , settings.wifiNetworks [x].password );
2679
- }
2680
-
2681
- systemPrint (" a) Configure device via WiFi Access Point or connect to WiFi: " );
2682
- systemPrintf (" %s\r\n " , settings.wifiConfigOverAP ? " AP" : " WiFi" );
2683
-
2684
- systemPrint (" c) Captive Portal: " );
2685
- systemPrintf (" %s\r\n " , settings.enableCaptivePortal ? " Enabled" : " Disabled" );
2686
-
2687
- systemPrintln (" x) Exit" );
2688
-
2689
- byte incoming = getUserInputCharacterNumber ();
2690
-
2691
- if (incoming >= 1 && incoming <= MAX_WIFI_NETWORKS * 2 )
2692
- {
2693
- int arraySlot = ((incoming - 1 ) / 2 ); // Adjust incoming to array starting at 0
2694
-
2695
- if (incoming % 2 == 1 )
2696
- {
2697
- systemPrintf (" Enter SSID network %d: " , arraySlot + 1 );
2698
- getUserInputString (settings.wifiNetworks [arraySlot].ssid ,
2699
- sizeof (settings.wifiNetworks [arraySlot].ssid ));
2700
- restartWiFi = true ; // If we are modifying the SSID table, force restart of WiFi
2701
- }
2702
- else
2703
- {
2704
- systemPrintf (" Enter Password for %s: " , settings.wifiNetworks [arraySlot].ssid );
2705
- getUserInputString (settings.wifiNetworks [arraySlot].password ,
2706
- sizeof (settings.wifiNetworks [arraySlot].password ));
2707
- restartWiFi = true ; // If we are modifying the SSID table, force restart of WiFi
2708
- }
2709
- }
2710
- else if (incoming == ' a' )
2711
- {
2712
- settings.wifiConfigOverAP ^= 1 ;
2713
- restartWiFi = true ;
2714
- }
2715
- else if (incoming == ' c' )
2716
- {
2717
- settings.enableCaptivePortal ^= 1 ;
2718
- }
2719
- else if (incoming == ' x' )
2720
- break ;
2721
- else if (incoming == INPUT_RESPONSE_GETCHARACTERNUMBER_EMPTY)
2722
- break ;
2723
- else if (incoming == INPUT_RESPONSE_GETCHARACTERNUMBER_TIMEOUT)
2724
- break ;
2725
- else
2726
- printUnknown (incoming);
2727
- }
2728
-
2729
- // Erase passwords from empty SSID entries
2730
- for (int x = 0 ; x < MAX_WIFI_NETWORKS; x++)
2731
- {
2732
- if (strlen (settings.wifiNetworks [x].ssid ) == 0 )
2733
- strcpy (settings.wifiNetworks [x].password , " " );
2734
- }
2735
-
2736
- clearBuffer (); // Empty buffer of any newline chars
2737
- }
2738
-
2739
2738
// ----------------------------------------
2740
2739
// Starts WiFi in STA, AP, or STA_AP mode depending on bools
2741
2740
// Returns true if STA connects, or if AP is started
0 commit comments