diff --git a/lib/device-ui b/lib/device-ui index d0f0e5e28..83c0eb060 160000 --- a/lib/device-ui +++ b/lib/device-ui @@ -1 +1 @@ -Subproject commit d0f0e5e286904913db9e2a05f43edcd45be7b29f +Subproject commit 83c0eb060d8ab15ae1073f22f2386ecd63d09480 diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 00d101495..63beeab9a 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -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; diff --git a/src/mesh/api/PacketAPI.cpp b/src/mesh/api/PacketAPI.cpp index 80a7d8335..10c1404ee 100644 --- a/src/mesh/api/PacketAPI.cpp +++ b/src/mesh/api/PacketAPI.cpp @@ -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(server)->sendPacket(fromRadioScratch); - // else bool result = server->sendPacket(DataPacket(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(0, fromRadioScratch)); +} + /** * return true if we got (once!) contact from our client and the server send queue is not full */ diff --git a/src/mesh/api/PacketAPI.h b/src/mesh/api/PacketAPI.h index 53c0667f5..fc08ab209 100644 --- a/src/mesh/api/PacketAPI.h +++ b/src/mesh/api/PacketAPI.h @@ -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 }; diff --git a/variants/seeed-sensecap-indicator/platformio.ini b/variants/seeed-sensecap-indicator/platformio.ini index 6b6abae6c..31566edbe 100644 --- a/variants/seeed-sensecap-indicator/platformio.ini +++ b/variants/seeed-sensecap-indicator/platformio.ini @@ -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 diff --git a/variants/seeed-sensecap-indicator/variant.h b/variants/seeed-sensecap-indicator/variant.h index 58eed7d96..1010e04c8 100644 --- a/variants/seeed-sensecap-indicator/variant.h +++ b/variants/seeed-sensecap-indicator/variant.h @@ -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 diff --git a/variants/t-deck/platformio.ini b/variants/t-deck/platformio.ini index 42cc4c44d..1eb8a1abd 100644 --- a/variants/t-deck/platformio.ini +++ b/variants/t-deck/platformio.ini @@ -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 \ No newline at end of file