Add WiFi/BT toggle for screenless devices

This commit is contained in:
Łukasz Kosson 2025-09-27 10:53:33 +02:00
parent a2d86454d3
commit e16fab8406
3 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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;

View File

@ -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();