dotintent / FlutterBleLib

Bluetooth Low Energy library for Flutter with support for simulating peripherals
Apache License 2.0
535 stars 197 forks source link

Service list is not updated on Android. #529

Open vsadovyi opened 3 years ago

vsadovyi commented 3 years ago

In my case ble device, has specific flow. After we send some characteristic value ble device update list of services. After that i call method discoverAllServicesAndCharacteristics() and get updated list of services. But for Android it looks like, library return cashed list of services even after we call discoverAllServicesAndCharacteristics(). The same code works fine for iOS, and i got updated list of services.

Logs:

2020-09-24 10:38:57.002 25351-25726/com.testble.ble D/BluetoothGatt: connect() - device: EB:7B:BC:57:B2:88, auto: false 2020-09-24 10:38:57.002 25351-25726/com.testble.ble D/BluetoothGatt: registerApp() 2020-09-24 10:38:57.002 25351-25726/com.testble.ble D/BluetoothGatt: registerApp() - UUID=2873099f-f325-44d4-862e-f4e638094756 2020-09-24 10:38:57.018 25351-25394/com.testble.ble D/BluetoothGatt: onClientRegistered() - status=0 clientIf=8 2020-09-24 10:38:57.114 25351-25394/com.testble.ble D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=8 device=EB:7B:BC:57:B2:88 2020-09-24 10:38:57.115 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onConnectionStateChange newState=2 status=0 2020-09-24 10:38:57.124 25351-25726/com.testble.ble D/BluetoothGatt: configureMTU() - device: EB:7B:BC:57:B2:88 mtu: 186 2020-09-24 10:38:57.509 25351-25394/com.testble.ble D/BluetoothGatt: onPhyUpdate() - status=0 address=EB:7B:BC:57:B2:88 txPhy=2 rxPhy=2 2020-09-24 10:38:58.588 25351-25394/com.testble.ble D/BluetoothGatt: onConnectionUpdated() - Device=EB:7B:BC:57:B2:88 interval=6 latency=0 timeout=500 status=0 2020-09-24 10:38:59.136 25351-25394/com.testble.ble D/BluetoothGatt: onConfigureMTU() - Device=EB:7B:BC:57:B2:88 mtu=65 status=0 2020-09-24 10:38:59.137 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onMtuChanged mtu=65 status=0 2020-09-24 10:38:59.157 25351-25726/com.testble.ble D/BluetoothGatt: discoverServices() - device: EB:7B:BC:57:B2:88 2020-09-24 10:38:59.160 25351-25394/com.testble.ble D/BluetoothGatt: onSearchComplete() = Device=EB:7B:BC:57:B2:88 Status=0 2020-09-24 10:38:59.161 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onServicesDiscovered status=0 2020-09-24 10:38:59.218 25351-25394/com.testble.ble D/BluetoothGatt: onConnectionUpdated() - Device=EB:7B:BC:57:B2:88 interval=36 latency=0 timeout=500 status=0 2020-09-24 10:38:59.264 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onCharacteristicRead characteristic=6e400006-b5a3-f393-e0a9-e50e24dcca9e status=0 2020-09-24 10:39:01.939 25351-25351/com.testble.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 6e400009-b5a3-f393-e0a9-e50e24dcca9e enable: true 2020-09-24 10:39:02.099 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0 2020-09-24 10:39:02.189 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onCharacteristicWrite characteristic=6e400005-b5a3-f393-e0a9-e50e24dcca9e status=0 2020-09-24 10:39:02.279 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onCharacteristicWrite characteristic=6e400007-b5a3-f393-e0a9-e50e24dcca9e status=0 2020-09-24 10:39:02.290 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onCharacteristicWrite characteristic=6e400008-b5a3-f393-e0a9-e50e24dcca9e status=0 2020-09-24 10:39:02.370 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onCharacteristicChanged characteristic=6e400009-b5a3-f393-e0a9-e50e24dcca9e 2020-09-24 10:39:02.380 25351-25351/com.testble.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 6e400009-b5a3-f393-e0a9-e50e24dcca9e enable: false 2020-09-24 10:39:02.402 25351-25351/com.testble.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 6d400004-b5a3-f393-e0a9-e50e24dcca9e enable: true 2020-09-24 10:39:02.461 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0 2020-09-24 10:39:02.594 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0 2020-09-24 10:39:02.684 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onCharacteristicWrite characteristic=6d400001-b5a3-f393-e0a9-e50e24dcca9e status=0 2020-09-24 10:39:02.774 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onCharacteristicRead characteristic=6d400002-b5a3-f393-e0a9-e50e24dcca9e status=0 2020-09-24 10:39:02.863 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onCharacteristicWrite characteristic=6d400003-b5a3-f393-e0a9-e50e24dcca9e status=0 2020-09-24 10:39:02.864 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onCharacteristicChanged characteristic=6d400004-b5a3-f393-e0a9-e50e24dcca9e 2020-09-24 10:39:02.873 25351-25351/com.testble.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 6d400004-b5a3-f393-e0a9-e50e24dcca9e enable: false 2020-09-24 10:39:02.898 25351-25726/com.testble.ble D/BluetoothGatt: cancelOpen() - device: EB:7B:BC:57:B2:88 2020-09-24 10:39:02.902 25351-25394/com.testble.ble D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=8 device=EB:7B:BC:57:B2:88 2020-09-24 10:39:02.903 25351-25394/com.testble.ble D/RxBle#BluetoothGatt$1: onConnectionStateChange newState=0 status=0 2020-09-24 10:39:02.907 25351-25726/com.testble.ble D/BluetoothGatt: close() 2020-09-24 10:39:02.907 25351-25726/com.testble.ble D/BluetoothGatt: unregisterApp() - mClientIf=8

As you can see there are only one event for discoverServices(). But i call it multiple times method discoverAllServicesAndCharacteristics() after event onCharacteristicChanged characteristic=6d400004-b5a3-f393-e0a9-e50e24dcca9e.

mikolak commented 3 years ago

I'll give it a look, but it might be cached on the system layer. There's a flag to reset GATT cache, but it can only be passed when connecting. I assume it won't be sufficient for you?