-
Notifications
You must be signed in to change notification settings - Fork 0
feat(tagxl): add DataRate support to Port151Payload and update de…
#170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Codecov Report❌ Patch coverage is
... and 30 files with indirect coverage changes 🚀 New features to boost your workflow:
|
…ate Port151Payload
|
There was a problem hiding this 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
FeatureDataRatefeature 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.
| // 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() | ||
| } | ||
|
|
Copilot
AI
Jan 1, 2026
There was a problem hiding this comment.
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.
| // 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 | |
| } |
| case 7: | ||
| return decoder.DataRateTagXLADR | ||
| default: | ||
| return decoder.DataRate("unknown") |
Copilot
AI
Jan 1, 2026
There was a problem hiding this comment.
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.
| return decoder.DataRate("unknown") | |
| return decoder.DataRateUnknown |



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:
DataRatefield (tag 0x4e) as an optionaluint8in thePort151Payloadstruct inport151.goand updated the decoder logic to recognize this field. [1] [2] [3]FeatureAdaptiveDataRate, indecoder.goto represent adaptive data rate capability.Testing and Documentation:
decoder_test.goto verify correct decoding of theDataRatefield for port 151.Maintenance:
.secrets.baselineto adjust line numbers for detected secrets indecoder_test.goand refreshed thegenerated_attimestamp. [1] [2]…coder tests