微信小程序 监听特征值返回成功但是没有真正的监听成功

小程序 文章 2021-01-28 11:21 1126 0 全屏看文

AI助手支持GPT4.0

微信小程序 监听特征值返回成功但是没有真正的监听成功Wechat Mini Program The monitoring feature value returns successfully but there is no real monitoring success

微信小程序 监听特征值返回成功但是没有真正的监听成功
框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.notifyBLECharacteristicValueChange 微信安卓客户端 8.0.0 2.14.0

这个问题仅在安卓手机上会出现,并且只在特定的芯片中出现。

1、蓝牙连接成功后,获取设备服务成功后,获取设备特征值成功后进行监听蓝牙特征值变化。

wx.notifyBLECharacteristicValueChange({              deviceId:deviceId,              serviceId:serviceId,              characteristicId: NotifyCharactersticUUID,              statetrue,              success:(res2) =>{                   console.log('监听特征值成功',res2)                },              fail:(res2) => {                console.log("notify fail", res2)              },              complete:(res2) =>{                                      wx.onBLECharacteristicValueChange((characteristic) => {                  const data = Array.prototype.slice.call(new Uint8Array(characteristic.value ))                  console.log('设备返回的特征值',data)                  father.onCharacteristicsHandler(data)                })              }            })


2、这个时候可以看到接口返回的是监听特征值成功了

但是这个时候一直没有特征值返回。

3、于是打开另一个软件nRF Connect 连接上这台设备,并在这里监听特征值变化


4、监听成功后,我返回到小程序,可以看到此时立即有特征值返回了

5、可以判断是接口没有真正的监听特征值成功。


Framework type problem type API / component name terminal type wechat version basic library version applet bug wx.notifyBLECharacteristicValueChange Wechat Android client 8.0.0 2.14.0 this problem only appears on Android phones, and only in specific chips. 1. After the Bluetooth connection is successful, the device service is obtained successfully, and the device characteristic value is obtained successfully, then the Bluetooth characteristic value change is monitored. wx.notifyBLECharacteristicValueChange ({               deviceId:deviceId ,               serviceId:serviceId ,              characteristicId: NotifyCharactersticUUID,              state: true,               success:(res2) =>{                    console.log ('monitoring eigenvalue succeeded ', res2)}, fail: (res2) = > { console.log ("notify fail", res2)              },               complete:(res2) =>{                                       wx.onBLECharacteristicValueChange ((characteristic) => {                  const data =  Array.prototype.slice .call(new Uint8Array( characteristic.value  ))                   console.log (' Characteristic value 'returned by the device, data) father.onCharacteristicsHandler (data)})} (2. At this time, we can see that the interface returns the listening eigenvalue successfully, but no eigenvalue has been returned at this time. 3. So open another software NRF connect to connect to this device, and monitor the change of characteristic value here. 4. After the monitoring is successful, I return to the small program, and you can see that the characteristic value is returned immediately. 5. It can be judged that the interface is not monitoring the characteristic value successfully.

回答:

belief:

开启,监听,发送,接受 这样只要向设备发送了数据,就能接受到数据啊


Ain:

我一直把onBLECharacteristicValueChange写在notifyBLECharacteristicValueChange的前面,没有出现过你说的问题,可以试一下能不能解决。

斑马:监听低功耗蓝牙设备的特征值变化事件。必须先启用 notifyBLECharacteristicValueChange 接口才能接收到设备推送的 notification。
斑马:

请问这个bug什么时候会解决?

-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
企业微信获取部门成员详情有的部门只能获取个别用户
小程序上请求接口特别慢,网页上请求是毫秒级的?
小程序能不能发布美女视频什么的啊?
微信小程序分享到朋友圈之后打开,打开的单页应用的生命周期是什么?
公众号在没有任何违规的情况下,搜索突然被降权?
随便看看
企业微信通讯录账号被管理员误/恶意删除,怎么办? 9568
问题? 9048
如何快速搭建抽奖助手小程序(无需代码知识) 6177
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 7472
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 6793
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 6128
如何解决渲染层网络错误Failed to load media? 17393
小程序找号找回 释放昵称? 3253
我的小程序广告主收入5301,实际进账4406,是怎么回事呀? 3108
删除部分微信用户个人数据的通知,怎么删除? 6381