# qa.openBluetoothAdapter(Object object)
初始化蓝牙模块
# 参数
# Object object
| 属性 | 类型 | 默认值  |  必填  |  说明 | 
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | 
# 错误
| 错误码 | 错误信息 | 说明 | 
|---|---|---|
| 0 | ok | 正常 | 
| 10000 | not init | 未初始化蓝牙适配器 | 
| 10001 | not available | 当前蓝牙适配器不可用 | 
| 10002 | no device | 没有找到指定设备 | 
| 10003 | connection fail | 连接失败 | 
| 10004 | no service | 没有找到指定服务 | 
| 10005 | no characteristic | 没有找到指定特征值 | 
| 10006 | no connection | 当前连接已断开 | 
| 10007 | property not support | 当前特征值不支持此操作 | 
| 10008 | system error | 其余所有系统上报的异常 | 
| 10009 | system not support | 系统不支持 | 
| 10012 | operate time out | 连接超时 | 
| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | 
# 注意
- 其他蓝牙相关 API 必须在 qa.openBluetoothAdapter 调用之后使用。否则 API 会返回错误(errCode=10000)。
 - 在用户蓝牙开关未开启或者手机不支持蓝牙功能的情况下,调用 qa.openBluetoothAdapter 会返回错误(errCode=10001),表示手机蓝牙功能不可用。此时快应用蓝牙模块已经初始化完成,可通过 qa.onBluetoothAdapterStateChange 监听手机蓝牙状态的改变,也可以调用蓝牙模块的所有 API。
 
# 示例代码
qa.openBluetoothAdapter({
  success(res) {
    console.log(res)
  }
})
 1
2
3
4
5
2
3
4
5
      ←
      
 →
    
 在线客服