feat: dual BLE/USB serial interface + dock-quiet BLE

Backport of PR #1779 (BLE companion usable over USB while BLE disconnected), plus: track the active transport (secure-transport gating), and stop BLE advertising while a USB host is connected (docked) so the node stays quiet on 2.4 GHz; resume advertising when undocked. An active BLE link is never force-disconnected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 4.8 committed 2026-07-11 19:21:11 +02:00
1 parent a5fd4b7488
commit 40c166fa7f
3 files changed
+110 -5

No files matched your search

+7 -4
View File
@@ -43,7 +43,8 @@ static uint32_t _atoi(const char* sp) {
#endif
#elif defined(BLE_PIN_CODE)
#include <helpers/esp32/SerialBLEInterface.h>
SerialBLEInterface serial_interface;
#include <helpers/SerialDualInterface.h>
SerialDualInterface<SerialBLEInterface> serial_interface;
#elif defined(SERIAL_RX)
#include <helpers/ArduinoSerialInterface.h>
ArduinoSerialInterface serial_interface;
@@ -72,8 +73,10 @@ static uint32_t _atoi(const char* sp) {
#endif
#elif defined(NRF52_PLATFORM)
#ifdef BLE_PIN_CODE
// Backport upstream PR #1779: BLE companion dostupný i přes USB
#include <helpers/nrf52/SerialBLEInterface.h>
SerialBLEInterface serial_interface;
#include <helpers/SerialDualInterface.h>
SerialDualInterface<SerialBLEInterface> serial_interface;
#else
#include <helpers/ArduinoSerialInterface.h>
ArduinoSerialInterface serial_interface;
@@ -157,7 +160,7 @@ void setup() {
);
#ifdef BLE_PIN_CODE
serial_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin());
serial_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin(), Serial);
#else
serial_interface.begin(Serial);
#endif
@@ -216,7 +219,7 @@ void setup() {
WiFi.begin(WIFI_SSID, WIFI_PWD);
serial_interface.begin(TCP_PORT);
#elif defined(BLE_PIN_CODE)
serial_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin());
serial_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin(), Serial);
#elif defined(SERIAL_RX)
companion_serial.setPins(SERIAL_RX, SERIAL_TX);
companion_serial.begin(115200);
+1 -1
View File
@@ -228,7 +228,7 @@ public:
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, 43, "< Connected >");
} else if (the_mesh.getBLEPin() != 0) { // BT pin
} else if (the_mesh.getBLEPin() != 0 && _task->isSerialEnabled()) { // BT pin
display.setColor(DisplayDriver::RED);
display.setTextSize(2);
sprintf(tmp, "Pin:%d", the_mesh.getBLEPin());