Skip to content

Commit 91f665b

Browse files
committed
feat: finalize pending integration and UI/runtime stability updates
Apply remaining cross-module updates covering HostLink bridge handling, chat/contact storage and event-flow tuning, GPS/track recorder SPI coordination, and USB mode Wi-Fi behavior. Complete UI refinements for contacts, team, GPS, and GNSS skyplot interactions, including T-Deck layout/input behavior improvements and related state plumbing.
1 parent a0614ae commit 91f665b

25 files changed

+818
-621
lines changed

src/app/app_context.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@
2525
namespace app
2626
{
2727

28+
#ifndef APP_EVENT_LOG_ENABLE
29+
#define APP_EVENT_LOG_ENABLE 0
30+
#endif
31+
32+
#if APP_EVENT_LOG_ENABLE
33+
#define APP_EVENT_LOG(...) Serial.printf(__VA_ARGS__)
34+
#else
35+
#define APP_EVENT_LOG(...)
36+
#endif
37+
2838
bool AppContext::init(BoardBase& board, LoraBoard* lora_board, GpsBoard* gps_board, MotionBoard* motion_board,
2939
bool use_mock_adapter, uint32_t disable_hw_init)
3040
{
@@ -230,6 +240,8 @@ void AppContext::getEffectiveUserInfo(char* out_long, size_t long_len,
230240

231241
void AppContext::update()
232242
{
243+
constexpr size_t kMaxEventsPerUpdate = 32;
244+
233245
hostlink::process_pending_commands();
234246

235247
// Update chat service (process incoming messages)
@@ -258,33 +270,35 @@ void AppContext::update()
258270
ui_controller_->update();
259271
}
260272

261-
// Process events
273+
// Process events with a budget to avoid starving UI under burst traffic.
262274
sys::Event* event = nullptr;
263-
while (sys::EventBus::subscribe(&event, 0))
275+
for (size_t processed = 0;
276+
processed < kMaxEventsPerUpdate && sys::EventBus::subscribe(&event, 0);)
264277
{
265278
if (!event)
266279
{
267280
continue;
268281
}
282+
++processed;
269283

270284
// Handle global events (like haptic feedback) before UI-specific handling
271285
switch (event->type)
272286
{
273287
case sys::EventType::ChatNewMessage:
274288
{
275289
sys::ChatNewMessageEvent* msg_event = (sys::ChatNewMessageEvent*)event;
276-
Serial.printf("[AppContext::update] ChatNewMessage received: channel=%d\n", msg_event->channel);
290+
APP_EVENT_LOG("[AppContext::update] ChatNewMessage received: channel=%d\n", msg_event->channel);
277291

278292
// Global haptic feedback on incoming messages (works regardless of UI state)
279293
if (board_)
280294
{
281-
Serial.printf("[AppContext::update] Triggering haptic feedback...\n");
295+
APP_EVENT_LOG("[AppContext::update] Triggering haptic feedback...\n");
282296
board_->vibrator();
283-
Serial.printf("[AppContext::update] Haptic feedback triggered\n");
297+
APP_EVENT_LOG("[AppContext::update] Haptic feedback triggered\n");
284298
}
285299
else
286300
{
287-
Serial.printf("[AppContext::update] WARNING: board_ is nullptr, cannot trigger vibration\n");
301+
APP_EVENT_LOG("[AppContext::update] WARNING: board_ is nullptr, cannot trigger vibration\n");
288302
}
289303

290304
// Show system notification
@@ -369,7 +383,7 @@ void AppContext::update()
369383
case sys::EventType::NodeInfoUpdate:
370384
{
371385
sys::NodeInfoUpdateEvent* node_event = (sys::NodeInfoUpdateEvent*)event;
372-
Serial.printf("[AppContext] NodeInfo event consumed node=%08lX pending=%u\n",
386+
APP_EVENT_LOG("[AppContext] NodeInfo event consumed node=%08lX pending=%u\n",
373387
static_cast<unsigned long>(node_event->node_id),
374388
static_cast<unsigned>(sys::EventBus::pendingCount()));
375389
// Update ContactService with node info from event
@@ -393,7 +407,7 @@ void AppContext::update()
393407
case sys::EventType::NodeProtocolUpdate:
394408
{
395409
sys::NodeProtocolUpdateEvent* node_event = (sys::NodeProtocolUpdateEvent*)event;
396-
Serial.printf("[AppContext] NodeProtocol event consumed node=%08lX pending=%u\n",
410+
APP_EVENT_LOG("[AppContext] NodeProtocol event consumed node=%08lX pending=%u\n",
397411
static_cast<unsigned long>(node_event->node_id),
398412
static_cast<unsigned>(sys::EventBus::pendingCount()));
399413
if (contact_service_)
@@ -409,7 +423,7 @@ void AppContext::update()
409423
case sys::EventType::NodePositionUpdate:
410424
{
411425
auto* pos_event = (sys::NodePositionUpdateEvent*)event;
412-
Serial.printf("[AppContext] NodePosition event consumed node=%08lX pending=%u\n",
426+
APP_EVENT_LOG("[AppContext] NodePosition event consumed node=%08lX pending=%u\n",
413427
static_cast<unsigned long>(pos_event->node_id),
414428
static_cast<unsigned>(sys::EventBus::pendingCount()));
415429
if (contact_service_)

src/app/app_tasks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <RadioLib.h>
99

1010
#ifndef LORA_LOG_ENABLE
11-
#define LORA_LOG_ENABLE 1
11+
#define LORA_LOG_ENABLE 0
1212
#endif
1313

1414
#if LORA_LOG_ENABLE

src/chat/infra/meshcore/meshcore_adapter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ T clampValue(T value, T min_value, T max_value)
7575
}
7676

7777
#ifndef MESHCORE_LOG_ENABLE
78-
#define MESHCORE_LOG_ENABLE 1
78+
#define MESHCORE_LOG_ENABLE 0
7979
#endif
8080

8181
#if MESHCORE_LOG_ENABLE

src/chat/infra/meshtastic/mt_adapter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <vector>
3434

3535
#ifndef LORA_LOG_ENABLE
36-
#define LORA_LOG_ENABLE 1
36+
#define LORA_LOG_ENABLE 0
3737
#endif
3838

3939
#if LORA_LOG_ENABLE

src/chat/infra/meshtastic/node_store.cpp

Lines changed: 55 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ namespace chat
1717
namespace meshtastic
1818
{
1919

20+
#ifndef NODE_STORE_LOG_ENABLE
21+
#define NODE_STORE_LOG_ENABLE 0
22+
#endif
23+
24+
#if NODE_STORE_LOG_ENABLE
25+
#define NODE_STORE_LOG(...) Serial.printf(__VA_ARGS__)
26+
#else
27+
#define NODE_STORE_LOG(...)
28+
#endif
29+
2030
namespace
2131
{
2232
uint32_t crc32(const uint8_t* data, size_t len)
@@ -46,31 +56,31 @@ void logNvsStats(const char* tag, const char* ns)
4656
esp_err_t err = nvs_get_stats(nullptr, &stats);
4757
if (err == ESP_OK)
4858
{
49-
Serial.printf("[NodeStore] NVS stats(%s): used=%u free=%u total=%u namespaces=%u\n",
50-
tag ? tag : "?",
51-
static_cast<unsigned>(stats.used_entries),
52-
static_cast<unsigned>(stats.free_entries),
53-
static_cast<unsigned>(stats.total_entries),
54-
static_cast<unsigned>(stats.namespace_count));
59+
NODE_STORE_LOG("[NodeStore] NVS stats(%s): used=%u free=%u total=%u namespaces=%u\n",
60+
tag ? tag : "?",
61+
static_cast<unsigned>(stats.used_entries),
62+
static_cast<unsigned>(stats.free_entries),
63+
static_cast<unsigned>(stats.total_entries),
64+
static_cast<unsigned>(stats.namespace_count));
5565
}
5666
else
5767
{
58-
Serial.printf("[NodeStore] NVS stats(%s) err=%s\n",
59-
tag ? tag : "?",
60-
esp_err_to_name(err));
68+
NODE_STORE_LOG("[NodeStore] NVS stats(%s) err=%s\n",
69+
tag ? tag : "?",
70+
esp_err_to_name(err));
6171
}
6272
if (ns && ns[0])
6373
{
6474
nvs_handle_t handle;
6575
err = nvs_open(ns, NVS_READONLY, &handle);
6676
if (err == ESP_OK)
6777
{
68-
Serial.printf("[NodeStore] NVS open ns=%s ok\n", ns);
78+
NODE_STORE_LOG("[NodeStore] NVS open ns=%s ok\n", ns);
6979
nvs_close(handle);
7080
}
7181
else
7282
{
73-
Serial.printf("[NodeStore] NVS open ns=%s err=%s\n", ns, esp_err_to_name(err));
83+
NODE_STORE_LOG("[NodeStore] NVS open ns=%s err=%s\n", ns, esp_err_to_name(err));
7484
}
7585
}
7686
}
@@ -97,18 +107,18 @@ void NodeStore::begin()
97107
}
98108

99109
entries_.clear();
100-
Serial.printf("[NodeStore] loaded=0\n");
110+
NODE_STORE_LOG("[NodeStore] loaded=0\n");
101111
}
102112

103113
void NodeStore::upsert(uint32_t node_id, const char* short_name, const char* long_name,
104114
uint32_t now_secs, float snr, float rssi, uint8_t protocol, uint8_t role,
105115
uint8_t hops_away)
106116
{
107-
Serial.printf("[NodeStore] upsert node=%08lX ts=%lu snr=%.1f rssi=%.1f\n",
108-
(unsigned long)node_id,
109-
(unsigned long)now_secs,
110-
snr,
111-
rssi);
117+
NODE_STORE_LOG("[NodeStore] upsert node=%08lX ts=%lu snr=%.1f rssi=%.1f\n",
118+
(unsigned long)node_id,
119+
(unsigned long)now_secs,
120+
snr,
121+
rssi);
112122
// find existing
113123
for (auto& e : entries_)
114124
{
@@ -220,16 +230,16 @@ void NodeStore::save()
220230
{
221231
if (saveToSd())
222232
{
223-
Serial.printf("[NodeStore] save ok (SD) count=%u\n",
224-
static_cast<unsigned>(entries_.size()));
233+
NODE_STORE_LOG("[NodeStore] save ok (SD) count=%u\n",
234+
static_cast<unsigned>(entries_.size()));
225235
return;
226236
}
227237
}
228238

229239
Preferences prefs;
230240
if (!prefs.begin(kPersistNodesNs, false))
231241
{
232-
Serial.printf("[NodeStore] save failed ns=%s\n", kPersistNodesNs);
242+
NODE_STORE_LOG("[NodeStore] save failed ns=%s\n", kPersistNodesNs);
233243
logNvsStats("save-open", kPersistNodesNs);
234244
return;
235245
}
@@ -265,20 +275,20 @@ void NodeStore::save()
265275
prefs.putUInt(kPersistNodesKeyCrc, crc);
266276
if (written != expected)
267277
{
268-
Serial.printf("[NodeStore] save failed wrote=%u expected=%u\n",
269-
static_cast<unsigned>(written),
270-
static_cast<unsigned>(expected));
278+
NODE_STORE_LOG("[NodeStore] save failed wrote=%u expected=%u\n",
279+
static_cast<unsigned>(written),
280+
static_cast<unsigned>(expected));
271281
logNvsStats("save-write", kPersistNodesNs);
272282
}
273283
else
274284
{
275285
size_t verify_len = prefs.getBytesLength(kPersistNodesKey);
276286
uint8_t verify_ver = prefs.getUChar(kPersistNodesKeyVer, 0);
277287
uint32_t verify_crc = prefs.getUInt(kPersistNodesKeyCrc, 0);
278-
Serial.printf("[NodeStore] save ok len=%u ver=%u crc=%08lX\n",
279-
static_cast<unsigned>(verify_len),
280-
static_cast<unsigned>(verify_ver),
281-
static_cast<unsigned long>(verify_crc));
288+
NODE_STORE_LOG("[NodeStore] save ok len=%u ver=%u crc=%08lX\n",
289+
static_cast<unsigned>(verify_len),
290+
static_cast<unsigned>(verify_ver),
291+
static_cast<unsigned long>(verify_crc));
282292
}
283293
}
284294
else
@@ -288,7 +298,7 @@ void NodeStore::save()
288298
prefs.remove(kPersistNodesKeyCrc);
289299
}
290300
prefs.end();
291-
Serial.printf("[NodeStore] saved=%u\n", static_cast<unsigned>(entries_.size()));
301+
NODE_STORE_LOG("[NodeStore] saved=%u\n", static_cast<unsigned>(entries_.size()));
292302
}
293303

294304
void NodeStore::maybeSave()
@@ -334,22 +344,22 @@ bool NodeStore::loadFromNvs()
334344
Preferences prefs;
335345
if (!prefs.begin(kPersistNodesNs, false))
336346
{
337-
Serial.printf("[NodeStore] begin failed ns=%s\n", kPersistNodesNs);
347+
NODE_STORE_LOG("[NodeStore] begin failed ns=%s\n", kPersistNodesNs);
338348
logNvsStats("begin", kPersistNodesNs);
339349
return false;
340350
}
341351
size_t len = prefs.getBytesLength(kPersistNodesKey);
342352
uint8_t ver = prefs.getUChar(kPersistNodesKeyVer, 0);
343353
bool has_crc = prefs.isKey(kPersistNodesKeyCrc);
344354
uint32_t stored_crc = has_crc ? prefs.getUInt(kPersistNodesKeyCrc, 0) : 0;
345-
Serial.printf("[NodeStore] blob len=%u ver=%u crc=%08lX has_crc=%u\n",
346-
static_cast<unsigned>(len),
347-
static_cast<unsigned>(ver),
348-
static_cast<unsigned long>(stored_crc),
349-
has_crc ? 1U : 0U);
355+
NODE_STORE_LOG("[NodeStore] blob len=%u ver=%u crc=%08lX has_crc=%u\n",
356+
static_cast<unsigned>(len),
357+
static_cast<unsigned>(ver),
358+
static_cast<unsigned long>(stored_crc),
359+
has_crc ? 1U : 0U);
350360
if (len == 0 && has_crc)
351361
{
352-
Serial.printf("[NodeStore] stale meta detected, clearing ver/crc\n");
362+
NODE_STORE_LOG("[NodeStore] stale meta detected, clearing ver/crc\n");
353363
prefs.remove(kPersistNodesKeyVer);
354364
prefs.remove(kPersistNodesKeyCrc);
355365
}
@@ -372,16 +382,16 @@ bool NodeStore::loadFromNvs()
372382
if (!has_crc)
373383
{
374384
prefs.end();
375-
Serial.printf("[NodeStore] missing crc\n");
385+
NODE_STORE_LOG("[NodeStore] missing crc\n");
376386
clear();
377387
return false;
378388
}
379389
if (ver != kPersistVersion)
380390
{
381391
prefs.end();
382-
Serial.printf("[NodeStore] version mismatch stored=%u expected=%u\n",
383-
static_cast<unsigned>(ver),
384-
static_cast<unsigned>(kPersistVersion));
392+
NODE_STORE_LOG("[NodeStore] version mismatch stored=%u expected=%u\n",
393+
static_cast<unsigned>(ver),
394+
static_cast<unsigned>(kPersistVersion));
385395
clear();
386396
return false;
387397
}
@@ -390,9 +400,9 @@ bool NodeStore::loadFromNvs()
390400
if (calc_crc != stored_crc)
391401
{
392402
prefs.end();
393-
Serial.printf("[NodeStore] crc mismatch stored=%08lX calc=%08lX\n",
394-
static_cast<unsigned long>(stored_crc),
395-
static_cast<unsigned long>(calc_crc));
403+
NODE_STORE_LOG("[NodeStore] crc mismatch stored=%08lX calc=%08lX\n",
404+
static_cast<unsigned long>(stored_crc),
405+
static_cast<unsigned long>(calc_crc));
396406
clear();
397407
return false;
398408
}
@@ -417,13 +427,13 @@ bool NodeStore::loadFromNvs()
417427
}
418428
else if (len > 0)
419429
{
420-
Serial.printf("[NodeStore] invalid blob size=%u\n", static_cast<unsigned>(len));
430+
NODE_STORE_LOG("[NodeStore] invalid blob size=%u\n", static_cast<unsigned>(len));
421431
prefs.end();
422432
clear();
423433
return false;
424434
}
425435
prefs.end();
426-
Serial.printf("[NodeStore] loaded=%u\n", static_cast<unsigned>(entries_.size()));
436+
NODE_STORE_LOG("[NodeStore] loaded=%u\n", static_cast<unsigned>(entries_.size()));
427437
return true;
428438
}
429439

@@ -491,7 +501,7 @@ bool NodeStore::loadFromSd()
491501
dst.role = src.role;
492502
entries_.push_back(dst);
493503
}
494-
Serial.printf("[NodeStore] loaded=%u (SD)\n", static_cast<unsigned>(entries_.size()));
504+
NODE_STORE_LOG("[NodeStore] loaded=%u (SD)\n", static_cast<unsigned>(entries_.size()));
495505
return true;
496506
}
497507

0 commit comments

Comments
 (0)