wx.getBLEDeviceServices,获取蓝牙设备所有 service(服务)
2017-12-11
导读:基础库 1.1.0 开始支持,低版本需做 兼容处理 获取蓝牙设备所有 service(服务) OBJECT参数说明: 参数 类型 必填 说明 deviceId String 是 蓝牙设备 id,参考 getDevices 接口 success Function 是 成...
基础库 1.1.0 开始支持,低版本需做兼容处理
获取蓝牙设备所有 service(服务)
OBJECT参数说明:
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
deviceId | String | 是 | 蓝牙设备 id,参考 getDevices 接口 |
success | Function | 是 | 成功则返回本机蓝牙适配器状态 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success返回参数:
参数 | 类型 | 说明 |
---|---|---|
services | Array | 设备服务列表 |
errMsg | String | 成功:ok,错误:详细信息 |
service对象
蓝牙设备service(服务)信息
参数 | 类型 | 说明 |
---|---|---|
uuid | String | 蓝牙设备服务的 uuid |
isPrimary | Boolean | 该服务是否为主服务 |
示例代码:
wx.getBLEDeviceServices({
// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
deviceId: deviceId,
success: function (res) {
console.log('device services:', res.services)
}
})
第二部分:如何开通一个小商店