Fix Room Server message delivery failure when companion RTC differs from app clock #1551
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.
Problem
Companions cannot send messages to Room Servers when the companion's RTC clock is ahead of the app's clock. Messages silently fail with retries until "Failed" status, while login and sync operations work normally. On top of that, users could not fix this themselves because the firmware prevented setting the RTC to an earlier time.
Root Cause
There was an inconsistency in timestamp sources:
sendLogin)BaseChatMesh.cpp:486)sendRequest)BaseChatMesh.cpp:547)cmd_frame)cmd_frame)Room Servers track
last_timestampper client to prevent replay attacks (simple_room_server/MyMesh.cpp:405). Messages with timestamps older thanlast_timestampare silently discarded.Failure scenario:
last_timestamp= companion's RTC (e.g.,1500)1001)1001 >= 1500? NO → message discarded, no ACK sentAdditional Issue
Users could not fix a future-stuck RTC because
CMD_SET_DEVICE_TIMErejected any time earlier than the current RTC (companion_radio/MyMesh.cpp:1068).Solutions
Fix 1: Use companion's RTC for all message timestamps (consistency)
Fix 2: Allow RTC to be corrected even when current RTC is in the future
Testing