Fix Room Server message delivery failure when companion RTC differs from app clock#1551
Fix Room Server message delivery failure when companion RTC differs from app clock#1551saradonim wants to merge 1 commit intomeshcore-dev:devfrom
Conversation
|
This is a fix for issue #1461 |
|
Thanks for the PR. I've converted this to a draft for now so it's not accidentally merged before I have the chance to go through more internals. Message timestamps are heavily used by the app to determine heard repeat counts. The timestamp provided by the app is likely to be more accurate than the microcontroller, since it can't be synced backwards, but mobile phones can be corrected by GPS and network providers. This will need some proper testing/investigation. We don't want to break the app functionality. I'm away at the moment so can't do a full review right now, but one thing I thought of, was putting the timestamp the firmware used when sending a message, in the SENT response code. The app could parse that for use. |
|
I haven’t noticed any issues with repeater counts while using the app so far. However, I only have one repeater nearby that can hear me, so I can’t really test this properly at the moment. Let me know what you find once you’re back and able to test it. If there do turn out to be issues with repeater counts, we could definitely look into including the timestamp in the response code as you suggested. |
|
I've done some more testing and confirmed that this indeed breaks repeater counts for public channel messages. Possible SolutionsOption 1: Pass the RTC timestamp per message to the app - (App change needed) Option 2: Use the app clock everywhere - (App change needed) Option 3: Revert only the channel message change - (for this, no app change is needed) I think these are the only valid options, but please correct me if i'm wrong. |
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