refactor: port upstream MyMesh::Listener; MyMesh no longer calls the UI directly

Ports upstream's "Abstract UI overhaul" (PR #3431 + follow-ups) with
identical names/signatures. MyMesh talks to the UI only through
MyMesh::Listener (setListener()); a second block holds Solo extensions
(own-send mirroring, relay echoes, room login/admin replies, [LOC] shares,
contact/channel removal, bot device actions, requestShutdown), all no-op
by default.

AbstractUITask becomes the Listener and carries the glue MyMesh used to
run for the UI (display filter, room-post labels, notifications,
connection polling). BLE PIN randomisation moves to main.cpp as upstream.
Also fixes ui-orig's stale advertReceived event on buzzer boards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-09-24 22:54:40 +02:00
co-authored by Claude Opus 5.5
parent f768e73f9f
commit 2a8d4598d4
9 changed files with 305 additions and 232 deletions
+33 -9
View File
@@ -135,11 +135,7 @@ static uint32_t _atoi(const char* sp) {
StdRNG fast_rng;
SimpleMeshTables tables;
MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store
#ifdef DISPLAY_CLASS
, &ui_task
#endif
);
MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store);
/* END GLOBAL OBJECTS */
@@ -147,6 +143,29 @@ void halt() {
while (1) ;
}
// Session BLE PIN, resolved after the_mesh.begin() has loaded prefs and before
// the serial interface starts advertising with it. A saved PIN wins; otherwise
// the default 123456 becomes a random per-session PIN when there's a display to
// show it on (moved here from MyMesh::begin(), as upstream did -- MyMesh has no
// display concept).
static void resolveBLEPin(bool has_display) {
#ifdef BLE_PIN_CODE // 123456 by default
if (the_mesh.getNodePrefs()->ble_pin == 0) {
if (has_display && BLE_PIN_CODE == 123456) {
StdRNG rng;
the_mesh.setBLEPin(rng.nextInt(100000, 999999)); // random pin each session
} else {
the_mesh.setBLEPin(BLE_PIN_CODE); // otherwise static pin
}
} else {
the_mesh.setBLEPin(the_mesh.getNodePrefs()->ble_pin);
}
#else
(void)has_display;
the_mesh.setBLEPin(0);
#endif
}
/* WIFI RECONNECT TRACKERS */
#if defined(ESP32) && defined(WIFI_SSID)
bool wifi_needs_reconnect = false;
@@ -193,7 +212,8 @@ void setup() {
#endif
#endif
store.begin();
the_mesh.begin(
the_mesh.begin();
resolveBLEPin(
#ifdef DISPLAY_CLASS
disp != NULL
#else
@@ -212,7 +232,8 @@ void setup() {
#elif defined(RP2040_PLATFORM)
LittleFS.begin();
store.begin();
the_mesh.begin(
the_mesh.begin();
resolveBLEPin(
#ifdef DISPLAY_CLASS
disp != NULL
#else
@@ -238,7 +259,8 @@ void setup() {
#elif defined(ESP32)
SPIFFS.begin(true);
store.begin();
the_mesh.begin(
the_mesh.begin();
resolveBLEPin(
#ifdef DISPLAY_CLASS
disp != NULL
#else
@@ -277,7 +299,8 @@ void setup() {
#elif defined(SIM_PLATFORM)
// sim_fs already exists/mkdir'd itself in its constructor above.
store.begin();
the_mesh.begin(
the_mesh.begin();
resolveBLEPin(
#ifdef DISPLAY_CLASS
disp != NULL
#else
@@ -303,6 +326,7 @@ void setup() {
if (disp && the_mesh.getNodePrefs())
disp->setBrightness(the_mesh.getNodePrefs()->display_brightness);
ui_task.begin(disp, &sensors, the_mesh.getNodePrefs()); // still want to pass this in as dependency, as prefs might be moved
the_mesh.setListener(&ui_task);
#ifdef DISPLAY_HAS_BUSY_PUMP
if (disp) disp->setBusyPumpFn(pumpRadioDuringDisplayBusyWait, nullptr);
#endif