Skip to content

Commit be5f0dc

Browse files
committed
Fix acks never updating message status, reorder nav
sendText() never assigned a packet id, so it defaulted to 0 and was sent to the radio as-is. The radio then assigns its own real id on receipt and echoes that real id back as requestId on the Routing ack - which never matches the (always-0) id the UI was told to track, so incoming acks could never be matched to their message and the status line was stuck on 'Waiting to be acknowledged...' forever, no matter how many acks actually arrived. Fixed by generating the packet id client-side before sending, same as sendAdmin() already did correctly. Nav order is now Peers, Channels, Messages, Map, Config.
1 parent e9a21cd commit be5f0dc

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

‎index.html‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@
6161
<!-- Navigation group -->
6262
<div class="nav-group">
6363
<div class="nav-group-title">Navigation</div>
64+
<button class="nav-item" id="navBtnPeers" onclick="navigate('peers')">
65+
<span class="icon">group</span><span class="nav-item-label">Peers</span>
66+
<span class="nav-item-count" id="navPeerCount">0</span>
67+
</button>
68+
<button class="nav-item" id="tabBtnChannels" onclick="navigate('channels')">
69+
<span class="icon">hub</span><span class="nav-item-label">Channels</span>
70+
<span class="tab-badge" id="tabBadgeChannels" style="display:none">0</span>
71+
</button>
6472
<button class="nav-item active" id="tabBtnMessages" onclick="navigate('messages')">
6573
<span class="icon">chat</span><span class="nav-item-label">Messages</span>
6674
<span class="tab-badge" id="tabBadgeMessages" style="display:none">0</span>
@@ -71,14 +79,6 @@
7179
<button class="nav-item" id="navBtnConfig" onclick="navigate('config')">
7280
<span class="icon">settings</span><span class="nav-item-label">Config</span>
7381
</button>
74-
<button class="nav-item" id="tabBtnChannels" onclick="navigate('channels')">
75-
<span class="icon">hub</span><span class="nav-item-label">Channels</span>
76-
<span class="tab-badge" id="tabBadgeChannels" style="display:none">0</span>
77-
</button>
78-
<button class="nav-item" id="navBtnPeers" onclick="navigate('peers')">
79-
<span class="icon">group</span><span class="nav-item-label">Peers</span>
80-
<span class="nav-item-count" id="navPeerCount">0</span>
81-
</button>
8282
</div>
8383

8484
<!-- Bottom rail -->

‎server/server.js‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,15 @@ async function sendText(text, destNum, channelIndex) {
282282
if (typeof text !== 'string' || text.length === 0 || text.length > 237) {
283283
throw new Error('Message must be 1-237 characters (Meshtastic limit)');
284284
}
285-
const mp = create(MeshPacketSchema, { to: destNum ?? 0xFFFFFFFF, channel: channelIndex ?? 0, decoded: { payload: new TextEncoder().encode(text), portnum: PortNum.TEXT_MESSAGE_APP }, wantAck: true, hopLimit: 3 });
285+
// The packet id must be assigned here, client-side — leaving it unset defaults
286+
// to 0, so the node silently assigns its own real id on receipt. That real id
287+
// is what comes back as `requestId` on the Routing ack, which then never
288+
// matches the (always-0) id we told the UI to track, so ack status can never
289+
// update no matter how many acks actually arrive.
290+
const packetId = Math.floor(Math.random() * 0x7ffffffe) + 1;
291+
const mp = create(MeshPacketSchema, { id: packetId, to: destNum ?? 0xFFFFFFFF, channel: channelIndex ?? 0, decoded: { payload: new TextEncoder().encode(text), portnum: PortNum.TEXT_MESSAGE_APP }, wantAck: true, hopLimit: 3 });
286292
await httpPut(`${nodeBaseUrl()}/api/v1/toradio`, toBinary(ToRadioSchema, create(ToRadioSchema, { payloadVariant: { case: 'packet', value: mp } })));
287-
return Number(mp.id);
293+
return packetId;
288294
}
289295

290296
async function doConnect(ip, port) {

0 commit comments

Comments
 (0)