refactor(companion): the app's links through upstream's MultiSerialInterface

- Bluetooth + USB (+ WiFi/Ethernet/UART per build) in one interface_manager,
  as upstream; frames go to every enabled link, USB is read while BT is
  connected. DUAL_SERIAL now means ENABLE_USB_INTERFACE.
- WiFi interface with upstream's wifi_* prefs and set/get wifi.* CLI.
- isClientConnected moved into ArduinoSerialInterface (DTR on nRF52 and
  ESP32 native CDC).
- UI uses isBluetoothEnabled/enableBluetooth/disableBluetooth; turning BT
  off leaves USB and the other links on.
- DualSerialInterface removed.
- Sim build gains DynamicConfigSerializer.cpp (broken since bd64c203).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-15 14:04:58 +02:00
co-authored by Claude Opus 5.5
parent bd64c203c7
commit f6c0a2f021
21 changed files with 345 additions and 309 deletions
@@ -314,7 +314,7 @@ bool UITask::quickPanelOpen() const { return qpanel::s_open; }
void UITask::quickPanelRefresh() {
using namespace qpanel;
if (!s_panel) return;
tileSet(T_BT, LV_SYMBOL_BLUETOOTH, hasConnection() ? "Connected" : "Bluetooth", isSerialEnabled());
tileSet(T_BT, LV_SYMBOL_BLUETOOTH, hasConnection() ? "Connected" : "Bluetooth", isBluetoothEnabled());
tileSet(T_WIFI, LV_SYMBOL_WIFI, lvport::netRadio() == lvport::NET_UP ? "Online" : "WiFi", lvport::wifiAllowed());
int32_t lat, lon;
const bool gps = _core->gpsEnabled();
@@ -357,7 +357,7 @@ void UITask::quickPanelTile(int t, bool hold) {
}
// The tile shows what changed: no toast saying it again.
switch (t) {
case T_BT: setBluetooth(!isSerialEnabled()); break;
case T_BT: setBluetooth(!isBluetoothEnabled()); break;
case T_WIFI: wifiSetAllowed(!lvport::wifiAllowed()); break;
case T_GPS: if (_core->gpsAvailable()) setGps(!_core->gpsEnabled()); break;
case T_SOUND:
@@ -47,7 +47,7 @@ static void onQuickEditKb(lv_event_t* e) { s_ui->quickEditDone(lv_event_get_cod
static void onQuickList(lv_event_t* e) { (void)e; s_ui->showQuickMsgs(); }
static void onAdvertGo(lv_event_t* e) { s_ui->advertSend((uintptr_t)lv_event_get_user_data(e) != 0); }
static void bluetoothHint(char* sub, size_t n) {
if (!s_ui->isSerialEnabled()) snprintf(sub, n, "Off");
if (!s_ui->isBluetoothEnabled()) snprintf(sub, n, "Off");
else if (s_ui->hasConnection()) snprintf(sub, n, "App connected");
else if (the_mesh.getBLEPin()) snprintf(sub, n, "PIN %06lu", (unsigned long)the_mesh.getBLEPin());
else snprintf(sub, n, "Waiting for the app");
@@ -202,12 +202,12 @@ static void bluetoothRow(lv_obj_t* body) {
char sub[48];
qview::bluetoothHint(sub, sizeof(sub));
lv_obj_t* sw = switchRow(body, LV_SYMBOL_BLUETOOTH " Bluetooth", sub, nullptr);
if (s_ui->isSerialEnabled()) lv_obj_add_state(sw, LV_STATE_CHECKED);
if (s_ui->isBluetoothEnabled()) lv_obj_add_state(sw, LV_STATE_CHECKED);
lv_obj_add_event_cb(sw, qview::onBtSwitch, LV_EVENT_VALUE_CHANGED, NULL);
}
void UITask::setBluetooth(bool on) {
if (on) enableSerial(); else disableSerial();
if (on) enableBluetooth(); else disableBluetooth();
if (!on) showToast("Bluetooth off - USB still works", 1500);
refreshStatusBar();
}
+1 -1
View File
@@ -750,7 +750,7 @@ void UITask::refreshStatusBar() {
struct Icon { const char* sym; uint32_t col; };
Icon icons[11];
int n = 0;
if (isSerialEnabled()) icons[n++] = { LV_SYMBOL_BLUETOOTH, hasConnection() ? theme::ACCENT : theme::TEXT_MUTED };
if (isBluetoothEnabled()) icons[n++] = { LV_SYMBOL_BLUETOOTH, hasConnection() ? theme::ACCENT : theme::TEXT_MUTED };
if (lvport::wifiAllowed()) // WiFi switched on: accent while connected (map tiles, update)
icons[n++] = { LV_SYMBOL_WIFI, lvport::netRadio() == lvport::NET_UP ? theme::ACCENT : theme::TEXT_MUTED };
int32_t lat, lon;
+2 -2
View File
@@ -7,7 +7,7 @@
#include <Arduino.h>
#include <helpers/ui/DisplayDriver.h>
#include <helpers/SensorManager.h>
#include <helpers/BaseSerialInterface.h>
#include <helpers/MultiSerialInterface.h>
#include <lvgl.h>
// A big zero-initialised static in PSRAM (ESP32): the internal RAM is what
// WiFi starts and joins on. Not for what DMA or an interrupt touches.
@@ -53,7 +53,7 @@ struct TextEntry {
class UITask : public UITaskBase, public UiCoreHost {
public:
UITask(mesh::MainBoard* board, BaseSerialInterface* serial) : UITaskBase(board, serial) {}
UITask(mesh::MainBoard* board, MultiSerialInterface* serial) : UITaskBase(board, serial) {}
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs);
void loop() override;