Skip to content

feat(ble): add BLE ports 160-163 to smartlabel and tagxl decoders#192

Merged
michaelbeutler merged 2 commits into
mainfrom
feat/smartlabel-tagxl-ble-ports-160-163
Jun 19, 2026
Merged

feat(ble): add BLE ports 160-163 to smartlabel and tagxl decoders#192
michaelbeutler merged 2 commits into
mainfrom
feat/smartlabel-tagxl-ble-ports-160-163

Conversation

@michaelbeutler

@michaelbeutler michaelbeutler commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Decode the ts2 BLE uplink payloads (RSSI + MAC beacon lists) on ports 160 (steady), 161 (moving), 162 (steady + timestamp) and 163 (moving + timestamp) for both the smartlabel and tagxl v1 decoders.

Each payload exposes the Ble and Moving features. The timestamped variants (162/163) additionally expose Timestamp; the tagxl variants also expose Buffered, mirroring its existing timestamped Wi-Fi ports. The smartlabel timestamped variants intentionally omit Buffered, consistent with its other timestamped ports (e.g. port 10).

Also refresh .secrets.baseline for the new test payload vectors.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added BLE beacon payload decoding for SmartLabel and TagXL across ports 160–163, including beacon MAC addresses and RSSI readings.
    • Included movement state for the appropriate ports (steady vs moving).
    • Added timestamp support for the time-aware ports (162–163), with TagXL buffering status evaluation for those payloads.
  • Tests

    • Expanded decoder fixtures and feature assertions to cover ports 160–163, verifying decoded payloads, beacons, movement state, and timestamps where applicable.

Decode the ts2 BLE uplink payloads (RSSI + MAC beacon lists) on ports
160 (steady), 161 (moving), 162 (steady + timestamp) and 163
(moving + timestamp) for both the smartlabel and tagxl v1 decoders.

Each payload exposes the Ble and Moving features (plus Timestamp/Buffered
for the timestamped variants), mirroring the existing Wi-Fi port layout.

Also refresh .secrets.baseline for the new test payload vectors.
Copilot AI review requested due to automatic review settings June 19, 2026 07:59
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4a039b65-d787-4c1f-b3c7-d11d584e0522

📥 Commits

Reviewing files that changed from the base of the PR and between 749ba61 and e85c972.

📒 Files selected for processing (2)
  • pkg/decoder/smartlabel/v1/decoder_test.go
  • pkg/decoder/tagxl/v1/decoder_test.go

📝 Walkthrough

Walkthrough

Adds BLE uplink decoder support for ports 160–163 to both the SmartLabel v1 and TagXL v1 decoders. Four new payload types per decoder handle steady/moving variants (ports 160/161) and timestamped steady/moving variants (ports 162/163), with GetBeacons(), IsMoving(), and optional GetTimestamp()/buffering methods. Decoder configs, transform helpers, tests, and the secrets baseline are updated accordingly.

Changes

BLE Ports 160–163 (SmartLabel + TagXL)

Layer / File(s) Summary
SmartLabel Port160–163 payload structs and methods
pkg/decoder/smartlabel/v1/port160.go, pkg/decoder/smartlabel/v1/port161.go, pkg/decoder/smartlabel/v1/port162.go, pkg/decoder/smartlabel/v1/port163.go
Introduces four new payload types for SmartLabel v1 BLE ports. All implement GetBeacons() and IsMoving(); ports 162/163 additionally implement GetTimestamp(). Compile-time interface assertions are present in each file.
SmartLabel decoder config and transform helpers
pkg/decoder/smartlabel/v1/decoder.go
Adds getConfig switch cases for ports 160–163 with BLE field layouts and wires alwaysTrue/alwaysFalse transform helpers for the Moving field.
SmartLabel tests for ports 160–163
pkg/decoder/smartlabel/v1/decoder_test.go
Extends TestDecode and TestFeatures with port 160–163 cases; adds a FeatureBle assertion branch verifying UplinkFeatureBle type and non-nil GetBeacons().
TagXL Port160–163 payload structs and methods
pkg/decoder/tagxl/v1/port160.go, pkg/decoder/tagxl/v1/port161.go, pkg/decoder/tagxl/v1/port162.go, pkg/decoder/tagxl/v1/port163.go
Introduces four new payload types for TagXL v1. Ports 162/163 additionally implement buffering methods (GetBufferLevel, IsBuffered) using bufferedAgeThreshold and GetTimestamp().
TagXL decoder config for ports 160–163
pkg/decoder/tagxl/v1/decoder.go
Adds getConfig switch cases for ports 160–163 in the TagXL decoder, including buffered/timestamp features for ports 162/163.
TagXL tests for ports 160–163
pkg/decoder/tagxl/v1/decoder_test.go
Extends TestDecode and TestFeatures with port 160–163 cases and adds the FeatureBle assertion branch.
Secrets baseline refresh
.secrets.baseline
Updates hashed secret entries and line numbers for both decoder test files and refreshes the generated_at timestamp.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • truvami/decoder#178: Introduces the Beacon/UplinkFeatureBle/GetBeacons() interfaces and the BLE feature pattern that this PR directly extends to ports 160–163 in both SmartLabel and TagXL.

Suggested reviewers

  • JanickFischer
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding BLE decoder support for ports 160-163 across smartlabel and tagxl decoders, which is the core focus of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/smartlabel-tagxl-ble-ports-160-163

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter

codecov-commenter commented Jun 19, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 68.64407% with 148 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/decoder/smartlabel/v1/port160.go 37.14% 18 Missing and 4 partials ⚠️
pkg/decoder/smartlabel/v1/port162.go 40.54% 18 Missing and 4 partials ⚠️
pkg/decoder/tagxl/v1/port160.go 42.85% 16 Missing and 4 partials ⚠️
pkg/decoder/tagxl/v1/port162.go 51.21% 16 Missing and 4 partials ⚠️
pkg/decoder/smartlabel/v1/port161.go 51.42% 14 Missing and 3 partials ⚠️
pkg/decoder/smartlabel/v1/port163.go 54.05% 14 Missing and 3 partials ⚠️
pkg/decoder/tagxl/v1/port161.go 57.14% 12 Missing and 3 partials ⚠️
pkg/decoder/tagxl/v1/port163.go 63.41% 12 Missing and 3 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Files with missing lines Coverage Δ
pkg/decoder/smartlabel/v1/decoder.go 96.85% <100.00%> (+1.72%) ⬆️
pkg/decoder/tagxl/v1/decoder.go 91.14% <100.00%> (+1.71%) ⬆️
pkg/decoder/tagxl/v1/port161.go 57.14% <57.14%> (ø)
pkg/decoder/tagxl/v1/port163.go 63.41% <63.41%> (ø)
pkg/decoder/smartlabel/v1/port161.go 51.42% <51.42%> (ø)
pkg/decoder/smartlabel/v1/port163.go 54.05% <54.05%> (ø)
pkg/decoder/tagxl/v1/port160.go 42.85% <42.85%> (ø)
pkg/decoder/tagxl/v1/port162.go 51.21% <51.21%> (ø)
pkg/decoder/smartlabel/v1/port160.go 37.14% <37.14%> (ø)
pkg/decoder/smartlabel/v1/port162.go 40.54% <40.54%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI 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.

Pull request overview

Adds decoding support for TS2 BLE uplinks (RSSI + MAC beacon lists) on ports 160–163 for both SmartLabel v1 and TagXL v1, aligning the port layout with the existing steady/moving + (optional) timestamp variants and expanding test coverage for these new payload vectors.

Changes:

  • Add new BLE payload types and beacon extraction for ports 160–163 (steady/moving; with/without timestamp) in SmartLabel v1 and TagXL v1 decoders.
  • Extend both decoder configs to map the new port layouts into the new payload structs and expose the corresponding decoder features.
  • Add decode + feature tests for new payload vectors and refresh .secrets.baseline accordingly.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/decoder/tagxl/v1/port160.go New TagXL v1 BLE steady (no timestamp) payload type + beacon extraction
pkg/decoder/tagxl/v1/port161.go New TagXL v1 BLE moving (no timestamp) payload type + beacon extraction
pkg/decoder/tagxl/v1/port162.go New TagXL v1 BLE steady (timestamped) payload type + beacon extraction + buffered semantics
pkg/decoder/tagxl/v1/port163.go New TagXL v1 BLE moving (timestamped) payload type + beacon extraction + buffered semantics
pkg/decoder/tagxl/v1/decoder.go Adds port-to-payload field mappings + feature exposure for ports 160–163
pkg/decoder/tagxl/v1/decoder_test.go Adds decode + feature tests for new BLE ports (160–163)
pkg/decoder/smartlabel/v1/port160.go New SmartLabel v1 BLE steady (no timestamp) payload type + beacon extraction
pkg/decoder/smartlabel/v1/port161.go New SmartLabel v1 BLE moving (no timestamp) payload type + beacon extraction
pkg/decoder/smartlabel/v1/port162.go New SmartLabel v1 BLE steady (timestamped) payload type + beacon extraction
pkg/decoder/smartlabel/v1/port163.go New SmartLabel v1 BLE moving (timestamped) payload type + beacon extraction
pkg/decoder/smartlabel/v1/decoder.go Adds port-to-payload field mappings + feature exposure for ports 160–163
pkg/decoder/smartlabel/v1/decoder_test.go Adds decode + feature tests for new BLE ports (160–163)
.secrets.baseline Updates detect-secrets baseline for added high-entropy test vectors

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/decoder/smartlabel/v1/decoder.go
Comment thread pkg/decoder/smartlabel/v1/decoder.go
Comment thread pkg/decoder/smartlabel/v1/port162.go
Comment thread pkg/decoder/smartlabel/v1/port163.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/decoder/smartlabel/v1/decoder_test.go`:
- Around line 783-790: Replace the weak nil check for GetBeacons() with a
stronger assertion that validates the beacons slice actually contains data. In
the test block where you check if ble.GetBeacons() == nil, change this to
instead check that len(ble.GetBeacons()) > 0 to ensure beacon count is greater
than zero and catch potential decode regressions where beacons might be empty.

In `@pkg/decoder/smartlabel/v1/port160.go`:
- Around line 50-90: The beacon inclusion logic currently requires both MAC and
RSSI to be present before adding beacons, which can silently drop MAC addresses
when RSSI is unavailable and diverges from the existing BLE beacon contract.
Change the inclusion logic in the beacon appending blocks to key only on MAC
presence: for Mac1, check only if p.Mac1 is not empty (remove the Rssi1 check);
for Mac2 through Mac6, check only if the Mac pointer is non-nil (remove the Rssi
checks). When appending beacons, always include the RSSI pointer as-is, allowing
it to be nil when unavailable instead of dropping valid MAC entries.

In `@pkg/decoder/tagxl/v1/decoder_test.go`:
- Around line 1571-1578: The assertion in the BLE feature test using
GetBeacons() == nil check is insufficient because it will pass even when
GetBeacons() returns an initialized empty slice, missing potential BLE decoding
regressions. Replace the nil check with a stronger assertion that verifies
GetBeacons() actually contains the expected beacon data, such as checking that
the slice has a non-zero length or contains the specific beacons expected from
the decoded payload in this test case.

In `@pkg/decoder/tagxl/v1/port160.go`:
- Around line 57-90: The code appends optional beacons when the MAC pointer is
not nil (p.Mac2, p.Mac3, p.Mac4, p.Mac5, p.Mac6) but does not validate that the
corresponding RSSI pointer is also not nil, which can result in partial beacon
entries being emitted. Modify each if condition in the repeated beacon appending
blocks to require both the MAC pointer AND the RSSI pointer to be not nil before
appending to the beacons slice. This ensures complete MAC/RSSI pairs are
validated before creating and appending each decoder.Beacon entry.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 11ea685f-5cf3-4a06-95e9-69424fc8ebd9

📥 Commits

Reviewing files that changed from the base of the PR and between 31e9cf6 and 749ba61.

📒 Files selected for processing (13)
  • .secrets.baseline
  • pkg/decoder/smartlabel/v1/decoder.go
  • pkg/decoder/smartlabel/v1/decoder_test.go
  • pkg/decoder/smartlabel/v1/port160.go
  • pkg/decoder/smartlabel/v1/port161.go
  • pkg/decoder/smartlabel/v1/port162.go
  • pkg/decoder/smartlabel/v1/port163.go
  • pkg/decoder/tagxl/v1/decoder.go
  • pkg/decoder/tagxl/v1/decoder_test.go
  • pkg/decoder/tagxl/v1/port160.go
  • pkg/decoder/tagxl/v1/port161.go
  • pkg/decoder/tagxl/v1/port162.go
  • pkg/decoder/tagxl/v1/port163.go

Comment thread pkg/decoder/smartlabel/v1/decoder_test.go
Comment thread pkg/decoder/smartlabel/v1/port160.go
Comment thread pkg/decoder/tagxl/v1/decoder_test.go
Comment thread pkg/decoder/tagxl/v1/port160.go
Strengthen the FeatureBle assertions in the smartlabel and tagxl feature
tests to require at least one decoded beacon instead of a non-nil slice,
catching empty-decode regressions.
@michaelbeutler michaelbeutler merged commit 86ee797 into main Jun 19, 2026
8 checks passed
@michaelbeutler michaelbeutler deleted the feat/smartlabel-tagxl-ble-ports-160-163 branch June 19, 2026 11:31
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.

4 participants