From e16fab84065ff378848a26d0cc46219aba55997c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Kosson?= Date: Sat, 27 Sep 2025 10:53:33 +0200 Subject: [PATCH] Add WiFi/BT toggle for screenless devices --- src/input/InputBroker.h | 1 + src/main.cpp | 2 +- src/modules/SystemCommandsModule.cpp | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/input/InputBroker.h b/src/input/InputBroker.h index 2cdfa2ae2..61e0fd568 100644 --- a/src/input/InputBroker.h +++ b/src/input/InputBroker.h @@ -18,6 +18,7 @@ enum input_broker_event { INPUT_BROKER_ALT_LONG, INPUT_BROKER_SHUTDOWN = 0x9b, INPUT_BROKER_GPS_TOGGLE = 0x9e, + INPUT_BROKER_BT_WIFI_TOGGLE = 0x9f, INPUT_BROKER_SEND_PING = 0xaf, INPUT_BROKER_MATRIXKEY = 0xFE, INPUT_BROKER_ANYKEY = 0xff diff --git a/src/main.cpp b/src/main.cpp index 38c8e8ca5..f353c1b48 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1123,7 +1123,7 @@ void setup() mainDelay.interruptFromISR(&higherWake); }; userConfigNoScreen.singlePress = INPUT_BROKER_USER_PRESS; - userConfigNoScreen.longPress = INPUT_BROKER_NONE; + userConfigNoScreen.longPress = INPUT_BROKER_BT_WIFI_TOGGLE; userConfigNoScreen.longPressTime = 500; userConfigNoScreen.longLongPress = INPUT_BROKER_SHUTDOWN; userConfigNoScreen.doublePress = INPUT_BROKER_SEND_PING; diff --git a/src/modules/SystemCommandsModule.cpp b/src/modules/SystemCommandsModule.cpp index 74b9678f4..a7ac95f83 100644 --- a/src/modules/SystemCommandsModule.cpp +++ b/src/modules/SystemCommandsModule.cpp @@ -101,6 +101,22 @@ int SystemCommandsModule::handleInputEvent(const InputEvent *event) } #endif return true; + case INPUT_BROKER_BT_WIFI_TOGGLE: + if (config.network.wifi_enabled) + { + LOG_WARN("Disabling WiFi, enabling BT"); + config.network.wifi_enabled = false; + config.bluetooth.enabled = true; + } + else + { + LOG_WARN("Enabling WiFi, disabling BT"); + config.network.wifi_enabled = true; + config.bluetooth.enabled = false; + } + nodeDB->saveToDisk(); + rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000); + return 0; // Mesh ping case INPUT_BROKER_SEND_PING: service->refreshLocalMeshNode();