milesight: update em300-sld-zld codec to latest official and add encoder#29
Merged
brocaar merged 1 commit intoJun 11, 2026
Merged
Conversation
Sync the decoder with Milesight-IoT/SensorDecoders@347389d (em-series/em300-zld) and append the official downlink encoder so the codec supports both decodeUplink and encodeDownlink. Two renames were required to coexist with the decoder and the test runner: - getValue/getValues -> getEncoderValue/getEncoderValues: the decoder defines a getValue with different semantics (forward map lookup vs reverse). - Buffer -> EncoderBuffer: the test runner imports the npm buffer polyfill into module scope, whose Buffer.prototype defines a getter-only 'offset' property that breaks the encoder's own Buffer helper ('no setter for property'). Decoder changes coming from upstream Milesight: - temperature_alarm_config: min_threshold/max_threshold -> threshold_min/threshold_max - d2d_config -> d2d_master_config (array), trigger_event -> mode - *_calibration_config -> *_calibration_settings, value -> calibration_value - hardware/firmware versions formatted as hex Decode tests seeded from the sample payload in the official codec.json; encode tests cover the most used commands. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Thanks @GeorgeBark 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
threshold_min/threshold_max,d2d_master_configas array,*_calibration_settings, hex-formatted hardware/firmware versions).encodeDownlink(reboot, intervals, history, retransmission, temperature/leakage alarms, calibration, D2D).codec.json, encode cases covering the most used commands.Two helpers from the official encoder are renamed to avoid collisions:
getValue/getValues→getEncoderValue/getEncoderValues(the decoder defines agetValuewith reverse semantics) andBuffer→EncoderBuffer(the test runner imports the npmbufferpolyfill into module scope, whose getter-onlyBuffer.prototype.offsetbreaks the encoder helper).Test plan
make testpasses (CI on fork: run 27288260868)🤖 Generated with Claude Code