Fix room message timestamps - #3127
Open
mikecarper wants to merge 1 commit into
Open
Conversation
mikecarper
marked this pull request as ready for review
August 7, 2026 21:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The current implementation uses one per-client
last_timestampreplay watermark for login requests, keep-alives, CLI traffic, and room posts. Current upstreamdevstill uses this shared watermark, as do deployed room servers built from earlier versions of the same implementation.This PR changes only companion firmware so those deployed room servers do not need to be updated.
Root cause
The companion already generates login and keep-alive timestamps from its own RTC. For ordinary text messages, however, it forwards the timestamp supplied by the phone app. Those timestamps can come from different clock states even though the packets are sent by the same companion.
With a shared room-server replay watermark, this can produce the following sequence:
client->last_timestampon the room server.Sending (attempt 2/3)and subsequent attempts fail the same comparison.The fix gives a new room message a timestamp from the companion's monotonic RTC, matching the clock source already used for login and keep-alive traffic.
Why retries keep the same timestamp
The logical message timestamp and the MeshCore packet hash serve different purposes:
attemptbyte inside that payload, so attempts 1, 2, and 3 have different packet hashes even when their logical timestamp is unchanged.This gives the intended behavior:
Lower-level retransmission of the exact same encrypted packet is separate from the app-level attempt mechanism addressed here.
Impact and scope
Companions can send messages to room servers using the shared replay watermark without requiring a room-server firmware update. Peer messages, channel messages, and room-server firmware are unchanged.
Validation
pio test -e native— 30 tests passedpio run -e Heltec_v3_companion_radio_ble— passedpio run -e RAK_WisMesh_Tag_companion_radio_ble— passed