Fix Cardputer delivery, live settings and power management

Keep selected chats bound to full contact keys and route keyboard channel sends through the active transport. Deliver accepted plain, room and Meshtext messages to local history and notifications once; disarm rejected sends and retries.

Use shared live radio settings, GPS acquisition and power-saving policy, screen timers and red night palette. Report save failures, preserve verified custom preferences, and guard display controls and shutdown.

Add executable sanitizer regressions for routing, retries, selection, storage faults, UI lifecycle and GPS. Both Companion builds and the shared T-Deck regression pass; no physical Cardputer testing performed.
This commit is contained in:
mikecarper committed 2026-10-27 22:59:26 -07:00
1 parent e5d5981e5e
commit 9a2211e85a
27 files changed
+1950 -346

No files matched your search

+26 -3
View File
@@ -1717,9 +1717,12 @@ bool MyMesh::queueMessage(const ContactInfo &from, uint8_t txt_type, mesh::Packe
const bool notification_managed = false;
#endif
#ifdef DISPLAY_CLASS
#if defined(DISPLAY_CLASS) || CARDPUTER_ADV_UI
// we only want to show text messages on display, not cli data
bool should_display = txt_type == TXT_TYPE_PLAIN || txt_type == TXT_TYPE_SIGNED_PLAIN;
#if CARDPUTER_ADV_UI
if (should_display) onUiContactMessage(from, text);
#endif
if (should_display && _ui) {
_ui->newMsg(path_len, from.name, text, offline_queue_len,
-1, nullptr, queued ? offline_queue_len - 1 : -1);
@@ -2340,6 +2343,9 @@ bool MyMesh::queueChannelText(uint8_t channel_idx, const uint8_t secret[32], flo
const bool queued = addToOfflineQueue(out_frame, i);
if (!queued) return false;
#if CARDPUTER_ADV_UI
onUiChannelMessage(secret, text);
#endif
#if COMPANION_FEATURE_NOTIFICATIONS
const bool notification_managed = notify && _notifications.message(nullptr, secret, _serial && _serial->isConnected(), millis());
if (_ui) _ui->setMessageNotificationOverride(notification_managed, _notifications.overridesScreen());
@@ -2354,7 +2360,7 @@ bool MyMesh::queueChannelText(uint8_t channel_idx, const uint8_t secret[32], flo
frame[0] = PUSH_CODE_MSG_WAITING;
_serial->writeFrame(frame, 1);
} else {
#ifdef DISPLAY_CLASS
#if defined(DISPLAY_CLASS) || CARDPUTER_ADV_UI
if (notify && _ui && !notification_managed) _ui->notify(UIEventType::channelMessage);
#endif
}
@@ -2369,7 +2375,7 @@ bool MyMesh::queueChannelText(uint8_t channel_idx, const uint8_t secret[32], flo
path_len == 0xFF ? "DIRECT" : "FLOOD", text);
}
#endif
#ifdef DISPLAY_CLASS
#if defined(DISPLAY_CLASS) || CARDPUTER_ADV_UI
// Get the channel name from the channel index
const char *channel_name = "Unknown";
ChannelDetails channel_details;
@@ -9544,6 +9550,23 @@ void MyMesh::appendRxPowerSavingAdjustmentNote(char* reply, size_t reply_size,
(unsigned)_prefs.rx_ps_level);
}
#if CARDPUTER_ADV_UI
bool MyMesh::sendUiChannelMessage(int channel_idx, uint32_t timestamp,
const char* text, size_t length) {
ChannelDetails channel;
if (!text || !length || length != strlen(text)
|| !getChannel(channel_idx, channel) || !channel.name[0]) return false;
#if MESH_ENABLE_MESHTEXT_CHAT
if (isMeshtextChannel(channel)) return sendMeshtextText(channel, text, length);
#endif
if (isAliasRadio2Defined()
&& parseCompanionChannelAlias(channel.name).kind == CompanionChannelKind::Meshtext) return false;
const size_t prefix_length = strlen(_prefs.node_name) + 2;
if (prefix_length >= MAX_TEXT_LEN || length > MAX_TEXT_LEN - prefix_length) return false;
return sendGroupMessage(timestamp, channel.channel, _prefs.node_name, text, length);
}
#endif
#if COMPANION_FEATURE_TEXT_TERMINAL
Stream& MyMesh::terminalOutput() {
if (isTerminalWaitingForInput()) return mesh::usbTerminalPort(false);
+12
View File
@@ -389,6 +389,12 @@ public:
#endif
protected:
#if CARDPUTER_ADV_UI
// Run after the shared duplicate/retention checks, including room posts and
// Meshtext. Variant history must not bypass the Companion delivery policy.
virtual void onUiContactMessage(const ContactInfo&, const char*) {}
virtual void onUiChannelMessage(const uint8_t[32], const char*) {}
#endif
#if COMPANION_FEATURE_TEMP_RADIO
bool isTempRadioActive() const override {
return _temp_radio_applied && _temp_radio_revert_at != 0
@@ -609,6 +615,12 @@ public:
// Runtime copies use the wire PSK; storage/app keep the original alias PSK.
bool getChannel(int channel_idx, ChannelDetails& channel);
bool setChannel(int channel_idx, const ChannelDetails& channel);
#if CARDPUTER_ADV_UI
uint16_t getPrimaryRadioPreamble() const { return _radio_profiles.primaryPreamble(); }
bool queueUiContactWrite(const ContactInfo& contact) { return scheduleContactWrite(contact); }
bool sendUiChannelMessage(int channel_idx, uint32_t timestamp,
const char* text, size_t length);
#endif
bool savePrefs() {
const uint8_t previous_tail_flags[] = {
_prefs.usb_debug_enabled, _prefs.usb_logging_always};
+2
View File
@@ -3991,6 +3991,8 @@ void setup() {
the_mesh.begin(
#ifdef DISPLAY_CLASS
disp != NULL
#elif CARDPUTER_ADV_UI
cardputer_disp != NULL
#else
false
#endif