---
name: "getDeviceOnlineType"
mode: "kit"
versionRequirements:
  - { name: "DeviceKit", version: "2.1.4" }
  - { name: "@ray-js/ray", version: "0.6.23" }
platform:
  - "iOS"
  - "Android"
async: true
---

## getDeviceOnlineType

> [VERSION] DeviceKit >= 2.1.4 | @ray-js/ray >= 0.6.23

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Check whether a specific channel of the device is online

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `deviceId` | `string` | Yes | - | `4.11.0` | deviceId device ID Supports fetching other devices’ information across panels; the current panel can pass the current device’s ID to retrieve it |
| `dps` | `Record<string, Record<string, any>>` | No | - | `4.11.0` | dps |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `(params: Object) => void` ↓see below | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### success callback parameters

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `onlineType` | `number` | `3.3.0` | Device 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) |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Examples

#### Basic usage

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

const { getDeviceOnlineType } = device;

getDeviceOnlineType({
  deviceId: 'device_001',
  success: (result) => {
    console.log('getDeviceOnlineType success', result);
  },
  fail: (error) => {
    console.log('getDeviceOnlineType fail', error.errorMsg);
  },
});
```
