Open sean7512 opened 2 years ago
I think the call in the loop may need changed to getCentralsWantingNotifications()
. Unfortunately, I have run out of time today to continue testing.
I think this is related to the other issues you are reporting. In 2.4.0 the logic for getting connected devices was changed and now uses the library internal lists rather than the OS.
I don't think so, because it doesn't work even if I turn off advertising. There are 2 methods for notifying of characteristic changed, 1 that takes a central to notify and 1 that doesn't. On the one that doesn't, it is still querying the OS and not using the internal list, as it should. When using the debugger, getCentralsWantingNotifications(characteristic)
returns the expected values, but the method is calling getConnectedCentrals()
which is returning an empty list.
I tried the example (https://github.com/weliem/bluetooth-server-example) and everything seems fine, but that is of course only a peripheral.
I can submit a PR soon, I have a local code change that is working, its a very minor change.
Thanks for continuing to help me.
Another interesting finding.....so it gets removed from the internal list because of a random onConnectionStateChange callback that says it was disconnected. If you use bluetoothManager.getConnectionState(device, BluetoothProfile.GATT)
in that call, it will return that it is connected, contradicting the notification. I wonder if we can only fall down and call handleDeviceDisconnected(device)
if the OS tells us it was disconnected?
Is there any update on this? We are facing this problem too.
I had to revert to version 2.1.2
We were not getting this problem on debug variants but on release variants (2.4.0
and 2.3.5
) onCharacteristicUpdate
was not being called.
@archie94 are you sure this is the same issue? There is no onCharacteristicUpdate
in BluetoothPeripheralManagerCallback
....
Umm .. this one
public void onCharacteristicUpdate(@NotNull BluetoothPeripheral peripheral, @NotNull byte[] value, @NotNull BluetoothGattCharacteristic characteristic, @NotNull GattStatus status) {}
in BluetoothPeripheralCallback
Also may be related but from Nordic BLE library:
https://github.com/NordicSemiconductor/Android-BLE-Library/pull/395
@archie94 , you are referring to an issue with a BluetoothPeripheral but @sean7512 is referring to an issue when notifying to a BluetoothCentral....
Please open a new issue if you still are having this issue.
I had to revert to version
2.1.2
We were not getting this problem on debug variants but on release variants (2.4.0
and2.3.5
)onCharacteristicUpdate
was not being called.
Same problem here. No problem with debug release, i need to use 2.2.3 version
When using version 2.3.4, everything works fine; however updating to 2.4.0 breaks notifying.
Inside of
BluetoothPeripheralManager
is the following:When using 2.4.0, the
getConnectedCentrals()
call is returning an empty list; however in 2.3.4, it is returning the centrals correctly.