- wx.onBLEConnectionStateChange IOS出现问题
在IOS上第一次连接蓝牙成功时是有回调的,但我手动把蓝牙关了就没有回调了,再把蓝牙开了也没有回调了,回调就出现过一次。 在安卓上蓝牙连接成功,关闭蓝牙和连接断开都是有回调的。 麻烦修复一下这个BUG
2017-12-07 - 更新后出现 10008 错误
更新新版后 writeBLECharacteristicValue写入数据 有百分之80的概率出现10008错误
2017-08-29 - writeBLECharacteristicValue 写入问题
[代码]//向低功耗蓝牙设备特征值中写入二进制数据[代码][代码] [代码][代码]writeBLECharacteristicValue: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码] [代码] [代码][代码]wx.onBLECharacteristicValueChange([代码][代码]function[代码] [代码](characteristic) {[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]msg_3: JSON.stringify(characteristic)[代码][代码] [代码][代码]})[代码][代码] [代码][代码]})[代码][代码] [代码] [代码] [代码][代码]// 向蓝牙设备发送一个0x00的16进制数据[代码][代码] [代码][代码]let buffer = [代码][代码]new[代码] [代码]ArrayBuffer(4)[代码][代码] [代码][代码]let dataView = [代码][代码]new[代码] [代码]DataView(buffer)[代码][代码] [代码] [代码] [代码][代码]dataView.setUint8(0, 0x0D)[代码][代码] [代码][代码]dataView.setUint8(1, 0x02)[代码][代码] [代码][代码]dataView.setUint8(2, 0x11)[代码][代码] [代码][代码]dataView.setUint8(3, 0x13)[代码][代码] [代码] [代码] [代码][代码]wx.writeBLECharacteristicValue({[代码][代码] [代码][代码]deviceId: that.data.deviceId,[代码][代码] [代码][代码]serviceId: that.data.uuid,[代码][代码] [代码][代码]characteristicId: that.data.characteristicId,[代码][代码] [代码][代码]value: buffer,[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]msg_2: JSON.stringify(res)[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码] 请问 value: buffer, 这样写对吗? 显示是成功写入的,但 onBLECharacteristicValueChange 没有回调信息
2017-08-16 - 蓝牙搜索问题
[代码]Page({[代码][代码] [代码][代码]data:{[代码][代码] [代码][代码]msg_1 : [代码][代码]""[代码][代码],[代码][代码] [代码][代码]msg_2: [代码][代码]""[代码][代码],[代码][代码] [代码][代码]msg_3: [代码][代码]""[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码]() {[代码][代码] [代码] [代码] [代码][代码]},[代码][代码] [代码][代码]searchBlueBtn: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]this[代码][代码].openBluetooth();[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//初始化蓝牙模块[代码][代码] [代码][代码]openBluetooth: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码] [代码] [代码][代码]wx.openBluetoothAdapter({[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]that.startBluetooth();[代码] [代码] [代码][代码]that.setData({[代码][代码] [代码][代码]msg_1: [代码][代码]"msg_1"[代码] [代码]+JSON.stringify(res)[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//开启蓝牙搜索[代码][代码] [代码][代码]startBluetooth:[代码][代码]function[代码][代码](e){[代码][代码] [代码][代码]var[代码] [代码]that=[代码][代码]this[代码][代码];[代码] [代码] [代码][代码]wx.startBluetoothDevicesDiscovery({[代码][代码] [代码][代码]success:[代码][代码]function[代码][代码](res){[代码][代码] [代码][代码]that.getBluetoothDevices();[代码] [代码] [代码][代码]that.setData({[代码][代码] [代码][代码]msg_2: [代码][代码]"msg_2"[代码] [代码]+JSON.stringify(res)[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//开始搜索附近蓝牙设备[代码][代码] [代码][代码]getBluetoothDevices: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码] [代码] [代码][代码]wx.getBluetoothDevices({[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]msg_3: [代码][代码]"msg_3"[代码] [代码]+JSON.stringify(res)[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]that.closeBluetooth();[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//关闭蓝牙[代码][代码] [代码][代码]closeBluetooth: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]wx.stopBluetoothDevicesDiscovery({[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) { }[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]wx.closeBluetoothAdapter({[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) { }[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码]})[代码] 昨天测试的时候,蓝牙设备列表是时有时无,今天测试的时候是一直没有过。。。。手机也重启过了,也是一样,用的是安卓手机。请问是什么问题啊
2017-08-11