Jasonchenlijian / FastBle

Android Bluetooth Low Energy (BLE) Fast Development Framework. It uses simple ways to filter, scan, connect, read ,write, notify, readRssi, setMTU, and multiConnection.
Apache License 2.0
5.28k stars 1.22k forks source link

我已解决notify的那个102 descriptor equals null 的错 #574

Open wangjinchan opened 1 year ago

wangjinchan commented 1 year ago

调试了一会儿,发现作者使用的mCharacteristic是空的,而不是从函数传入的。所以我就在BleManager.getInstance().notify这个函数里加上了characteristic;详情请看我改了哪些地方,跟着我改就可以了: image image image image image image BluetoothGattDescriptor descriptor = null; List<BluetoothGattDescriptor> descriptors = characteristic.getDescriptors(); for (BluetoothGattDescriptor desc : descriptors) { if (desc.getCharacteristic().getUuid().equals(formUUID(UUID_CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR))) { descriptor = desc; break; } }

wangjinchan commented 1 year ago

如果还有什么没看懂 ,可以问 我,邮箱:945750315@qq.com 希望作者把我拉进去一起维护。

wwxwwq commented 1 year ago

image 这里mCharacteristic不是已经赋值了吗

wangjinchan commented 1 year ago

没有,那个值是空的

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: Wenxiang Wang @.> 发送时间: 2023年6月28日 18:54 收件人: Jasonchenlijian/FastBle @.> 抄送: wangjinchan @.>, Author @.> 主题: Re: [Jasonchenlijian/FastBle] 我已解决notify的那个102 descriptor equals null 的错 (Issue #574)

wwxwwq commented 1 year ago

连接上后,扫描到服务,再开启通过,这里应该不可能空 image

wangjinchan commented 1 year ago

就是开始那个读的服务时报错了,我一层一层去打点调试出来的,改了之后,才能正常读取外围设备发的数据。

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: Wenxiang Wang @.> 发送时间: 2023年6月29日 13:54 收件人: Jasonchenlijian/FastBle @.> 抄送: wangjinchan @.>, Author @.> 主题: Re: [Jasonchenlijian/FastBle] 我已解决notify的那个102 descriptor equals null 的错 (Issue #574)

hiddus commented 1 year ago

每次都是newBleConnector characteristic每次都会赋值。 我这边状况是,write和notify是2个不同characteristic。 有时正常,读写发送都好着。 有时候,写入一次,然后接收到返回,之后再发送都是发送回调成功,实际下位机没接收到。需要重新启动APP。

alvayang commented 11 months ago

非常感谢 @wangjinchan 的讨论,通过源码和Debug发现,很可能是下位机对于一条指令的结束没有给出正确的反应,比较合理的尝试是修改MTU的大小,当然下位机是需要能支持的。

ThanatosDan commented 11 months ago

image liangg两个一样的UUID 第二个才是notify 导致了这个问题

ThanatosDan commented 11 months ago

image image 我这边这样改好像也可以