出现概率多大,这个是绑定秤时的流程,取消绑定操作吧?,这个问题是调用wx.notifyBLECharacteristicValueChange 关闭通道时微信回调的错误。 应该不会影响同步数据和绑定逻辑,可以忽略。 看报错前的日志,搜索并连接上秤,读取到了设备信息,但是id是空的,那么需要去服务端申请deviceId,然后调用pushSetting 写入设备ID,这样就完成了绑定流程 详情看https://github.com/LiuXinyi/LSBlePluginDemo/blob/master/pages/DeviceMananer.js #bindDevice接口
读取数据[图片]
2020-03-30代码要放在openBluetoothAdapter的success 回调去startBluetoothDevicesDiscovery才行吧? openBluetoothAdapter是异步的,然后你按顺序写,会导致openBluetoothAdapter未成功,就先调用了startBluetoothDevicesDiscovery,导致扫描失败
Android手机 蓝牙发现不了设备使用android调试,搜索不到设备,一直都不会执行onBluetoothDeviceFound的回调。openBluetoothAdapter执行成功了,startBluetoothDevicesDiscovery也执行成功了,微信的全部权限都打开了,也重启手机了,都不行。代码: onLoad: function (options) { var page = this; wx.openBluetoothAdapter({ success: function (res) { wx.onBluetoothAdapterStateChange(function (res) { console.log(`adapterState changed, now is`, res) }) }, fail: function (res) { } }); wx.onBluetoothDeviceFound(devices => { console.log('new device list has founded', devices); }); wx.startBluetoothDevicesDiscovery({ services: [], success: function (res) { console.log('startBluetoothDevicesDiscovery: success => ', res); }, fail: function (res) { console.log('fail => ', res) } }); },
2018-05-14