---
name: "getBTDeviceInfo"
mode: "kit"
versionRequirements:
  - { name: "DeviceKit", version: "2.3.1" }
  - { name: "@ray-js/ray", version: "0.6.23" }
platform:
  - "iOS"
  - "Android"
async: true
title: "getBTDeviceInfo - 获取设备 BT 信息"
---

## getBTDeviceInfo

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

> [PLATFORM] iOS, Android

> ⚡ **支持 Promise 调用** — 不传 success / fail / complete 回调时，该方法返回 Promise。

### 描述

获取设备BT信息

### 参数

| 属性 | 类型 | 必填 | 默认值 | 最低版本 | 描述 |
| --- | --- | --- | --- | --- | --- |
| `deviceId` | `string` | 是 | - | `2.3.1` | 设备模型 deviceId 设备Id |
| `complete` | `() => void` | 否 | - | - | 接口调用结束的回调函数（调用成功、失败都会执行） |
| `success` | `(params: Object) => void` ↓见下方 | 否 | - | - | 接口调用成功的回调函数 |
| `fail` | `(params: Object) => void` ↓见下方 | 否 | - | - | 接口调用失败的回调函数 |

#### success 回调参数

| 属性 | 类型 | 最低版本 | 描述 |
| --- | --- | --- | --- |
| `deviceName` | `string` | `3.3.0` | 设备名称 |
| `isConnected` | `boolean` | `3.3.0` | 是否连接 |
| `isBond` | `boolean` | `3.3.0` | 是否配对 |
| `mac` | `string` | `3.3.0` | mac |

#### fail 回调参数

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `errorMsg` | `string` | 错误信息 |
| `errorCode` | `string \| number` | 错误码 |
| `innerError` | `Object` | 错误扩展 |

##### fail(params).innerError 的属性

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `errorCode` | `string \| number` | 错误扩展码 |
| `errorMsg` | `string` | 错误扩展信息 |


### 示例代码

#### 基础调用

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

const { getBTDeviceInfo } = device;

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