Fix/time driver race condition, fix BLE queries. - #8
Merged
Conversation
- Fix race condition in clock_time64() where reading the hardware timer outside the critical section allowed interrupts to update the last-seen timestamp in between, causing false overflow detection and an instantaneous multi-minute jump in Instant::now(). This manifested as light transitions snapping abruptly to their final state. Hardware read is now performed inside the critical section so the read and comparison are atomic with respect to interrupts. - Fix incorrect variable read in the BLE response callback match expression, which was reading from the request packet instead of the response packet being built. - Wrap the mesh provisioning BLE connection in an EOFError handler to suppress spurious errors on device reset during disconnection. Also reduce the post-pairing monitoring window. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tests were setting val[15] on the request packet (p_req), but after fixing the match expression to read from the response packet (ppp), the tests must set val[15] on the response instead — matching how rf_drv_8266.rs sets pkt_light_status.val[15] before calling the callback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tatus The refactored HEAD version incorrectly placed vendor_id (2 bytes) before op (1 byte) in the assembled notification payload, reversing the original mesh packet layout where op precedes vendor_id. This caused Python clients to read the vendor_id low byte (0x11) as the opcode instead of the actual opcode (e.g. 0x1b for STATUS). Restore the original order: op at dat[7], vendor_id at dat[8..10], par at dat[10..20]. This matches the raw mesh packet memory layout that the original memcpy-based implementation produced. Add test_rf_link_slave_add_status_packet_layout to explicitly assert the op-first, vendor_id-second layout expected by decrypt_notification. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📊 Coverage Report
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
No description provided.