disconnectBluetoothDevice(params: Object)

Requires:
DeviceKit≥3.1.0@ray-js/ray≥0.8.0
Platforms:
iOSAndroid
import { device } from '@ray-js/ray';

const { disconnectBluetoothDevice } = device;

// Promise usage
try {
  const res = await disconnectBluetoothDevice({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Description

Aggregated Bluetooth disconnect API; supports ble, ble in dual-mode, mesh single-live-wire and mesh disconnections. Calling this on beacon devices has no effect.

Parameters

PropertyTypeRequiredDefaultDescriptionDeviceKit Since
devIdstringYes-Device ID-
connectTypenumberNo0Bluetooth connection mode (default: 0) 0: Gateway and app. Default mode; effective if either the local or gateway path is available. 1: App only. Only checks whether the device is locally online and whether the local connection succeeds. 2: Gateway only. Only checks whether the gateway is online and whether the gateway connection succeeds.v3.1.2
complete() => voidNo-Completion callback (executed on both success and failure)-
success() => voidNo-Callback on successful API call-
fail(params: Object) => voidNo-Failure callback-
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { device } from '@ray-js/ray'

device.disconnectBluetoothDevice({
  devId: "xx",
  connectType: 0,
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});