小程序
小游戏
企业微信
微信支付
扫描小程序码分享
- 当前 Bug 的表现(可附上截图)
- 预期表现
- 复现路径
- 提供一个最简复现 Demo
安卓蓝牙onBLECharacteristicValueChange 收不到数据。
type: 'notification'也不行。接受的数据固定158个字节。是否有限制(20个字节)
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
MI 8 微信版本:7.0.4。系统是MIUI10.0。 代码就是用小程序自带的蓝牙模块代码。
private static final UUID CLIENT_CHARACTERISTIC_CONFIG = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
BluetoothGattDescriptor CCCD = mDeviceComm_Notify_Characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG);
if(CCCD != null) {
CCCD.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(CCCD);
}
if(!mBluetoothGatt.setCharacteristicNotification(mDeviceComm_Notify_Characteristic, true)){
LogToFile.e("zbh",mDeviceComm_Notify_Characteristic.getUuid().toString()+" 监听失败");
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
MI 8 微信版本:7.0.4。系统是MIUI10.0。 代码就是用小程序自带的蓝牙模块代码。
目前测试,同样的代码。A设备发送32字节到手机上。iOS能正常收到数据;Android不能收到任何数据。
测试B产品,C产品的蓝牙模块(不同蓝牙模块),均不能收到数据。初步判断是没有notify成功。
参考我之前的Android代码:
是可以监听成功的。
private static final UUID CLIENT_CHARACTERISTIC_CONFIG = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
BluetoothGattDescriptor CCCD = mDeviceComm_Notify_Characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG);
if(CCCD != null) {
CCCD.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(CCCD);
}
if(!mBluetoothGatt.setCharacteristicNotification(mDeviceComm_Notify_Characteristic, true)){
LogToFile.e("zbh",mDeviceComm_Notify_Characteristic.getUuid().toString()+" 监听失败");
}