Skip to content

Fix timestamp ticks decoding mask#208

Merged
emontnemery merged 2 commits into
home-assistant-libs:mainfrom
MartB:main
Jan 8, 2026
Merged

Fix timestamp ticks decoding mask#208
emontnemery merged 2 commits into
home-assistant-libs:mainfrom
MartB:main

Conversation

@MartB

@MartB MartB commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

Thread defines the Timestamp Ticks field as 15 bits. The parser was using a mask of 0x7FF (11 bits), which truncated higher tick values.

This changes the mask to 0x7FFF to correctly decode the full 15-bit value.

Related to home-assistant/core#134306
If this ends up being merged, bumping the dependency of the thread component would be nice!

Comment thread tests/test_tlv_parser.py
Thread defines the Timestamp Ticks field as 15 bits. The parser was using a mask of `0x7FF` (11 bits), which truncated higher tick values.

This changes the mask to `0x7FFF` to correctly decode the full 15-bit value.

Related to home-assistant/core#134306
@MartB
MartB requested a review from lboue December 26, 2025 16:09
@lboue

lboue commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

That seems correct to me; it corresponds to what we find here: timestamp.hpp#L179-L180

    static constexpr uint8_t  kTicksOffset         = 1;
    static constexpr uint16_t kTicksMask           = 0x7fff << kTicksOffset;

@lboue lboue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@emontnemery

Copy link
Copy Markdown
Collaborator

@MartB You really should create a topic branch for PRs instead of submitting PRs from your fork's main branch (for your own sake, it doesn't matter for us).

@emontnemery emontnemery left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot for fixing this @MartB 👍

@emontnemery
emontnemery merged commit f766982 into home-assistant-libs:main Jan 8, 2026
1 check passed
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.

3 participants