Coder Social home page Coder Social logo

fitbit / bitgatt Goto Github PK

View Code? Open in Web Editor NEW
56.0 56.0 17.0 797 KB

The FitbitGatt API is designed to provide a strong state machine around all Android gatt operations with the aim of making Android BLE development across Android vendors as straightforward and side-effect free as possible.

License: Mozilla Public License 2.0

Shell 0.01% Java 99.94% HTML 0.05%
android ble bluetooth bluetooth-low-energy

bitgatt's People

Contributors

cristian-ich avatar dragosdi avatar droolingsheep avatar explodes avatar fossabot avatar ionutlepi avatar irvinowens avatar khanmurtuza avatar sbang002 avatar shawnw858 avatar warrencomputes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bitgatt's Issues

Unable to receive characteristic notifications.

Describe the bug
I have a simple BLE device that begins advertising data immediately after being turned on. I am attempting to write an Android app that can detect and parse that advertisement. Following the instructions found in the README I was able to:

  1. Scan for the device.
  2. Connect to it.
  3. Discover it's services and characteristics.
  4. Subscribe for a characteristic's notifications.

My application is never notified of characteristic changes. Did I overlook anything in my setup?

override fun onStart() {
    super.onStart()
    fitGatt.registerGattEventListener(this)
    fitGatt.clientCallback
    fitGatt.startGattServer(this)
}

override fun onGattServerStarted(serverConnection: GattServerConnection?) {
    fitGatt.addDeviceNameScanFilter("EXAMPLE_DEVICE_NAME")
    fitGatt.startPeriodicScan(this);
}

override fun onBluetoothPeripheralDiscovered(connection: GattConnection?) {
    fitGatt.cancelScan(this)

    // Connect
    connection.runTx(GattConnectTransaction(connection, GattState.CONNECTED)) { connResult ->

        // Discover services / characteristic
        connection.runTx(GattClientDiscoverServicesTransaction(connection, GattState.DISCOVERY_SUCCESS)) { discResult ->
            val service = discResult.services.find { it.uuid == UUID.fromString("EXAMPLE_SERVICE_UUID") }
            val characteristic = service?.characteristics?.find { it.uuid == UUID.fromString("EXAMPLE_CHARACTERISTIC_UUID") }
            if (characteristic == null) return@runTx

            // Confirmed that this characteristic has the "notify" property.

            // Subscribe
            connection.runTx(SubscribeToCharacteristicNotificationsTransaction(connection, GattState.ENABLE_CHARACTERISTIC_NOTIFICATION_SUCCESS, characteristic)) {
                // All done?
            }
        }
    }

    connection.registerConnectionEventListener(object: ConnectionEventListener {
        override fun onClientCharacteristicChanged(result: TransactionResult, connection: GattConnection) { 
            // Never being called.
        }
        ...
    })
}

Expected behavior
The ConnectionEventListener should be notified every time my app detects a new advertisement from the subscribed characteristic.

Peripheral:
Samico ADF-B06 Pulse Oximeter

Smartphone:

  • Device: Google Pixel 2 XL
  • OS: Android Q
  • Patch Level [e.g. 22]

GATT_INSUF_AUTHORIZATION

Describe the bug
I am trying to connect to a BLE thermometer that has an "indicate" characteristic. When running my app with the debugger attached everything works perfectly. I can connect to the device, discover services, subscribe to the characteristic, get updates, etc. But anytime I run my app without the debugger my device connection is always severed after 2-3 seconds. The logs call out a GATT_INSUF_AUTHORIZATION error.

Here are logs from the setup process:

22:40:54.132 17493-17493 D/PeripheralScanner: Start High priority Scan
22:40:54.132 17493-17493 V/PeripheralScanner: Scan filter's size: 5
22:40:54.132 17493-17493 D/BluetoothAdapter: isLeEnabled(): ON
22:40:54.133 17493-17521 D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=9 mScannerId=0
22:40:54.136 17493-17493 V/PeripheralScanner: Starting scan, scan count in this 120000 ms is 1
22:40:54.136 17493-17493 I/FitbitGatt: On scan status changed true
22:41:00.439 17493-17493 V/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -51, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Received transaction: GattConnectTransaction
22:41:00.441 17493-17554 V/GattStateTransitionValidator: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -51, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Current State DISCONNECTED, Success State CONNECTED
22:41:00.443 17493-17554 W/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -51, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] While this instance isn't in the cache, there is already a connection in the queue, please be careful not to create too many client_ifs #developerlove.
22:41:00.444 17493-17554 V/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -51, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Android BluetoothGatt was null, start a new Android BluetoothGatt instance connect to device
22:41:00.446 17493-17554 D/BluetoothGatt: connect() - device: D0:5F:B8:51:5A:E7, auto: false
22:41:00.446 17493-17554 D/BluetoothGatt: registerApp()
22:41:00.447 17493-17554 D/BluetoothGatt: registerApp() - UUID=c4c51102-4042-4d2a-add8-43a6e0531588
22:41:00.451 17493-17521 D/BluetoothGatt: onClientRegistered() - status=0 clientIf=10
22:41:00.791 17493-17521 D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=10 device=D0:5F:B8:51:5A:E7
22:41:00.795 17493-17521 V/GattClientCallback: [TEMP] onConnectionStateChange: Gatt Response Status GATT_ERROR
22:41:00.797 17493-17521 D/GattClientCallback: [TEMP][Threading] Originally called on thread : Binder:17493_3
22:41:00.799 17493-17521 D/GattClientCallback: [TEMP]Connection state: Not-Connected
22:41:00.801 17493-17521 I/GattClientCallback: [TEMP] The connection state may have changed in error
22:41:00.804 17493-17521 D/GattClientCallback: [TEMP] Disconnection reason: GATT_CONN_UNKNOWN
22:41:00.806 17493-17521 W/GattClientCallback: [TEMP] disconnected, waiting 1000ms for full disconnection
22:41:00.806 17493-17521 D/BluetoothGatt: cancelOpen() - device: D0:5F:B8:51:5A:E7
22:41:01.850 17493-17552 D/BluetoothGatt: close()
22:41:01.850 17493-17552 D/BluetoothGatt: unregisterApp() - mClientIf=10
22:41:01.855 17493-17552 I/GattClientCallback: [TEMP] Full disconnection
22:41:01.859 17493-17552 W/GattTransaction: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] The transaction GattConnectTransaction failed, Result: Transaction Name: GattConnectTransaction, Gatt State: DISCONNECTED - State Type: IDLE, Transaction Result Status: FAILURE, Response Status: GATT_SUCCESS, rssi: -60, mtu: 0, Characteristic UUID: null, Service UUID: null, Descriptor UUID: null, Data: null, Offset: 0, txPhy: 1, rxPhy: 1, transaction results: []
22:41:01.861 17493-17552 W/GattTransaction: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Halting the execution chain because tx GattConnectTransaction failed
22:41:01.900 17493-17493 V/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Received transaction: GattConnectTransaction
22:41:01.902 17493-17554 V/GattStateTransitionValidator: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Current State DISCONNECTED, Success State CONNECTED
22:41:01.904 17493-17554 W/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] While this instance isn't in the cache, there is already a connection in the queue, please be careful not to create too many client_ifs #developerlove.
22:41:01.905 17493-17554 V/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Android BluetoothGatt was null, start a new Android BluetoothGatt instance connect to device
22:41:01.906 17493-17554 D/BluetoothGatt: connect() - device: D0:5F:B8:51:5A:E7, auto: false
22:41:01.906 17493-17554 D/BluetoothGatt: registerApp()
22:41:01.907 17493-17554 D/BluetoothGatt: registerApp() - UUID=fa45b741-369e-4285-a20c-95fc8b0724e9
22:41:01.911 17493-17521 D/BluetoothGatt: onClientRegistered() - status=0 clientIf=10
22:41:02.044 17493-17521 D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=10 device=D0:5F:B8:51:5A:E7
22:41:02.048 17493-17493 I/LowEnergyAclListener: BT change received !
22:41:02.049 17493-17521 V/GattClientCallback: [TEMP] onConnectionStateChange: Gatt Response Status GATT_SUCCESS
22:41:02.051 17493-17493 I/LowEnergyAclListener: TEMP Device is now connected
22:41:02.051 17493-17521 D/GattClientCallback: [TEMP][Threading] Originally called on thread : Binder:17493_3
22:41:02.053 17493-17521 D/GattClientCallback: [TEMP]Connection state: Connected
22:41:02.055 17493-17552 V/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Received transaction: GattClientDiscoverServices
22:41:02.056 17493-17554 V/GattStateTransitionValidator: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Current State IDLE, Success State DISCOVERY_SUCCESS
22:41:02.056 17493-17554 D/BluetoothGatt: discoverServices() - device: D0:5F:B8:51:5A:E7
22:41:02.570 17493-17521 D/BluetoothGatt: onConnectionUpdated() - Device=D0:5F:B8:51:5A:E7 interval=78 latency=0 timeout=600 status=0
22:41:03.739 17493-17521 D/BluetoothGatt: onConnectionUpdated() - Device=D0:5F:B8:51:5A:E7 interval=6 latency=0 timeout=500 status=0
22:41:04.133 17493-17521 D/BluetoothGatt: onSearchComplete() = Device=D0:5F:B8:51:5A:E7 Status=0
22:41:04.135 17493-17521 V/GattClientCallback: [TEMP] onServicesDiscovered: Gatt Response Status GATT_SUCCESS
22:41:04.136 17493-17521 D/GattClientCallback: [TEMP][Threading] Originally called on thread : Binder:17493_3
22:41:04.137 17493-17552 V/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Received transaction: CompositeClientTransaction
22:41:04.138 17493-17554 V/GattStateTransitionValidator: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Current State IDLE, Success State IDLE
22:41:04.138 17493-17554 I/TransactionQueueController: Implicitly restarting queue
22:41:04.138 17493-17554 V/TransactionQueueController: Starting execution thread
22:41:04.140 17493-17635 V/GattStateTransitionValidator: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Current State IDLE, Success State ENABLE_CHARACTERISTIC_NOTIFICATION_SUCCESS
22:41:04.141 17493-17635 D/BluetoothGatt: setCharacteristicNotification() - uuid: 00002a1c-0000-1000-8000-00805f9b34fb enable: true
22:41:04.144 17493-17635 V/SubscribeToCharacteristicNotificationsTransaction: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Notification success on 00002a1c-0000-1000-8000-00805f9b34fb
22:41:04.144 17493-17635 V/StrategyProvider: The current device has properties: AndroidDevice[Google, Pixel 4a (5G), 30, bramble, google, bramble]
22:41:04.145 17493-17635 D/StrategyProvider: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Target android device does not match, no need for strategy
22:41:04.146 17493-17493 V/CompositeClientTransaction: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Transaction result: Transaction Name: SubscribeToCharacteristicNotificationsTransaction, Gatt State: ENABLE_CHARACTERISTIC_NOTIFICATION_SUCCESS - State Type: IDLE, Transaction Result Status: SUCCESS, Response Status: GATT_SUCCESS, rssi: 0, mtu: 0, Characteristic UUID: 00002a1c-0000-1000-8000-00805f9b34fb, Service UUID: 00001809-0000-1000-8000-00805f9b34fb, Descriptor UUID: null, Data: null, Offset: 0, txPhy: 1, rxPhy: 1, transaction results: []
22:41:04.147 17493-17635 V/GattStateTransitionValidator: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Current State IDLE, Success State WRITE_DESCRIPTOR_SUCCESS
22:41:04.168 17493-17521 V/GattClientCallback: [TEMP] onDescriptorWrite: Gatt Response Status GATT_SUCCESS
22:41:04.170 17493-17521 D/GattClientCallback: [TEMP][Threading] Originally called on thread : Binder:17493_3
22:41:04.173 17493-17552 V/CompositeClientTransaction: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Transaction result: Transaction Name: WriteGattDescriptorTransaction, Gatt State: WRITE_DESCRIPTOR_SUCCESS - State Type: IDLE, Transaction Result Status: SUCCESS, Response Status: GATT_SUCCESS, rssi: -60, mtu: 0, Characteristic UUID: null, Service UUID: null, Descriptor UUID: 00002902-0000-1000-8000-00805f9b34fb, Data: null, Offset: 0, txPhy: 1, rxPhy: 1, transaction results: []
22:41:04.174 17493-17552 D/CompositeClientTransaction: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Finished running all transactions successfully, last result: Transaction Name: WriteGattDescriptorTransaction, Gatt State: WRITE_DESCRIPTOR_SUCCESS - State Type: IDLE, Transaction Result Status: SUCCESS, Response Status: GATT_SUCCESS, rssi: -60, mtu: 0, Characteristic UUID: null, Service UUID: null, Descriptor UUID: 00002902-0000-1000-8000-00805f9b34fb, Data: null, Offset: 0, txPhy: 1, rxPhy: 1, transaction results: []
22:41:04.176 17493-17552 V/TransactionQueueController: Stopping execution thread
22:41:04.177 17493-17552 V/GattClientTransaction: [TEMP] onDescriptorWrite not handled in tx: CompositeClientTransaction
22:41:04.178 17493-17635 D/GattTransaction: Transaction was interrupted while waiting for result, re-interrupting thread : CompositeClientTransaction
22:41:04.178 17493-17635 V/CompositeClientTransaction: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -60, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Transaction Transaction Name: SubscribeToCharacteristicNotificationsTransaction, Gatt State: ENABLE_CHARACTERISTIC_NOTIFICATION_SUCCESS - State Type: IDLE, Transaction Result Status: SUCCESS, Response Status: GATT_SUCCESS, rssi: 0, mtu: 0, Characteristic UUID: 00002a1c-0000-1000-8000-00805f9b34fb, Service UUID: 00001809-0000-1000-8000-00805f9b34fb, Descriptor UUID: null, Data: null, Offset: 0, txPhy: 1, rxPhy: 1, transaction results: [] was successful, moving on to index: 1
22:41:04.178 17493-17635 I/TransactionQueueController$ClientThread: Thread was stopped
22:41:04.224 17493-17521 D/BluetoothGatt: onConnectionUpdated() - Device=D0:5F:B8:51:5A:E7 interval=78 latency=0 timeout=600 status=0

And here are logs when the connection is lost:

22:41:10.234 17493-17636 D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=10 device=D0:5F:B8:51:5A:E7
22:41:10.236 17493-17636 V/GattClientCallback: [TEMP] onConnectionStateChange: Gatt Response Status GATT_INSUF_AUTHORIZATION
22:41:10.238 17493-17636 D/GattClientCallback: [TEMP][Threading] Originally called on thread : Binder:17493_5
22:41:10.241 17493-17636 D/GattClientCallback: [TEMP]Connection state: Not-Connected
22:41:10.242 17493-17636 I/GattClientCallback: [TEMP] The connection state may have changed in error
22:41:10.242 17493-17493 I/LowEnergyAclListener: BT change received !
22:41:10.243 17493-17493 I/LowEnergyAclListener: TEMP Device is disconnected
22:41:10.244 17493-17493 V/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -61, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Received transaction: GattDisconnectionTransaction
22:41:10.244 17493-17636 D/GattClientCallback: [TEMP] Disconnection reason: GATT_CONN_UNKNOWN
22:41:10.245 17493-17554 V/GattStateTransitionValidator: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -61, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Current State IDLE, Success State DISCONNECTED
22:41:10.246 17493-17636 W/GattClientCallback: [TEMP] disconnected, waiting 1000ms for full disconnection
22:41:10.246 17493-17636 D/BluetoothGatt: cancelOpen() - device: D0:5F:B8:51:5A:E7
22:41:10.247 17493-17554 V/LowEnergyAclListener: Successful disconnection
22:41:10.247 17493-17554 I/LowEnergyAclListener: TEMP Notifying listeners of connection disconnected
22:41:10.307 17493-17493 V/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -61, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Received transaction: GattConnectTransaction
22:41:10.309 17493-17554 V/GattStateTransitionValidator: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -61, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Current State DISCONNECTED, Success State CONNECTED
22:41:10.309 17493-17554 W/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -61, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] While this instance isn't in the cache, there is already a connection in the queue, please be careful not to create too many client_ifs #developerlove.
22:41:10.310 17493-17554 V/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -61, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Android BluetoothGatt has been used before, using an existing Android BluetoothGatt instance to connect to device
22:41:10.458 17493-17636 D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=10 device=D0:5F:B8:51:5A:E7
22:41:10.460 17493-17493 I/LowEnergyAclListener: BT change received !
22:41:10.461 17493-17493 I/LowEnergyAclListener: TEMP Device is now connected
22:41:10.461 17493-17636 V/GattClientCallback: [TEMP] onConnectionStateChange: Gatt Response Status GATT_SUCCESS
22:41:10.462 17493-17636 D/GattClientCallback: [TEMP][Threading] Originally called on thread : Binder:17493_5
22:41:10.463 17493-17636 D/GattClientCallback: [TEMP]Connection state: Connected
22:41:10.465 17493-17552 V/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -61, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Received transaction: GattClientDiscoverServices
22:41:10.467 17493-17554 V/GattStateTransitionValidator: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -61, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Current State IDLE, Success State DISCOVERY_SUCCESS
22:41:10.467 17493-17554 D/BluetoothGatt: discoverServices() - device: D0:5F:B8:51:5A:E7
22:41:10.954 17493-17636 D/BluetoothGatt: onConnectionUpdated() - Device=D0:5F:B8:51:5A:E7 interval=78 latency=0 timeout=600 status=0
22:41:11.288 17493-17552 D/BluetoothGatt: close()
22:41:11.288 17493-17552 D/BluetoothGatt: unregisterApp() - mClientIf=10
22:41:11.291 17493-17552 I/GattClientCallback: [TEMP] Full disconnection
22:41:11.293 17493-17552 V/GattClientTransaction: [TEMP] onPhyRead not handled in tx: GattClientDiscoverServices
22:41:12.320 17493-17493 I/LowEnergyAclListener: BT change received !
22:41:12.325 17493-17493 I/LowEnergyAclListener: TEMP Device is disconnected
22:41:12.326 17493-17493 V/GattConnection: [[FitbitBluetoothDevice Address: D0:5F:B8:51:5A:E7, Name: TEMP, Rssi: -61, Advertising Data: 02010603 02F0FF09 FF4248E7 5A51B85F D0051240 00500002 0A000509 54454D50 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000, Device Origin: SCANNED]] Received transaction: GattDisconnectionTransaction

To Reproduce
Steps to reproduce the behavior:

  1. Run your app without the debugger.
  2. Connect to a BLE device and subscribe to a characteristic.
  3. Wait a few seconds and observe the logs being written by Fitbit Gatt.

Expected behavior
The BLE device should remain connected until it is intentionally disconnected, turned off, or walks out of range.

Peripheral (please complete the following information):

Smartphone (please complete the following information):

  • Device: Google Pixel 4 5G
  • OS: Android R

Additional context
This seems to happen primarily on devices with "indicate" characteristics. In my testing, "notify" characteristics do not seem to be impacted.

Do not require Timber.

Is your feature request related to a problem? Please describe.
If an app adds com.github.Fitbit:bitgatt as a dependency but does NOT add timber it will crash as soon as FitbitGatt attempts to setup.

Example build.gradle:

dependencies {
    implementation 'com.github.Fitbit:bitgatt:0.9.2-RC4'
    // No timber!
    ...
}

Example Crash:

2021-02-08 23:10:56.813 18446-18446/com.myapp.demo.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.myapp.demo.debug, PID: 18446
    java.lang.NoClassDefFoundError: Failed resolution of: Ltimber/log/Timber;
        at com.fitbit.bluetooth.fbgatt.FitbitGatt.setup(FitbitGatt.java:161)
        at com.fitbit.bluetooth.fbgatt.FitbitGatt.getInstance(FitbitGatt.java:146)
        ...
     Caused by: java.lang.ClassNotFoundException: Didn't find class "timber.log.Timber" on path: DexPathList[[zip file "/data/app/~~buWpUy0wluCeKRNDidVUzA==/com.myapp.demo.debug-Zm3_EyFVTFzsRcNbP_PGQg==/base.apk"],nativeLibraryDirectories=[/data/app/~~buWpUy0wluCeKRNDidVUzA==/com.myapp.demo.debug-Zm3_EyFVTFzsRcNbP_PGQg==/lib/arm64, /system/lib64, /system_ext/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.fitbit.bluetooth.fbgatt.FitbitGatt.setup(FitbitGatt.java:161) 
        at com.fitbit.bluetooth.fbgatt.FitbitGatt.getInstance(FitbitGatt.java:146) 
        ...

Describe the solution you'd like
Timber is a great logging library but, if it isn't too much trouble, it would be nice to not REQUIRE all apps that use FitbitGatt
to also use Timber.

Describe alternatives you've considered
N/A

Additional context
N/A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.