getDeviceOnlineType(params: Object)

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

const { getDeviceOnlineType } = device;

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

Description

Check whether a specific channel of the device is online

Parameters

PropertyTypeRequiredDescription
deviceIdstringYesdeviceId device ID Supports fetching other devices’ information across panels; the current panel can pass the current device’s ID to retrieve it
Nodps
complete() => voidNoCompletion callback (executed on both success and failure)
success(params: Object) => voidNoCallback on successful API call
fail(params: Object) => voidNoFailure callback
success callback parameters
PropertyTypeDescriptionDeviceKit Since
onlineTypenumberDevice network online types represented as bit flags; use bitwise checks. Usage: (onlineType & (1 << bit)). For example, (onlineType & (1 << 0)) == true means the device is Wi‑Fi online; (onlineType & (1 << 2)) == true means the device is Bluetooth online. Definitions: bit 0 (1 << 0): Wi‑Fi online (Cloud online || LAN online). If you only need cloud online, use bit 7 bit 1 (1 << 1): Local online (LAN online) bit 2 (1 << 2): BLE online (Bluetooth online) bit 3 (1 << 3): BLEMesh online (Bluetooth Mesh online) bit 4 (1 << 4): Beacon online bit 5 (1 << 5): Dayu online bit 6 (1 << 6): System BT online (System Bluetooth online) bit 7 (1 << 7): Cloud online bit 8 (1 << 8): Matter online (Matter local online)v3.3.0
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

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

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