Ble Gatt Callback
Custom implementation of BluetoothGattCallback that handles all GATT client events.
This callback acts as a bridge between the Android Bluetooth stack and the ConnectionStateMachine, translating low-level GATT events into state machine transitions and operations.
Handled GATT Events
Connection State Changes: Connect/disconnect events
Service Discovery: When remote services are discovered
MTU Changes: When MTU negotiation completes
PHY Updates: When physical layer parameters change
Characteristic Operations: Read, write, and notification events
Descriptor Operations: Descriptor write completions
Logging
All callbacks are logged using Constants.TAG for debugging purposes. Log messages include the event type, relevant UUIDs, and status codes.
API Compatibility
This class handles both legacy (pre-API 33) and modern (API 33+) callback methods for characteristic change notifications. The appropriate method is called by the system based on the Android version.
Usage Example
val stateMachine = ConnectionStateMachine(scope, ...)
val callback = BleGattCallback(stateMachine, bondManager)
// Use the callback when connecting
device.connectGatt(context, false, callback)Parameters
The ConnectionStateMachine that processes GATT events and manages the connection lifecycle.
Optional BondManager for handling device bonding. Currently reserved for future use in automatic bonding scenarios.
See also
Functions
Called when a characteristic value has changed due to a notification or indication (API < 33).
Called when a characteristic value has changed due to a notification or indication (API 33+).
Called when a characteristic read operation completes.
Called when a characteristic write operation completes.
Called when the connection state changes (connected or disconnected).
Called when a descriptor write operation completes.
Called when the MTU (Maximum Transmission Unit) for a connection has changed.
Called when the PHY (Physical Layer) for a connection has been updated.
Called when remote device services have been discovered.