Safe Bluetooth
Uses coroutines to safely access a bluetooth GATT device with a synchronous API
The BTLE API on android is dumb. You can only have one outstanding operation in flight to the device. If you try to do something when something is pending, the operation just returns false. You are expected to chain your operations from the results callbacks.
This class fixes the API by using coroutines to let you safely do a series of BTLE operations.
Properties
Functions
Close and destroy this SafeBluetooth instance. You'll need to make a new instance before using it again
Close down any existing connection, any existing calls (including async connects will be cancelled and you'll need to recall connect to use this againt
Close just the GATT device but keep our pending callbacks active
Attempts an emergency restart of the Bluetooth adapter. This is a workaround for certain BLE stack issues. It checks for necessary permissions (BLUETOOTH_CONNECT on API 31+, BLUETOOTH_ADMIN on older versions) before attempting to disable and then re-enable the adapter.