mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-14 14:52:32 +00:00
Add WiFi Toggle to System frame to re-enable (#8802)
Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
This commit is contained in:
@@ -576,7 +576,7 @@ void menuHandler::textMessageBaseMenu()
|
||||
|
||||
void menuHandler::systemBaseMenu()
|
||||
{
|
||||
enum optionsNumbers { Back, Notifications, ScreenOptions, Bluetooth, PowerMenu, Test, enumEnd };
|
||||
enum optionsNumbers { Back, Notifications, ScreenOptions, Bluetooth, WiFiToggle, PowerMenu, Test, enumEnd };
|
||||
static const char *optionsArray[enumEnd] = {"Back"};
|
||||
static int optionsEnumArray[enumEnd] = {Back};
|
||||
int options = 1;
|
||||
@@ -592,6 +592,10 @@ void menuHandler::systemBaseMenu()
|
||||
optionsArray[options] = "Bluetooth Toggle";
|
||||
#endif
|
||||
optionsEnumArray[options++] = Bluetooth;
|
||||
#if HAS_WIFI && !defined(ARCH_PORTDUINO)
|
||||
optionsArray[options] = "WiFi Toggle";
|
||||
optionsEnumArray[options++] = WiFiToggle;
|
||||
#endif
|
||||
#if defined(M5STACK_UNITC6L)
|
||||
optionsArray[options] = "Power";
|
||||
#else
|
||||
@@ -629,6 +633,11 @@ void menuHandler::systemBaseMenu()
|
||||
} else if (selected == Bluetooth) {
|
||||
menuQueue = bluetooth_toggle_menu;
|
||||
screen->runNow();
|
||||
#if HAS_WIFI && !defined(ARCH_PORTDUINO)
|
||||
} else if (selected == WiFiToggle) {
|
||||
menuQueue = wifi_toggle_menu;
|
||||
screen->runNow();
|
||||
#endif
|
||||
} else if (selected == Back && !test_enabled) {
|
||||
test_count++;
|
||||
if (test_count > 4) {
|
||||
@@ -1278,19 +1287,28 @@ void menuHandler::wifiBaseMenu()
|
||||
|
||||
void menuHandler::wifiToggleMenu()
|
||||
{
|
||||
enum optionsNumbers { Back, Wifi_toggle };
|
||||
enum optionsNumbers { Back, Wifi_disable, Wifi_enable };
|
||||
|
||||
static const char *optionsArray[] = {"Back", "Disable"};
|
||||
static const char *optionsArray[] = {"Back", "WiFi Disabled", "WiFi Enabled"};
|
||||
BannerOverlayOptions bannerOptions;
|
||||
bannerOptions.message = "Disable Wifi and\nEnable Bluetooth?";
|
||||
bannerOptions.message = "WiFi Actions";
|
||||
bannerOptions.optionsArrayPtr = optionsArray;
|
||||
bannerOptions.optionsCount = 2;
|
||||
bannerOptions.optionsCount = 3;
|
||||
if (config.network.wifi_enabled == true)
|
||||
bannerOptions.InitialSelected = 2;
|
||||
else
|
||||
bannerOptions.InitialSelected = 1;
|
||||
bannerOptions.bannerCallback = [](int selected) -> void {
|
||||
if (selected == Wifi_toggle) {
|
||||
if (selected == Wifi_disable) {
|
||||
config.network.wifi_enabled = false;
|
||||
config.bluetooth.enabled = true;
|
||||
service->reloadConfig(SEGMENT_CONFIG);
|
||||
rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
|
||||
} else if (selected == Wifi_enable) {
|
||||
config.network.wifi_enabled = true;
|
||||
config.bluetooth.enabled = false;
|
||||
service->reloadConfig(SEGMENT_CONFIG);
|
||||
rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
|
||||
}
|
||||
};
|
||||
screen->showOverlayBanner(bannerOptions);
|
||||
|
||||
Reference in New Issue
Block a user