目录
兼容性:企业微信
监听寻找到新设备。
ww.onBluetoothDeviceFound(function(event) {
console.log(event)
})
参数
event: Object
属性 | 类型 | 必填 | 说明 | |||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
devices | Object[] | 是 | 新搜索到的设备列表 | |||||||||||||||||||||||||||||||||||||||||
|
若在该接口中回调了某个设备,则此设备会添加到 getBluetoothDevices 接口返回的设备列表中
// ArrayBuffer转16进度字符串示例
function ab2hex(buffer) {
var hexArr = Array.prototype.map.call(
new Uint8Array(buffer),
function(bit) {
return ('00' + bit.toString(16)).slice(-2)
}
)
return hexArr.join('');
}
wx.onBluetoothDeviceFound(function(devices) {
console.log('new device list has founded')
console.dir(devices)
console.log(ab2hex(devices[0].advertisData))
})