Skip to content

Commit 75bacc1

Browse files
fix(vs373): missing function (readResultStatus)
1 parent 0f4b216 commit 75bacc1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

VS_Series/VS373/VS373_Decoder.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function Decoder(bytes, port) {
2626
function milesightDeviceDecode(bytes) {
2727
var decoded = {};
2828

29-
for (var i = 0; i < bytes.length;) {
29+
for (var i = 0; i < bytes.length; ) {
3030
var channel_id = bytes[i++];
3131
var channel_type = bytes[i++];
3232

@@ -302,10 +302,12 @@ function handle_downlink_response_ext(code, channel_type, bytes, offset) {
302302
offset += 1;
303303

304304
if (result_value !== 0) {
305+
var request = decoded;
305306
decoded = {};
306307
decoded.device_response_result = {};
307308
decoded.device_response_result.channel_type = channel_type;
308-
decoded.device_response_result.result = readResultStatus(bytes[offset]);
309+
decoded.device_response_result.result = readResultStatus(result_value);
310+
decoded.device_response_result.request = request;
309311
}
310312
}
311313

@@ -316,6 +318,11 @@ function hasResultFlag(code) {
316318
return code === 0xf8;
317319
}
318320

321+
function readResultStatus(status) {
322+
var status_map = { 0: "success", 1: "forbidden", 2: "invalid parameter" };
323+
return getValue(status_map, status);
324+
}
325+
319326
function readProtocolVersion(bytes) {
320327
var major = (bytes & 0xf0) >> 4;
321328
var minor = bytes & 0x0f;

0 commit comments

Comments
 (0)