我知道原因了!!!大家查下自己的getBLEDeviceCharacteristics获取特征值里面的read是false还是true,不走回调肯定是false!那就跟你getBLEDeviceServices获取服务选的uuid有关系了,把返回的数组里的uuid都试一遍!我的试到最后一个read才是true,最后走了回调[图片]
wx.onBLECharacteristicValueChange 在安卓无回调help,wx.onBLECharacteristicValueChange 在android上无法接受返回值,notify开启是成功的,有趣的是在iOS下面一切正常,问了好多人,又说开启notify之后立即就调用了write会发生问题,尝试了延迟和重发依旧没有任何返回值,下图是测试返回的结果 ···························································································································· [图片] 上图是在ios设备的截图,能接收到返回值 ·································································································· [图片] 这实在android设备的,没有返回值 ··································································································· - 求问技术支持,这问题该如何解决,是否有解决方案,下面贴出我的代码,帮忙看看是不是我写的有问题 [代码]Page({[代码] [代码] [代码][代码]/** 页面的初始数据 */[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]deviceId: [代码][代码]'FD:76:74:35:99:92'[代码][代码],[代码][代码] [代码][代码]serviceId: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]services: [],[代码][代码] [代码][代码]writeCharacteristicsId: [代码][代码]""[代码][代码], [代码][代码]// 可写特征值uuid[代码][代码] [代码][代码]readCharacteristicsId: [代码][代码]""[代码][代码], [代码][代码]// 可读特征值uuid[代码][代码] [代码][代码]notifyCharacteristicsId: [代码][代码]""[代码][代码], [代码][代码]// 通知特征值uuid[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]/** 生命周期函数--监听页面加载 */[代码][代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码](opt) {[代码][代码] [代码][代码]//初始化蓝牙适配器[代码][代码] [代码][代码]wx.openBluetoothAdapter({[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]"初始化蓝牙适配器成功"[代码][代码], res);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码] [代码](err) {[代码][代码] [代码][代码]console.log([代码][代码]"初始化失败"[代码][代码], err)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]//监听蓝牙适配器状态变化事件[代码][代码] [代码][代码]wx.onBluetoothAdapterStateChange(res => {[代码][代码] [代码][代码]console.log([代码][代码]"状态变化"[代码][代码], res)[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]start: [代码][代码]function[代码][代码]() {[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码];[代码] [代码] [代码][代码]console.log([代码][代码]'监听设备的连接状态'[代码][代码]);[代码] [代码] [代码][代码]/** 连接设备 */[代码][代码] [代码][代码]wx.createBLEConnection({[代码][代码] [代码][代码]deviceId: that.data.deviceId,[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]'连接设备'[代码][代码], res);[代码] [代码] [代码][代码]/** 监听设备的连接状态 */[代码][代码] [代码][代码]wx.onBLEConnectionStateChanged([代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`)[代码][代码] [代码][代码]});[代码] [代码] [代码][代码]/** 连接成功,后开始获取设备的服务列表 */[代码][代码] [代码][代码]wx.getBLEDeviceServices({[代码][代码] [代码][代码]deviceId: that.data.deviceId,[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]'device services:'[代码][代码], res);[代码] [代码] [代码][代码]that.setData({ services: res.services, serviceId: res.services[0].uuid }, () => {[代码] [代码] [代码][代码]wx.getBLEDeviceCharacteristics({[代码][代码] [代码][代码]deviceId: that.data.deviceId,[代码][代码] [代码][代码]serviceId: that.data.serviceId,[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]'device getBLEDeviceCharacteristics:'[代码][代码], res.characteristics);[代码] [代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]i = 0; i < res.characteristics.length; i++) {[代码][代码] [代码][代码]if[代码] [代码](res.characteristics[i].properties.notify) {[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]notifyCharacteristicsId: res.characteristics[i].uuid[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](res.characteristics[i].properties.write) {[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]writeCharacteristicsId: res.characteristics[i].uuid[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](res.characteristics[i].properties.read) {[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]readCharacteristicsId: res.characteristics[i].uuid[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]/** 顺序开发设备特征notifiy */[代码][代码] [代码][代码]wx.notifyBLECharacteristicValueChanged({[代码][代码] [代码][代码]deviceId: that.data.deviceId,[代码][代码] [代码][代码]serviceId: that.data.serviceId,[代码][代码] [代码][代码]characteristicId: that.data.notifyCharacteristicsId,[代码][代码] [代码][代码]state: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]'notifyBLECharacteristicValueChanged success'[代码][代码], res);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码] [代码](res) { console.log([代码][代码]'notifyBLECharacteristicValueChanged fail :'[代码][代码], res) },[代码][代码] [代码][代码]complete: [代码][代码]function[代码] [代码](res) { }[代码][代码] [代码][代码]});[代码] [代码] [代码][代码]/** 回调获取 设备发过来的数据 */[代码][代码] [代码][代码]wx.onBLECharacteristicValueChange([代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]'characteristic value comed:'[代码][代码], res.value);[代码][代码] [代码][代码]//{value: ArrayBuffer, deviceId: "D8:00:D2:4F:24:17", serviceId: "ba11f08c-5f14-0b0d-1080-007cbe238851-0x600000460240", characteristicId: "0000cd04-0000-1000-8000-00805f9b34fb-0x60800069fb80"}[代码] [代码] [代码][代码]let buffer = res.value[代码][代码] [代码][代码]let dataView = [代码][代码]new[代码] [代码]DataView(buffer)[代码][代码] [代码][代码]let dataResult = [][代码][代码] [代码][代码]for[代码] [代码](let i = 0; i < dataView.byteLength; i++) {[代码][代码] [代码][代码]dataResult.push(dataView.getUint8(i).toString(16))[代码][代码] [代码][代码]}[代码][代码] [代码][代码]const result = dataResult[代码][代码] [代码][代码]console.log(result);[代码][代码] [代码][代码]});[代码] [代码] [代码][代码]/** 发送开锁命令 */[代码][代码] [代码][代码]that.send();[代码] [代码] [代码][代码]}, fail: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]'失败'[代码][代码], res);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]/** 发送 数据到设备中 */[代码][代码] [代码][代码]send: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码], hex = [代码][代码]'100031B0000018FFFFFFFF0000008900'[代码][代码];[代码][代码] [代码][代码]const typedArray = [代码][代码]new[代码] [代码]Uint8Array(hex.match(/[\da-f]{2}/gi).map([代码][代码]function[代码] [代码](h) { [代码][代码]return[代码] [代码]parseInt(h, 16) }))[代码][代码] [代码][代码]console.log(typedArray);[代码][代码] [代码][代码]const buffer1 = typedArray.buffer[代码][代码] [代码][代码]console.log(buffer1)[代码] [代码] [代码][代码]wx.writeBLECharacteristicValue({[代码][代码] [代码][代码]deviceId: that.data.deviceId,[代码][代码] [代码][代码]serviceId: that.data.serviceId,[代码][代码] [代码][代码]characteristicId: that.data.writeCharacteristicsId,[代码][代码] [代码][代码]value: buffer1,[代码] [代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]"success 指令发送成功"[代码][代码]);[代码][代码] [代码][代码]console.log(res);[代码] [代码] [代码][代码]/** 读取设备 */[代码][代码] [代码][代码]// setTimeout(() => {[代码][代码] [代码][代码]// wx.readBLECharacteristicValue({[代码][代码] [代码][代码]// deviceId: that.data.deviceId,[代码][代码] [代码][代码]// serviceId: that.data.serviceId,[代码][代码] [代码][代码]// characteristicId: that.data.readCharacteristicsId,[代码][代码] [代码][代码]// success: function (res) {[代码][代码] [代码][代码]// console.log('readBLECharacteristicValue:', res);[代码][代码] [代码][代码]// }[代码][代码] [代码][代码]// })[代码][代码] [代码][代码]// }, 3000)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码] [代码](res) { console.log(res); }[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]/** 生命周期函数--监听页面初次渲染完成 */[代码][代码] [代码][代码]onReady: [代码][代码]function[代码] [代码]() { },[代码] [代码] [代码][代码]/** 生命周期函数--监听页面显示 */[代码][代码] [代码][代码]onShow: [代码][代码]function[代码] [代码]() { },[代码] [代码] [代码][代码]/** 生命周期函数--监听页面隐藏 */[代码][代码] [代码][代码]onHide: [代码][代码]function[代码] [代码]() { },[代码] [代码] [代码][代码]/** 生命周期函数--监听页面卸载, 同时断开蓝牙 */[代码][代码] [代码][代码]onUnload: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]let me = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]wx.closeBLEConnection({[代码][代码] [代码][代码]deviceId: me.data.deviceId,[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]"蓝牙断开"[代码][代码], res)[代码][代码] [代码][代码]me.setData({ deviceId: [代码][代码]""[代码][代码], })[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码] [代码]})[代码] 在线等。
2022-06-17真的无敌了,疯狂打印request begin,request success
ios 上每次在vconsole会显示request begin,request successvconsole 总是会显示你们自己的日志(当发生http通信/下载资源时候),能不能给取消,比较影响我们看自己的日志
2021-01-08官方也不给答复了
wx.chooseimage拍照后无编辑图片按钮wx.chooseimage拍照后的编辑功能? 以前有编辑功能,最近该功能没了,请问如何打开? 小程序为大学生作业系统,拍照后需要编辑掉空白和方向,影响面很大,望能尽快解决!谢谢!(没有编辑功能,用户体验极其差) https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseImage.html
2020-12-25解决了吗?我的也这样
真机调试连接方式总是显示 未连接?[图片]真机调试连接方式总是显示 未连接?怎么回事?
2020-09-02最简单的方法把安装目录的微信开发者工具的中文名改成英文名就可以了
打开最新版本开发者工具一直黑屏,要怎么解决?1.02.2004020window7系统 打开后一直黑屏,登录的码弹框一直黑屏 [图片]
2020-08-19