小程序
小游戏
企业微信
微信支付
扫描小程序码分享
今天发现小程序可以支持安卓蓝牙API了,但测试了下wx.getBluetoothDevices这个API报错!
另外向非低功耗蓝牙设备发送数据的场景如何实现?比如我要使用蓝牙便携打印机(非低功耗蓝牙)
11 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
刚才尝试了安卓和苹果的手机返回来的数据不一样,这样子输出出来看看就知道了,但是这个
这个接口没有实时的数据返回来
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
请官方人员来解答下么?
有官方人员来解答下么?
7楼没错,而且,可以用另了一个方式去获取,就是通过
所以小程序app无法发现蓝牙设备。
四楼:您说蓝牙设备为0时wx.getBluetoothDevices才报错,感觉不对,手机发现的蓝牙设备有好几个(连接和不连接的),况且wx.getConnectedBluetoothDevices可以取得蓝牙设备一个,这如何解释?还是觉得这个API没做好
四楼,为啥发现的蓝牙设备为0,我测试的时候,旁边有好几个蓝牙,接口有问题吧
怎么解决?
这个报错是由于发现的蓝牙设备为0的时候导致的。
如果你发现至少一个设备后,就不会报错了
同遇到thirdScriptError wx.getBluetoothDevices,报错
Page({
onLoad: function () {
//var that = this;
wx.openBluetoothAdapter({
success: function (res) {
console.log(res)
wx.getBluetoothAdapterState({
}
})
wx.startBluetoothDevicesDiscovery({
wx.getConnectedBluetoothDevices({
wx.getBluetoothDevices({
//services: ['0019E0A29C02'],
// that.setData({
// // BLT_name: res.devices[0].name,
// // BLT_deviceId: res.devices[0].deviceId,
// // BLT_RSSI: res.devices[0].RSSI
// // BLT_advertisData: res.devices[0].advertisData
// })
控制台输出,就wx.getBluetoothDevices报错,其他四个API正常。
错误代码:cannot read property 'map' of undefined
正在加载...
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
wx.onBLECharacteristicValueChange(CALLBACK)
这个接口没有实时的数据返回来
请官方人员来解答下么?
有官方人员来解答下么?
7楼没错,而且,可以用另了一个方式去获取,就是通过
wx.onBluetoothDeviceFound(CALLBACK) 来获取,但实际上,手机可以发现蓝牙,但不会进入到这个事件函数中去。
所以小程序app无法发现蓝牙设备。
四楼:您说蓝牙设备为0时wx.getBluetoothDevices才报错,感觉不对,手机发现的蓝牙设备有好几个(连接和不连接的),况且wx.getConnectedBluetoothDevices可以取得蓝牙设备一个,这如何解释?还是觉得这个API没做好
四楼,为啥发现的蓝牙设备为0,我测试的时候,旁边有好几个蓝牙,接口有问题吧
怎么解决?
这个报错是由于发现的蓝牙设备为0的时候导致的。
如果你发现至少一个设备后,就不会报错了
同遇到thirdScriptError wx.getBluetoothDevices,报错
Page({
onLoad: function () {
//var that = this;
wx.openBluetoothAdapter({
success: function (res) {
console.log(res)
wx.getBluetoothAdapterState({
success: function (res) {
console.log(res)
}
})
wx.startBluetoothDevicesDiscovery({
success: function (res) {
console.log(res)
}
})
wx.getConnectedBluetoothDevices({
success: function (res) {
console.log(res)
}
})
wx.getBluetoothDevices({
//services: ['0019E0A29C02'],
success: function (res) {
console.log(res)
// that.setData({
// // BLT_name: res.devices[0].name,
// // BLT_deviceId: res.devices[0].deviceId,
// // BLT_RSSI: res.devices[0].RSSI
// // BLT_advertisData: res.devices[0].advertisData
// })
}
})
}
})
}
})
控制台输出,就wx.getBluetoothDevices报错,其他四个API正常。
错误代码:cannot read property 'map' of undefined