Skip to content

Conversation

@michaelbeutler
Copy link
Contributor

This pull request adds support for decoding the new "DataRate" field in the TagXL v1 decoder for port 151 uplinks, and updates related tests and documentation. It also introduces a new feature flag for adaptive data rate and updates the secrets baseline file to reflect changes in test line numbers.

Decoder and Feature Updates:

  • Added support for decoding the DataRate field (tag 0x4e) as an optional uint8 in the Port151Payload struct in port151.go and updated the decoder logic to recognize this field. [1] [2] [3]
  • Introduced a new feature flag, FeatureAdaptiveDataRate, in decoder.go to represent adaptive data rate capability.

Testing and Documentation:

  • Added a new test case in decoder_test.go to verify correct decoding of the DataRate field for port 151.

Maintenance:

  • Updated .secrets.baseline to adjust line numbers for detected secrets in decoder_test.go and refreshed the generated_at timestamp. [1] [2]…coder tests

@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 63.33333% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/decoder/tagxl/v1/port151.go 52.38% 10 Missing ⚠️
pkg/decoder/tagxl/v1/decoder.go 75.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
pkg/common/helpers.go 98.04% <100.00%> (+0.31%) ⬆️
pkg/decoder/decoder.go 100.00% <ø> (ø)
pkg/decoder/tagxl/v1/decoder.go 88.08% <75.00%> (+2.96%) ⬆️
pkg/decoder/tagxl/v1/port151.go 84.81% <52.38%> (-10.43%) ⬇️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@michaelbeutler michaelbeutler linked an issue Oct 17, 2025 that may be closed by this pull request
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 1, 2026

@michaelbeutler michaelbeutler marked this pull request as ready for review January 1, 2026 19:59
@michaelbeutler michaelbeutler requested review from a team and Copilot January 1, 2026 19:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for decoding the new DataRate field (tag 0x4e) in the TagXL v1 decoder for port 151 uplinks. The implementation introduces 8 new data rate constants for TagXL devices, a helper function to convert uint8 values to the corresponding data rate enums, and test cases to validate the decoder behavior.

  • Added DataRate field support with 8 specific TagXL data rate constants (DR0-DR5, DR1-3 array, and ADR)
  • Introduced a new FeatureDataRate feature flag and helper function for test data
  • Added test cases for data rate decoding validation

Reviewed changes

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

Show a summary per file
File Description
pkg/decoder/tagxl/v1/port151.go Added DataRate field to Port151Payload struct, implemented GetDataRate method, added DataRateFromUint8 conversion function, and documented the field's payload format
pkg/decoder/tagxl/v1/decoder_test.go Added 5 test cases covering data rate values 0, 3, 5, 7, and the absence of the field
pkg/decoder/tagxl/v1/decoder.go Added DataRate tag configuration (0x4e) with transform function and added FeatureDataRate to features list
pkg/decoder/decoder.go Added FeatureDataRate constant to the Feature type enumeration
pkg/decoder/data_rate.go Added 8 TagXL-specific DataRate constants with inline comments explaining their meanings
pkg/common/helpers.go Added generic DataRatePtr helper function using reflection to create pointers while avoiding circular dependencies
.secrets.baseline Updated line numbers for detected secrets due to test file changes and refreshed generated_at timestamp

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

Comment on lines +462 to +470
// DataRatePtr is a generic helper to create a pointer to any DataRate value.
// Returns interface{} to avoid circular dependencies.
func DataRatePtr(value interface{}) interface{} {
v := reflect.ValueOf(value)
ptr := reflect.New(v.Type())
ptr.Elem().Set(v)
return ptr.Interface()
}

Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

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

The DataRatePtr helper function uses reflection and returns interface{}, requiring callers to perform type assertions like .(*decoder.DataRate). This is inconsistent with other pointer helpers in this file (BoolPtr, Uint16Ptr, etc.) which return strongly-typed pointers. Consider defining this helper directly in the test file or in a test helper package that can import the decoder package, which would allow for a more type-safe implementation without reflection.

Suggested change
// DataRatePtr is a generic helper to create a pointer to any DataRate value.
// Returns interface{} to avoid circular dependencies.
func DataRatePtr(value interface{}) interface{} {
v := reflect.ValueOf(value)
ptr := reflect.New(v.Type())
ptr.Elem().Set(v)
return ptr.Interface()
}
// DataRatePtr is a generic helper to create a pointer to any value (e.g., decoder.DataRate)
// without needing to import the defining package here, avoiding circular dependencies.
func DataRatePtr[T any](value T) *T {
return &value
}

Copilot uses AI. Check for mistakes.
case 7:
return decoder.DataRateTagXLADR
default:
return decoder.DataRate("unknown")
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

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

The default case returns a hardcoded string literal "unknown" instead of using a defined constant. Consider adding a constant like DataRateUnknown to the data_rate.go file for consistency with other DataRate constants and better maintainability.

Suggested change
return decoder.DataRate("unknown")
return decoder.DataRateUnknown

Copilot uses AI. Check for mistakes.
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.

feat(tagxl): add support for uplinks port 151 with tag 0x4e

2 participants