Options
All
  • Public
  • Public/Protected
  • All
Menu

Switchbot_PlugMini management class Switchbot_PlugMiniを管理するクラス

Hierarchy

Implements

Index

Constructors

constructor

Properties

_peripheral

_peripheral: BleRemotePeripheral

Optional ondisconnect

ondisconnect: undefined | ((reason: any) => void)

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,};}))

Methods

connectWait

  • connectWait(setting?: Pick<BleConnectSetting, "retry" | "forceConnect">): Promise<void>
  • Parameters

    Returns Promise<void>

Static getData

  • Get a data from the Switchbot_PlugMini

    Switchbot_PlugMiniからデータを取得

    Parameters

    • peripheral: BleRemotePeripheral

      instance of BleRemotePeripheral BleRemotePeripheralのインスタンス

    Returns Switchbot_PlugMini_Data | null

    received data from the Switchbot_PlugMini Switchbot_PlugMiniから受け取ったデータ

Static getPayload

  • Parameters

    Returns null | ({} & {})

Static getServiceDataPayload

  • getServiceDataPayload(peripheral: BleRemotePeripheral, deviceType: number | number[], serviceDataPayloadLength: number): null | number[]

Static info

Static isDevice

  • Verify that the received peripheral is from the Switchbot_PlugMini

    受け取ったPeripheralがSwitchbot_PlugMiniのものかどうかを確認する

    Parameters

    • peripheral: BleRemotePeripheral

      instance of BleRemotePeripheral BleRemotePeripheralのインスタンス

    Returns boolean

    Whether it is the Switchbot_PlugMini

    Switchbot_PlugMiniかどうか

Static isSwitchbotDevice

  • isSwitchbotDevice(peripheral: BleRemotePeripheral, deviceType: number | number[], serviceDataPayloadLength: number): boolean

Generated using TypeDoc