Skip to content

Commit

Permalink
fix(wirepas): ignore LED read messages
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Feb 13, 2024
1 parent b07e04d commit 04bfa88
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions wirepas-5g-mesh-gateway/decodePayload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,7 @@ void describe('decodePayload()', () => {
),
{},
))

void it('should ignore LED status read messages', () =>
assert.deepEqual(decodePayload(Buffer.from('8201', 'hex')), {}))
})
10 changes: 10 additions & 0 deletions wirepas-5g-mesh-gateway/decodePayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ Byte 1: ID (0x03)
Byte 2: Color. 0x00: red, 0x01: blue, 0x02: green
Byte 3: State. 0x00: off, 0x01: on.
### Read LED status
Byte 1: ID (0x82)
Byte 2: Color. 0x00: red, 0x01: blue, 0x02: green
## Diagnostic messages
Concerning the message starting with BF, it does not come from the Thingy: these are diagnostic messages giving information about the network. You can safely ignore them too.
Expand Down Expand Up @@ -125,6 +130,11 @@ export const decodePayload = (
}
}

// LED reads special case
if (payload.length === 2 && msg.peek() === 0x82) {
return {}
}

// Regular message
while (msg.hasNext()) {
const type = msg.getChar()
Expand Down

0 comments on commit 04bfa88

Please sign in to comment.