赛捷软件论坛's Archiver

vicky.yu 发表于 2026-6-9 10:44

wx.getBLEDeviceCharacteristics(OBJECT)

基础库版本 1.1.0 开始支持,低版本需做兼容处理
获取蓝牙设备所有 characteristic(特征值)

OBJECT参数说明:

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

参数        类型        说明
characteristics        array        设备特征值列表
errMsg        string        成功:ok,错误:详细信息
characteristic对象

蓝牙设备characteristic(特征值)信息

参数        类型        说明
uuid        string        蓝牙设备特征值的 uuid
properties        object        该特征值支持的操作类型
properties对象

参数        类型        说明
read        boolean        该特征值是否支持 read 操作
write        boolean        该特征值是否支持 write 操作
notify        boolean        该特征值是否支持 notify 操作
indicate        boolean        该特征值是否支持 indicate 操作
示例代码:

wx.getBLEDeviceCharacteristics({
  // 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
  deviceId: deviceId,
  // 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
  serviceId: serviceId,
  success: function (res) {
    console.log('device getBLEDeviceCharacteristics:', res.characteristics)
  }
})

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.