177-371-24501(同微信)

wx.readBLECharacteristicValue,读取低功耗蓝牙设备的特征值的二进制数据值

2022-04-21 管理员

基础库 1.1.0 开始支持,低版本需做兼容处理

读取低功耗蓝牙设备的特征值的二进制数据值。注意:必须设备的特征值支持read才可以成功调用,具体参照 characteristic 的 properties 属性

OBJECT参数说明:

参数 类型 必填 说明
deviceId String 蓝牙设备 id,参考 device 对象
serviceId String 蓝牙特征值对应服务的 uuid
characteristicId String 蓝牙特征值的 uuid
success Function 成功则返回本机蓝牙适配器状态
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

success返回参数:

参数 类型 说明
errCode Number 错误码
errMsg String 成功:ok,错误:详细信息

示例代码:

// 必须在这里的回调才能获取
wx.onBLECharacteristicValueChange(function(characteristic) {
  console.log('characteristic value comed:', characteristic)
})

wx.readBLECharacteristicValue({
  // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接  [**new**]
  deviceId: deviceId,
  // 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
  serviceId: serviceId,
  // 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取
  characteristicId: characteristicId,
  success: function (res) {
    console.log('readBLECharacteristicValue:', res.errCode)
  }
})
上一篇:wx.writeBLECharacteristicValue,向低功耗蓝牙设备特征值中写入二进制数据
下一篇:wx.getBLEDeviceCharacteristics,获取蓝牙设备某个服务中的所有 characteristic(特征值)
相关资讯 Releva ntnews
解决方案 Solutions
相关热点 Hot spot
快速提升网站排名的方法
  1. 我们的优势
  2. 我们的实力
  3. 选择我们的理由
咨询电话(微信同号)

177-371-24501(同微信)

豫ICP备17049932号

Copyright © 2017-2022 版权所有 追风建站 Rights Reserved 技术支持:酷微科技

电话咨询 在线咨询 服务项目 SEO优化