Skip to content

Fix/time driver race condition, fix BLE queries. - #8

Merged
retsimx merged 4 commits into
mainfrom
fix/time-driver-race-condition
Mar 16, 2026
Merged

Fix/time driver race condition, fix BLE queries.#8
retsimx merged 4 commits into
mainfrom
fix/time-driver-race-condition

Conversation

@retsimx

@retsimx retsimx commented Mar 16, 2026

Copy link
Copy Markdown
Owner

No description provided.

retsimx and others added 3 commits March 16, 2026 11:36
- 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>
@github-actions

github-actions Bot commented Mar 16, 2026

Copy link
Copy Markdown

📊 Coverage Report

Metric Coverage
Lines 99.96%
Functions 100.00%
Regions 99.84%
Branches 93.93%

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@retsimx
retsimx merged commit b04a245 into main Mar 16, 2026
5 checks passed
@retsimx
retsimx deleted the fix/time-driver-race-condition branch March 16, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant