Static parser
parser: BinaryAnalyzer<{} & {}> = new BinaryAnalyzer().addTarget('flag', [0x02, 0x01, 0x06], 'RawArray').addGroup('manufacture',new BinaryAnalyzer().addTarget('length', [-1], 'RawArray').addTarget('type', [0xff], 'RawArray').addTarget('companyId', [0x69, 0x09], 'RawArray').addTargetByLength('macAddress', 6, 'RawArray').addTargetByLength('sequenceNumber', 1, 'RawArray', ([v]) => v).addTargetByLength('powerState', 1, 'RawArray', ([v]) =>v === 0x00 ? 'off' : v === 0x80 ? 'on' : null).addTargetByLength('byte10', 1, 'RawArray', ([v]) => {const hasDelay = v & 0b00000001 ? true : false;const hasTimer = v & 0b00000010 ? true : false;const alreadySyncTime = v & 0b00000100 ? true : false;return {hasDelay,hasTimer,alreadySyncTime,};}).addTargetByLength('wifiRssi', 1, 'RawArray', ([v]) => -v).addTargetByLength('byte12_13', 2, 'RawArray', ([_12, _13]) => {const overload = _12 & 0b10000000 ? true : false;const msb = _12 & 0b01111111;const lsb = _13;const power = ((msb << 8) + lsb) / 10;return {overload,power,};}))
Switchbot_PlugMini management class Switchbot_PlugMiniを管理するクラス