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

## queryDps

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

> [PLATFORM] iOS, Android

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

### Description

Query dps

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `deviceId` | `string` | Yes | - | `1.2.6` | Device ID |
| `dpIds` | `number[]` | Yes | - | `1.2.6` | dpids array |
| `queryType` | `number` | No | - | `4.1.10` | Query type 0: null dp query (MQTT protocol 5, LAN protocol 7, Bluetooth 03 command query) 1: regular query (MQTT protocol 31, LAN protocol 16, Bluetooth 03 command query) 2: send null dp query + regular query together 3: For single-point Bluetooth, perform a null dp query with the 03 command; other devices use regular query (aligned with the RN container's impl_getDpsWithDevId method). Note: Supported starting from TUNIDeviceKit 4.21.0; lower versions will use a null dp query > 3: is a null dp query |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `(params: boolean) => void` | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### 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 { queryDps } = device;

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