MUI: BT programming mode (#6046)

* allow BT connection with disabled MUI

* Update device-ui

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Manuel 2025-02-13 19:01:24 +01:00 committed by GitHub
parent 79c0e8168d
commit 2b1f45fd8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 40 additions and 20 deletions

@ -1 +1 @@
Subproject commit d0f0e5e286904913db9e2a05f43edcd45be7b29f
Subproject commit 83c0eb060d8ab15ae1073f22f2386ecd63d09480

View File

@ -422,13 +422,7 @@ bool NodeDB::resetRadioConfig(bool factory_reset)
rebootAtMsec = millis() + (5 * 1000);
}
#if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3)) && HAS_TFT
// as long as PhoneAPI shares BT and TFT app switch BT off
config.bluetooth.enabled = false;
if (moduleConfig.external_notification.nag_timeout == 60)
moduleConfig.external_notification.nag_timeout = 0;
#endif
LOG_ERROR("NodeDB::resetRadioConfig done %d", didFactoryReset);
return didFactoryReset;
}
@ -612,6 +606,13 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
#else
bool hasScreen = screen_found.port != ScanI2C::I2CPort::NO_I2C;
#endif
#if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3) || defined(INDICATOR)) && HAS_TFT
// as long as PhoneAPI shares BT and TFT app switch BT off
LOG_ERROR("config.bluetooth.enabled = false");
config.bluetooth.enabled = false;
if (moduleConfig.external_notification.nag_timeout == 60)
moduleConfig.external_notification.nag_timeout = 0;
#endif
#ifdef USERPREFS_FIXED_BLUETOOTH
config.bluetooth.fixed_pin = USERPREFS_FIXED_BLUETOOTH;
config.bluetooth.mode = meshtastic_Config_BluetoothConfig_PairingMode_FIXED_PIN;

View File

@ -16,11 +16,23 @@ PacketAPI *PacketAPI::create(PacketServer *_server)
return packetAPI;
}
PacketAPI::PacketAPI(PacketServer *_server) : concurrency::OSThread("PacketAPI"), isConnected(false), server(_server) {}
PacketAPI::PacketAPI(PacketServer *_server)
: concurrency::OSThread("PacketAPI"), isConnected(false), programmingMode(false), server(_server)
{
}
int32_t PacketAPI::runOnce()
{
bool success = sendPacket();
bool success = false;
if (config.bluetooth.enabled) {
if (!programmingMode) {
// in programmingMode we don't send any packets to the client except this one notify
programmingMode = true;
success = notifyProgrammingMode();
}
} else {
success = sendPacket();
}
success |= receivePacket();
return success ? 10 : 50;
}
@ -79,10 +91,6 @@ bool PacketAPI::sendPacket(void)
if (len != 0) {
static uint32_t id = 0;
fromRadioScratch.id = ++id;
// TODO: think about redesign or drop class MeshPacketServer
// if (typeid(*server) == typeid(MeshPacketServer))
// return dynamic_cast<MeshPacketServer*>(server)->sendPacket(fromRadioScratch);
// else
bool result = server->sendPacket(DataPacket<meshtastic_FromRadio>(id, fromRadioScratch));
if (!result) {
LOG_ERROR("send queue full");
@ -92,6 +100,18 @@ bool PacketAPI::sendPacket(void)
return false;
}
bool PacketAPI::notifyProgrammingMode(void)
{
// tell the client we are in programming mode by sending only the bluetooth config state
LOG_INFO("force client into programmingMode");
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
fromRadioScratch.id = nodeDB->getNodeNum();
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_tag;
fromRadioScratch.config.which_payload_variant = meshtastic_Config_bluetooth_tag;
fromRadioScratch.config.payload_variant.bluetooth = config.bluetooth;
return server->sendPacket(DataPacket<meshtastic_FromRadio>(0, fromRadioScratch));
}
/**
* return true if we got (once!) contact from our client and the server send queue is not full
*/

View File

@ -27,8 +27,10 @@ class PacketAPI : public PhoneAPI, public concurrency::OSThread
private:
bool receivePacket(void);
bool sendPacket(void);
bool notifyProgrammingMode(void);
bool isConnected;
bool programmingMode;
PacketServer *server;
uint8_t txBuf[MAX_TO_FROM_RADIO_SIZE] = {0}; // dummy buf to obey PhoneAPI
};

View File

@ -38,7 +38,6 @@ build_flags =
${env:seeed-sensecap-indicator.build_flags}
-D MESHTASTIC_EXCLUDE_CANNEDMESSAGES=1
-D MESHTASTIC_EXCLUDE_INPUTBROKER=1
-D MESHTASTIC_EXCLUDE_BLUETOOTH=1
-D MESHTASTIC_EXCLUDE_SCREEN=1
-D MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1
-D MESHTASTIC_EXCLUDE_WEBSERVER=1
@ -52,7 +51,7 @@ build_flags =
-D HAS_TFT=1
-D DISPLAY_SET_RESOLUTION
-D USE_I2S_BUZZER
-D RAM_SIZE=3072
-D RAM_SIZE=4096
-D LV_LVGL_H_INCLUDE_SIMPLE
-D LV_CONF_INCLUDE_SIMPLE
-D LV_COMP_CONF_INCLUDE_SIMPLE
@ -64,7 +63,6 @@ build_flags =
-D USE_LOG_DEBUG
-D LOG_DEBUG_INC=\"DebugConfiguration.h\"
-D CUSTOM_TOUCH_DRIVER
; -D CALIBRATE_TOUCH=0
-D LGFX_DRIVER=LGFX_INDICATOR
-D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_INDICATOR.h\"
-D VIEW_320x240

View File

@ -7,7 +7,9 @@
#define SENSOR_PORT_NUM 2
#define SENSOR_BAUD_RATE 115200
#if !HAS_TFT
#define BUTTON_PIN 38
#endif
// #define BUTTON_NEED_PULLUP
// #define BATTERY_PIN 27 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage

View File

@ -27,7 +27,6 @@ build_flags =
-D CONFIG_DISABLE_HAL_LOCKS=1 ; "feels" to be a bit more stable without locks
-D MESHTASTIC_EXCLUDE_CANNEDMESSAGES=1
-D MESHTASTIC_EXCLUDE_INPUTBROKER=1
-D MESHTASTIC_EXCLUDE_BLUETOOTH=1
-D MESHTASTIC_EXCLUDE_WEBSERVER=1
-D MESHTASTIC_EXCLUDE_SERIAL=1
-D MESHTASTIC_EXCLUDE_SOCKETAPI=1
@ -58,7 +57,6 @@ build_flags =
-D RADIOLIB_DEBUG_SPI=0
-D RADIOLIB_DEBUG_PROTOCOL=0
-D RADIOLIB_SPI_PARANOID=0
; -D CUSTOM_TOUCH_DRIVER
-D CALIBRATE_TOUCH=0
-D LGFX_DRIVER=LGFX_TDECK
-D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_T_DECK.h\"
@ -79,4 +77,3 @@ build_src_filter =
lib_deps =
${env:t-deck.lib_deps}
bitbank2/bb_captouch@1.2.2 ; alternative touch library supporting GT911