disconnectBluetoothDevice(params: Object)

版本要求:
DeviceKit≥3.1.0@ray-js/ray≥0.8.0
支持平台:
iOSAndroid
import { device } from '@ray-js/ray';

const { disconnectBluetoothDevice } = device;

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

描述

蓝牙断开连接 聚合接口, 支持ble, 双模中的ble, mesh单火类以及mesh连接断开. beacon设备调用无效

参数

属性类型必填默认值说明DeviceKit 最低版本
devIdstring是-设备ID-
connectTypenumber否0蓝牙连接方式,默认0 0 : 网关和app都需要,默认值,本地和网关两个途径任何一个可用均可生效 1 : 仅app,只会判定本地是否在线,以及本地连接是否成功 2 : 仅网关连接,只会判定网关是否在线,以及检查网关连接是否成功v3.1.2
complete() => void否-接口调用结束的回调函数(调用成功、失败都会执行)-
success() => void否-接口调用成功的回调函数-
fail(params: Object) => void否-接口调用失败的回调函数-
fail 回调参数
属性类型说明
errorMsgstring错误信息
errorCodestring | number错误码
错误扩展

返回值

无

示例代码

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

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