Add Milesight WS303 mini leak detection sensor - #38
Merged
Conversation
Adds the WS303 with AS923, AU915, EU868 and US915 profiles, reusing the existing Milesight 1.0.3 profiles. The codec is Milesight's published decoder and encoder for this product, combined into a single file. Both halves define a getValue helper with opposite semantics — the decoder maps a numeric key to a label, the encoder maps a label back to its key — so the encoder's has been renamed to getEncodeValue. Concatenating them unchanged lets the encoder's definition win through hoisting, and every decode returns "unknown". Decode and encode tests cover battery, leakage status, device status, reboot and report interval.
Contributor
|
@AkashM707 the tests are failing. I believe it is related to these lines: function Buffer(size) {
this.buffer = new Array(size);
this.offset = 0;
for (var i = 0; i < size; i++) {
this.buffer[i] = 0;
}
}I did a test and replacing these lines with: class Buffer {
constructor(size) {
this.buffer = new Array(size).fill(0);
this.offset = 0;
}
}solved the issue. Could you update this in your pull-request? |
@brocaar found this was causing the test suite to fail and confirmed a class-based Buffer resolves it.
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.
Adds the Milesight WS303 mini leak detection sensor, firmware 1.5, reusing the existing Milesight 1.0.3 profiles for AS923, AU915, EU868 and US915.
The codec is Milesight's published decoder and encoder for this product, combined into a single file.
One thing worth flagging for review: both halves define a
getValuehelper with opposite semantics — the decoder maps a numeric key to a label, the encoder maps a label back to its key. Concatenating them unchanged lets the encoder's definition win through function hoisting, and every decode then returns"unknown". The encoder's helper is renamed togetEncodeValuehere; no other changes to Milesight's code.Tests cover battery, leakage status (
normal/leak), device status, and downlink encoding for reboot and report interval.