Skip to content

milesight: update em300-sld-zld codec to latest official and add encoder#29

Merged
brocaar merged 1 commit into
chirpstack:masterfrom
ControlaIT:milesight-em300-sld-zld-update
Jun 11, 2026
Merged

milesight: update em300-sld-zld codec to latest official and add encoder#29
brocaar merged 1 commit into
chirpstack:masterfrom
ControlaIT:milesight-em300-sld-zld-update

Conversation

@GeorgeBark

Copy link
Copy Markdown
Contributor

Summary

  • Sync the EM300-SLD/ZLD decoder with the current official version from Milesight-IoT/SensorDecoders@347389d (field renames in downlink responses: threshold_min/threshold_max, d2d_master_config as array, *_calibration_settings, hex-formatted hardware/firmware versions).
  • Append the official downlink encoder so the codec supports encodeDownlink (reboot, intervals, history, retransmission, temperature/leakage alarms, calibration, D2D).
  • Fill in the previously empty decode/encode tests: decode cases seeded from the sample payload in the official codec.json, encode cases covering the most used commands.

Two helpers from the official encoder are renamed to avoid collisions: getValue/getValuesgetEncoderValue/getEncoderValues (the decoder defines a getValue with reverse semantics) and BufferEncoderBuffer (the test runner imports the npm buffer polyfill into module scope, whose getter-only Buffer.prototype.offset breaks the encoder helper).

Test plan

🤖 Generated with Claude Code

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>
@brocaar brocaar merged commit 4cf8d34 into chirpstack:master Jun 11, 2026
2 checks passed
@brocaar

brocaar commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Thanks @GeorgeBark 👍

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.

2 participants