How to use the @abandonware/noble._bindings function in @abandonware/noble

To help you get started, weโ€™ve selected a few @abandonware/noble examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github icanos / hassio-plejd / plejd / plejd.js View on Github external
async disconnect() {
    logger('disconnecting from Plejd');

    if (this.isConnected) {
      clearInterval(this.pingRef);

      if (this.peripheral) {
        try {
          // disconnect
          await this.peripheral.disconnect();

          // we need to reset the ble adapter too
          noble._bindings._hci.reset();

          // wait 200 ms for reset command to take effect :)
          sleep.msleep(200);

          // now we're ready to connect again
        }
        catch (error) {
          console.log('error: unable to disconnect from Plejd: ' + error);
          return Promise.resolve(false);
        }

        this.isConnected = false;
        logger('disconnected from Plejd');

        return Promise.resolve(true);
      }