chipweinberger / flutter_blue_plus

Flutter plugin for connecting and communicationg with Bluetooth Low Energy devices, on Android, iOS, macOS
Other
788 stars 478 forks source link

[Help]: Getting List<int> length as zero even after the BLE device sending the notification on iOS #1026

Closed EINS-SD-MOHAMMED closed 1 month ago

EINS-SD-MOHAMMED commented 1 month ago

Requirements

Have you checked this problem on the example app?

No

FlutterBluePlus Version

1.33.5

Flutter Version

3.24.3

What OS?

iOS

OS Version

18.0.1

Bluetooth Module

Nedap Nvite Reader

What is your problem?

It seems that on iOS, we're not receiving any data, even though the BLE device has sent it. We’re getting a List with a length of zero(maceCharacteristics event), which suggests that the notifications are not being properly received or processed. We have also used chr.setNotifyValue on the characteristics, but the issue persists.The same is working correctly on Android even after removing the desc.write(..) and just calling the chr.setNotifyValue.

Logs

iOS Logs
[FBP-iOS] handleMethodCall: connect
[FBP-iOS] didConnectPeripheral
[FBP-iOS] handleMethodCall: discoverServices
[FBP-iOS] didDiscoverServices:
[FBP-iOS]   svc: 180a
[FBP-iOS]   svc: 87b1de8d-e7cb-4ea8-a8e4-290209522c83
[FBP-iOS] didDiscoverCharacteristicsForService:
[FBP-iOS]   svc: 180a
[FBP-iOS]     chr: 2a25
[FBP-iOS]     chr: 2a27
[FBP-iOS]     chr: 2a26
[FBP-iOS]     chr: 2a28
[FBP-iOS]     chr: 2a29
[FBP-iOS]     chr: 2a24
[FBP-iOS] didDiscoverCharacteristicsForService:
[FBP-iOS]   svc: 87b1de8d-e7cb-4ea8-a8e4-290209522c83
[FBP-iOS]     chr: e68a5c09-aef8-4447-8f10-f3339898dee9
[FBP-iOS]     chr: 54080bd6-d573-11e5-ab30-625662870761
[FBP-iOS]     chr: 540810c2-d573-11e5-ab30-625662870761
[FBP-iOS] didDiscoverDescriptorsForCharacteristic:
[FBP-iOS]   chr: 2a25
[FBP-iOS] didDiscoverDescriptorsForCharacteristic:
[FBP-iOS]   chr: 2a27
[FBP-iOS] didDiscoverDescriptorsForCharacteristic:
[FBP-iOS]   chr: 2a26
[FBP-iOS] didDiscoverDescriptorsForCharacteristic:
[FBP-iOS]   chr: 2a28
[FBP-iOS] didDiscoverDescriptorsForCharacteristic:
[FBP-iOS]   chr: 2a29
[FBP-iOS] didDiscoverDescriptorsForCharacteristic:
[FBP-iOS]   chr: 2a24
[FBP-iOS] didDiscoverDescriptorsForCharacteristic:
[FBP-iOS]   chr: e68a5c09-aef8-4447-8f10-f3339898dee9
[FBP-iOS] didDiscoverDescriptorsForCharacteristic:
[FBP-iOS]   chr: 54080bd6-d573-11e5-ab30-625662870761
[FBP-iOS] didDiscoverDescriptorsForCharacteristic:
[FBP-iOS]   chr: 540810c2-d573-11e5-ab30-625662870761
[FBP-iOS]     desc: 2902
[FBP-iOS] handleMethodCall: setNotifyValue
[FBP-iOS] didUpdateNotificationStateForCharacteristic:
[FBP-iOS]   chr: 540810c2-d573-11e5-ab30-625662870761
flutter: The status of setNotifyValue true
flutter: MACE_CHALLENGE characteristic properties: CharacteristicProperties{broadcast: false, read: true, writeWithoutResponse: false, write: false, notify: true, indicate: false, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}
[FBP-iOS] handleMethodCall: writeCharacteristic
flutter: BluetoothDescriptor{remoteId: 3FDD4B45-0565-AF43-DE53-6BA68C1203E8, serviceUuid: 87b1de8d-e7cb-4ea8-a8e4-290209522c83, characteristicUuid: 540810c2-d573-11e5-ab30-625662870761, descriptorUuid: 2902, lastValue: [1, 0, 0, 0]}
flutter: Just before the descriptor write
flutter: Notifications enabled for MACE_CHALLENGE characteristic.
[FBP-iOS] handleMethodCall: writeCharacteristic
[FBP-iOS] didWriteValueForCharacteristic:
[FBP-iOS]   chr: e68a5c09-aef8-4447-8f10-f3339898dee9
flutter: Inside the lastValueStream method
flutter: The maceCharacteristics Event is 0
flutter: The mace Event is []
flutter: 080000000000004523 is of chart
flutter: macecharacteristic event found empty
[FBP-iOS] didDisconnectPeripheral:
[FBP-iOS]   error: The specified device has disconnected from us.
flutter: disconnedted from the device

Android
D/[FBP-Android](18776): [FBP] onMethodCall: connect
D/BluetoothAdapter(18776): getBleEnabledArray(): ON
D/CompatibilityChangeReporter(18776): Compat change id reported: 265103382; UID 10306; state: ENABLED
D/BluetoothGatt(18776): connect() - device: XX:XX:XX:XX:36:BA, auto: false
D/BluetoothGatt(18776): registerApp()
D/BluetoothGatt(18776): registerApp() - UUID=4505348e-550d-434f-98c1-9857e5035599
D/BluetoothGatt(18776): onClientRegistered() - status=0 clientIf=5
D/[FBP-Android](18776): [FBP] onMethodCall: getAdapterState
D/BluetoothAdapter(18776): getBleEnabledArray(): ON
D/BluetoothGatt(18776): onClientConnectionState() - status=0 clientIf=5 device=XX:XX:XX:XX:36:BA
D/[FBP-Android](18776): [FBP] onConnectionStateChange:connected
D/[FBP-Android](18776): [FBP]   status: SUCCESS
D/[FBP-Android](18776): [FBP] onMethodCall: discoverServices
D/BluetoothGatt(18776): discoverServices() - device: XX:XX:XX:XX:36:BA
D/BluetoothGatt(18776): onConnectionUpdated() - Device=XX:XX:XX:XX:36:BA interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt(18776): onSearchComplete() = Device=XX:XX:XX:XX:36:BA Status=0
D/[FBP-Android](18776): [FBP] onServicesDiscovered:
D/[FBP-Android](18776): [FBP]   count: 4
D/[FBP-Android](18776): [FBP]   status: 0GATT_SUCCESS
D/[FBP-Android](18776): [FBP] onMethodCall: setNotifyValue
D/BluetoothGatt(18776): setCharacteristicNotification() - uuid: 00002a05-0000-1000-8000-00805f9b34fb enable: true
D/BluetoothGatt(18776): onConnectionUpdated() - Device=XX:XX:XX:XX:36:BA interval=39 latency=0 timeout=500 status=0
D/[FBP-Android](18776): [FBP] onDescriptorWrite:
D/[FBP-Android](18776): [FBP]   chr: 2a05
D/[FBP-Android](18776): [FBP]   desc: 2902
D/[FBP-Android](18776): [FBP]   status: GATT_SUCCESS (0)
D/[FBP-Android](18776): [FBP] onMethodCall: setNotifyValue
D/BluetoothGatt(18776): setCharacteristicNotification() - uuid: 540810c2-d573-11e5-ab30-625662870761 enable: true
D/[FBP-Android](18776): [FBP] onCharacteristicChanged:
D/[FBP-Android](18776): [FBP]   chr: 540810c2-d573-11e5-ab30-625662870761
D/[FBP-Android](18776): [FBP] onDescriptorWrite:
D/[FBP-Android](18776): [FBP]   chr: 540810c2-d573-11e5-ab30-625662870761
D/[FBP-Android](18776): [FBP]   desc: 2902
D/[FBP-Android](18776): [FBP]   status: GATT_SUCCESS (0)
I/flutter (18776): The status of setNotifyValue true
I/flutter (18776): MACE_CHALLENGE characteristic properties: CharacteristicProperties{broadcast: false, read: true, writeWithoutResponse: false, write: false, notify: true, indicate: false, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}
D/[FBP-Android](18776): [FBP] onMethodCall: writeCharacteristic
I/flutter (18776): BluetoothDescriptor{remoteId: FC:0F:E7:68:36:BA, serviceUuid: 87b1de8d-e7cb-4ea8-a8e4-290209522c83, characteristicUuid: 540810c2-d573-11e5-ab30-625662870761, descriptorUuid: 2902, lastValue: [1, 0]}
I/flutter (18776): Just before the descriptor write
D/[FBP-Android](18776): [FBP] onMethodCall: writeDescriptor
D/[FBP-Android](18776): [FBP] onCharacteristicChanged:
D/[FBP-Android](18776): [FBP]   chr: 540810c2-d573-11e5-ab30-625662870761
D/[FBP-Android](18776): [FBP] onDescriptorWrite:
D/[FBP-Android](18776): [FBP]   chr: 540810c2-d573-11e5-ab30-625662870761
D/[FBP-Android](18776): [FBP]   desc: 2902
D/[FBP-Android](18776): [FBP]   status: GATT_SUCCESS (0)
I/flutter (18776): Notifications enabled for MACE_CHALLENGE characteristic.
D/[FBP-Android](18776): [FBP] onMethodCall: writeCharacteristic
D/[FBP-Android](18776): [FBP] onCharacteristicChanged:
D/[FBP-Android](18776): [FBP]   chr: 540810c2-d573-11e5-ab30-625662870761
D/[FBP-Android](18776): [FBP] onCharacteristicWrite:
D/[FBP-Android](18776): [FBP]   chr: e68a5c09-aef8-4447-8f10-f3339898dee9
D/[FBP-Android](18776): [FBP]   status: GATT_SUCCESS (0)
I/flutter (18776): 080000000000000521 is of chart
I/flutter (18776): event length is 9
I/flutter (18776): inside the maceCharacteristics 
I/flutter (18776): after converting
I/flutter (18776): bt 418704ef2c7754ff7c
I/flutter (18776): 418704ef2c7754ff7c is of maceCharacteristics
I/flutter (18776): inside
I/flutter (18776): dcf2d39124dea20a39e9d94a7fdfe0f3
I/flutter (18776): [135, 4, 239, 44, 119, 84, 255, 124]
I/flutter (18776): RNDA: 66f0fc7482d2a8f0
I/flutter (18776): RNDB*: 04ef2c7754ff7c87
I/flutter (18776): RNDA + RNDB*: 66f0fc7482d2a8f004ef2c7754ff7c87
I/flutter (18776): dcf2d39124dea20a39e9d94a7fdfe0f3
I/flutter (18776): 47eb6016544481d5a247bc59e4a27912
I/flutter (18776): Encrypted message: 47eb6016544481d5a247bc59e4a27912
D/[FBP-Android](18776): [FBP] onMethodCall: writeCharacteristic
D/[FBP-Android](18776): [FBP] onCharacteristicChanged:
D/[FBP-Android](18776): [FBP]   chr: 540810c2-d573-11e5-ab30-625662870761
D/[FBP-Android](18776): [FBP] onCharacteristicWrite:
D/[FBP-Android](18776): [FBP]   chr: 54080bd6-d573-11e5-ab30-625662870761
D/[FBP-Android](18776): [FBP]   status: GATT_SUCCESS (0)
I/flutter (18776): event length is 17
I/flutter (18776): inside the maceCharacteristics 
I/flutter (18776): after converting
I/flutter (18776): bt 43efc969fe220c842e27151a4b4d3f4947
I/flutter (18776): 43efc969fe220c842e27151a4b4d3f4947 is of maceCharacteristics
D/BluetoothGatt(18776): onClientConnectionState() - status=19 clientIf=5 device=XX:XX:XX:XX:36:BA
D/[FBP-Android](18776): [FBP] onConnectionStateChange:disconnected
D/[FBP-Android](18776): [FBP]   status: REMOTE_USER_TERMINATED_CONNECTION
D/BluetoothGatt(18776): close()
D/BluetoothGatt(18776): unregisterApp() - mClientIf=5
chipweinberger commented 1 month ago

not sure. if you figure it out, please tell me.

FBP, is a thin wrapper, so this is probably not something we can fix. Most likely an OS or peripheral firmware problem.