aws / amazon-freertos-ble-android-sdk

Android SDK for FreeRTOS Bluetooth Devices.
Apache License 2.0
49 stars 41 forks source link

onBleConnectionStatusChanged callback is not called in BLE_CONNECTED case #40

Closed cwalstad closed 3 years ago

cwalstad commented 3 years ago

Describe the bug The SDK allows clients to register a callback for BLE connection status changes. The callback is not called in the BLE_CONNECTED case.

I believe this behavior was broken in this change: https://github.com/aws/amazon-freertos-ble-android-sdk/commit/02e3b23bf614fa4bb1cdb1e7af579e56cb10fb2f

Specifically this line was removed: https://github.com/aws/amazon-freertos-ble-android-sdk/commit/02e3b23bf614fa4bb1cdb1e7af579e56cb10fb2f#diff-78fe5461821fc69ea3e2b628ae293eb60bd1b34b427f5aef8e4721fb9f95ec91L436

Build info What is the branch and commit on the device side?
What is the branch and tag the SDK side? https://github.com/aws/amazon-freertos-ble-android-sdk/releases/tag/v1.2.0 Does pulling the latest code help resolve the issue? No

System info What is the Android version? Android version 10 What is the bluetooth version? Tested on Samsung Galaxy A71 which has Bluetooth v5. I don't believe this is a version/phone specific bug though.

To Reproduce What is the frequency of this issue? 100% Steps to reproduce the behavior:

Register a callback and connect to a device. Observe that it is never called in the BLE_CONNECTED case.

 amazonFreeRTOSManager.connectToDevice(bleDevice.getDevice(), new BleConnectionStatusCallback() {
            @Override
            public void onBleConnectionStatusChanged(AmazonFreeRTOSConstants.BleConnectionState connectionStatus) {

...

Log Could you provide log on both the device side and SDK side?

Additional context Add any other context about the problem here.

ravibhagavandas commented 3 years ago

Hi,

Thanks for bringing this up. Here is the PR which fixes the issue by adding back the callback #41. Please note that the applications still needs to wait for BLE_INITIALIZED state before sending/receiving data. BLE_CONNECTED is an intermediate state, is still useful for debugging purposes.

The PR also cleans up duplicate code in onConnectionStateChangeCallback()

pvyawaha commented 3 years ago

Hello,

Does the above fix resolves your issue?

ravibhagavandas commented 3 years ago

Closing this issue. Please feel to repoen if you have more questions.