tt.openBluetoothAdapter
基础库 1.0.0 开始支持本方法,这是一个异步方法。
初始化小程序蓝牙模块。
| 前提条件 | 无 |
| 业务背景 | 无 |
| 使用限制 | 无 |
| 注意事项 | 1. 蓝牙初始化成功后,需要及时监听蓝牙状态变化事件。 |
| 支持沙盒 | 否 |
| 相关教程 | 无 |
语法
tt.openBluetoothAdapter(options)
参数说明
options 为 object 类型,属性如下:
| 属性名 | 类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
|---|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | 1.0.0 | |
| fail | function | 否 | 接口调用失败的回调函数 | 1.0.0 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | 1.0.0 |
回调成功
object 类型,属性如下:
| 属性名 | 类型 | 说明 | 最低支持版本 |
|---|---|---|---|
| errMsg | string | "openBluetoothAdapter:ok" | 3.87.0 |
| errorCode | string | 错误码信息 | 3.87.0 |
回调失败
object 类型,属性如下:
| 属性名 | 类型 | 说明 | 最低支持版本 |
|---|---|---|---|
| errMsg | string | "openBluetoothAdapter:fail" + 详细错误信息 | 3.87.0 |
| errorCode | string | 错误码信息 | 3.87.0 |
错误码
| errorCode | errMsg | errorType | 说明 | 最低支持版本 |
|---|---|---|---|---|
| 186602 | openBluetoothAdapter:fail adapter not available | F | 小程序框架内部错误,有需要请创建工单咨询 | 3.87.0 |
| 186609 | openBluetoothAdapter:fail system error | F | 小程序框架内部错误,有需要请创建工单咨询 | 3.87.0 |
| 186688 | openBluetoothAdapter:fail system not supported | F | 小程序框架内部错误,有需要请创建工单咨询 | 3.87.0 |
| 186679 | openBluetoothAdapter:fail api scope is not declared in the privacy agreement | D | API 范围未在隐私协议中声明 | 3.87.0 |
| 186680 | openBluetoothAdapter:fail privacy permission is not authorized | U | 隐私权限未授权 | 3.87.0 |
| 186689 | openBluetoothAdapter:fail system auth deny | U | 系统鉴权失败 | 3.87.0 |
| 186690 | openBluetoothAdapter:fail auth deny | U | API 鉴权失败 | 3.87.0 |
代码示例
tt.openBluetoothAdapter({ success(res) { console.log(res) } })
