Open phoebewow opened 2 years ago
都会回的呀
确实是只收到了一条数据 这两条数据下位机那边实际发送的是一条,共24个字节,但是蓝牙是20字节一包这样发送的
我下了源码放到APP里,加了时间打印,看了间隔时间应该满足啊
D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: 2022-05-19 14:59:31:855 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: A5 07 10 00 00 20 20 30 31 2D 30 30 2E 32 2E 30 31 20 20 20] D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: 2022-05-19 14:59:31:876 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: 20 1C BD 5A] D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: 2022-05-19 14:59:32:873 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: A5 07 10 00 00 20 20 30 31 2D 30 30 2E 32 2E 30 31 20 20 20] D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: 2022-05-19 14:59:32:879 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: 20 1C BD 5A]
是observer为空了,所以没有回调 D/EasyBLE: 2022-05-19 15:08:20:047 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: A5 07 10 00 00 20 20 30 31 2D 30 30 2E 32 2E 30 31 20 20 20] D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: observer is null D/EasyBLE: 2022-05-19 15:08:20:053 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: 20 1C BD 5A] D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: observer is null D/EasyBLE: 2022-05-19 15:08:21:047 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: A5 07 10 00 00 20 20 30 31 2D 30 30 2E 32 2E 30 31 20 20 20] D/BluetoothGatt: onNotify() - Device=50:33:8B:::** handle=21 D/EasyBLE: observer is null D/EasyBLE: 2022-05-19 15:08:21:071 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: 20 1C BD 5A]
之前observer为空是因为连接时没加,但是加了以后还是一样没回调第二条
D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: 2022-05-19 15:39:51:484 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: A5 07 10 00 00 20 20 30 31 2D 30 30 2E 32 2E 30 31 20 20 20] D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: 2022-05-19 15:39:51:489 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: 20 1C BD 5A] D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: 2022-05-19 15:39:52:459 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: A5 07 10 00 00 20 20 30 31 2D 30 30 2E 32 2E 30 31 20 20 20] D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: 2022-05-19 15:39:52:483 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: 20 1C BD 5A] D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: 2022-05-19 15:39:53:458 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: A5 07 10 00 00 20 20 30 31 2D 30 30 2E 32 2E 30 31 20 20 20] D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: 2022-05-19 15:39:53:484 characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: 20 1C BD 5A]
我尝试在连接到时候设置了setBluetoothGattCallback,这样可以收到数据,但变成2个进程了,会造成我拼包那里出问题
加了线程锁之后就没问题了,但是observer没回调的应该还是要看看怎么解决吧?
加了线程锁之后就没问题了,但是observer没回调的应该还是要看看怎么解决吧?
我验证了下,并没有出现你反馈的问题
看日志数据是全部接收到了的,但是回调只给了部分
D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: A5 07 10 00 00 20 20 30 31 2D 30 30 2E 32 2E 30 31 20 20 20] D/BluetoothGatt: onNotify() - Device=50:33:8B::: handle=21 D/EasyBLE: characteristic change! [UUID: 0000f1f2, addr: 50:33:8B:21:C3:5B, value: 20 1C BD 5A]
这个数据,第一条的数据有回调,第二条数据就没有 是因为这两条数据连发的原因吗?