UNPKG

eep-packet

Version:

Parses an EnOcean Serial Protocol 3 buffer to an EEP packet.

10 lines (8 loc) 274 B
module.exports = function(rawUserData) { const state = ['open', 'closed']; const stateBit = rawUserData.readUInt8() << 31 >>> 31; // Offset = 7, size = 1 return { type: 'contact', state: state[stateBit] // 0 = open, 1 = closed } };