getDeviceOnlineType(params: Object)

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

const { getDeviceOnlineType } = device;

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

描述

检查设备某个通道是否在线

参数

属性类型必填说明
deviceIdstring是deviceId 设备id 支持跨面板获取其他的设备信息,当前面板可以传当前设备的 id 来进行获取
否dps
complete() => void否接口调用结束的回调函数(调用成功、失败都会执行)
success(params: Object) => void否接口调用成功的回调函数
fail(params: Object) => void否接口调用失败的回调函数
success 回调参数
属性类型说明DeviceKit 最低版本
onlineTypenumber设备网络在线类型,位运算方式表示,可使用位运算方式进行判断。 使用方式:(onlineType & (1 << bit)),例如:(onlineType & (1 << 0)) == true 表示设备 Wi-Fi 在线,(onlineType & (1 << 2)) == true 表示设备蓝牙在线 定义如下: bit 0 (1 << 0): Wi-Fi online,(云端在线 || 局域网在线),若只想判断云端在线,建议使用 bit:7 bit 1 (1 << 1): Local online,局域网在线 bit 2 (1 << 2): BLE online,蓝牙在线 bit 3 (1 << 3): BLEMesh online,蓝牙mesh在线 bit 4 (1 << 4): beacon online,beacon在线 bit 5 (1 << 5): Dayu online,大禹在线 bit 6 (1 << 6): System BT Online,系统蓝牙在线 bit 7 (1 << 7): Cloud online,云端在线 bit 8 (1 << 8): Matter online,Matter 本地在线v3.3.0
fail 回调参数
属性类型说明
errorMsgstring错误信息
errorCodestring | number错误码
错误扩展

返回值

无

示例代码

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

device.getDeviceOnlineType({
  deviceId: "xx",
  dps: { "xx": {} },
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});