aws / amazon-freertos-ble-android-sdk

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

Fix exception while unregistering broadcast receiver #14

Closed ravibhagavandas closed 4 years ago

ravibhagavandas commented 4 years ago

Issue #, if available: Fixes #13

Description of changes: disconnect() method in AmazonFreeRTOSDevice unregisters the broadcast receiver, which gets registered only on a valid connection. It throws an exception if the disconnect() is invoked before a valid connection is made.

Fix: Catch not registered exception while unregistering broadcast receiver. Also moved gattclient.close() to first method being invoked.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.