This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Android scanner app connects to device but my program doesn't

Actually refers to the mobile version of nRF Connect but it's not on the menu.

I have inherited a legacy Android app that connects to various BLE devices and reads data. Works OK except for one device (a weight scale). It simply won't connect whether or not autoConnect is set. Any attempts to connect return immediately with a generic GATT_ERROR (code 0x85).

Your mobile scanner app can connect and seems to function normally. So can another test program I wrote using the RxAndroidBle library. Interestingly, with this library, it only works if autoConnect is true: if it's false I get an "already connected" error. I get this same error even if autoConnect is true, but after a few seconds it resolves itself and connects.

Wondering if your software experts can suggest things to try. I'm at my wits' end.

(I've run nRF Connect on iOS, and Android 8.0 and 5.0; works on all.)

Parents
  • Scan first, which finds the device, then

    mBluetoothGatt = mBluetoothDevice.connectGatt(mContext, shouldAutoConnect, mGattCallback);

    Have tried with shouldAutoConnect both true and false.

    Log:

    05-07 08:57:09.986 15763-15826/com.calderadev.x200health D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=6 device=88:1B:99:04:D7:40

    05-07 08:57:09.986 15763-15826/com.calderadev.x200health D/AbstractBleInteractor: [Callback] Connection state changed with status: 133 and new state: 0 (DISCONNECTED)
    05-07 08:57:09.986 15763-15826/com.calderadev.x200health W/AbstractBleInteractor: Error: (0x85)
    05-07 08:57:09.987 15763-15826/com.calderadev.x200health D/AbstractBleInteractor: Status's value (decimal) = 133
        onConnectionStateChange() - bluetoothGattOpenCount is at 1
    05-07 08:57:09.987 15763-15826/com.calderadev.x200health W/AbstractBleInteractor: BluetoothProfile.STATE_DISCONNECTED, closing connections and sending DeviceCommunicationsFailEvent
    05-07 08:57:09.987 15763-15826/com.calderadev.x200health D/AbstractBleInteractor: closeConnection()
    05-07 08:57:09.988 15763-15826/com.calderadev.x200health D/AbstractBleInteractor: gatt.closeConnection()
    05-07 08:57:09.988 15763-15826/com.calderadev.x200health D/BluetoothGatt: close()
    05-07 08:57:09.989 15763-15826/com.calderadev.x200health D/BluetoothGatt: unregisterApp() - mClientIf=6
    05-07 08:57:09.993 15763-15826/com.calderadev.x200health D/AbstractBleInteractor: closeConnection() - bluetoothGattOpenCount reducing to 0
    05-07 08:57:09.993 15763-15826/com.calderadev.x200health D/DefaultDeviceInteractor: onDeviceDisconnected
    05-07 08:57:09.995 15763-15763/com.calderadev.x200health D/PairDevicePresenter: onDeviceDisconnected
    05-07 08:57:10.000 15763-15763/com.calderadev.x200health D/MainActivity: onDeviceCommunicationsFail

    As noted, it works with other devices.

Reply
  • Scan first, which finds the device, then

    mBluetoothGatt = mBluetoothDevice.connectGatt(mContext, shouldAutoConnect, mGattCallback);

    Have tried with shouldAutoConnect both true and false.

    Log:

    05-07 08:57:09.986 15763-15826/com.calderadev.x200health D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=6 device=88:1B:99:04:D7:40

    05-07 08:57:09.986 15763-15826/com.calderadev.x200health D/AbstractBleInteractor: [Callback] Connection state changed with status: 133 and new state: 0 (DISCONNECTED)
    05-07 08:57:09.986 15763-15826/com.calderadev.x200health W/AbstractBleInteractor: Error: (0x85)
    05-07 08:57:09.987 15763-15826/com.calderadev.x200health D/AbstractBleInteractor: Status's value (decimal) = 133
        onConnectionStateChange() - bluetoothGattOpenCount is at 1
    05-07 08:57:09.987 15763-15826/com.calderadev.x200health W/AbstractBleInteractor: BluetoothProfile.STATE_DISCONNECTED, closing connections and sending DeviceCommunicationsFailEvent
    05-07 08:57:09.987 15763-15826/com.calderadev.x200health D/AbstractBleInteractor: closeConnection()
    05-07 08:57:09.988 15763-15826/com.calderadev.x200health D/AbstractBleInteractor: gatt.closeConnection()
    05-07 08:57:09.988 15763-15826/com.calderadev.x200health D/BluetoothGatt: close()
    05-07 08:57:09.989 15763-15826/com.calderadev.x200health D/BluetoothGatt: unregisterApp() - mClientIf=6
    05-07 08:57:09.993 15763-15826/com.calderadev.x200health D/AbstractBleInteractor: closeConnection() - bluetoothGattOpenCount reducing to 0
    05-07 08:57:09.993 15763-15826/com.calderadev.x200health D/DefaultDeviceInteractor: onDeviceDisconnected
    05-07 08:57:09.995 15763-15763/com.calderadev.x200health D/PairDevicePresenter: onDeviceDisconnected
    05-07 08:57:10.000 15763-15763/com.calderadev.x200health D/MainActivity: onDeviceCommunicationsFail

    As noted, it works with other devices.

Children
No Data
Related