Skip to content

Commit e16fab8

Browse files
committed
Add WiFi/BT toggle for screenless devices
1 parent a2d8645 commit e16fab8

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/input/InputBroker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ enum input_broker_event {
1818
INPUT_BROKER_ALT_LONG,
1919
INPUT_BROKER_SHUTDOWN = 0x9b,
2020
INPUT_BROKER_GPS_TOGGLE = 0x9e,
21+
INPUT_BROKER_BT_WIFI_TOGGLE = 0x9f,
2122
INPUT_BROKER_SEND_PING = 0xaf,
2223
INPUT_BROKER_MATRIXKEY = 0xFE,
2324
INPUT_BROKER_ANYKEY = 0xff

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ void setup()
11231123
mainDelay.interruptFromISR(&higherWake);
11241124
};
11251125
userConfigNoScreen.singlePress = INPUT_BROKER_USER_PRESS;
1126-
userConfigNoScreen.longPress = INPUT_BROKER_NONE;
1126+
userConfigNoScreen.longPress = INPUT_BROKER_BT_WIFI_TOGGLE;
11271127
userConfigNoScreen.longPressTime = 500;
11281128
userConfigNoScreen.longLongPress = INPUT_BROKER_SHUTDOWN;
11291129
userConfigNoScreen.doublePress = INPUT_BROKER_SEND_PING;

src/modules/SystemCommandsModule.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,22 @@ int SystemCommandsModule::handleInputEvent(const InputEvent *event)
101101
}
102102
#endif
103103
return true;
104+
case INPUT_BROKER_BT_WIFI_TOGGLE:
105+
if (config.network.wifi_enabled)
106+
{
107+
LOG_WARN("Disabling WiFi, enabling BT");
108+
config.network.wifi_enabled = false;
109+
config.bluetooth.enabled = true;
110+
}
111+
else
112+
{
113+
LOG_WARN("Enabling WiFi, disabling BT");
114+
config.network.wifi_enabled = true;
115+
config.bluetooth.enabled = false;
116+
}
117+
nodeDB->saveToDisk();
118+
rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
119+
return 0;
104120
// Mesh ping
105121
case INPUT_BROKER_SEND_PING:
106122
service->refreshLocalMeshNode();

0 commit comments

Comments
 (0)