1

I am writing an android app to communicate with my BLE112 device using the native bluetooth libraries in Android 4.4.2 kit kat.

Most of the time, my characteristicRead never returns. When the device shuts down, I get a decimal 133 status which probably means device shut down.

Sometimes, though, I get decimal 132 for all of my reads. I'm wondering where I can find these codes. I pulled the docs from bluegiga, but they don't have any error codes in this range.

Thom
  • 14,013
  • 25
  • 105
  • 185
  • Were you able to get an answer to this? 132 is not one of the status constants of android.bluetooth.BluetoothGatt. This is happenning to me with an HTC One connecting to a TI CC2540, while my other phones connect correctly. – sorianiv May 27 '14 at 17:54
  • @sorianiv We believe that it is a problem with the pairing. We are going to try a timer that waits for 2 seconds and then disconnects and reconnects. Early tests show that this has fixed the problem. – Thom May 27 '14 at 18:23
  • Disconnect and reconnect at which point? I tried waiting some seconds after service discovery but before reading, but it didn't work. It could be related to pairing; my BLE device is password protected (I'm sure I input it right). I just discovered 132 is supposed to be GATT_BUSY https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.3_r1.1/stack/include/gatt_api.h – sorianiv May 28 '14 at 02:03
  • @sorianiv After issuing a read but before receiving a result code. I'm still testing with my live code. – Thom May 28 '14 at 11:02
  • I just tried it, but it didn't work for me. Please tell me if you have any success. Thanks – sorianiv May 28 '14 at 13:07
  • @sorianiv I figured out my problem. Please review my answer and upvote if helpful. – Thom May 29 '14 at 11:23

2 Answers2

1

Hope this helps

https://stackoverflow.com/a/41718665/911389

GATT_INTERNAL_ERROR 0x0081 (129)

GATT_WRONG_STATE 0x0082 (130)

GATT_DB_FULL 0x0083 (131)

GATT_BUSY 0x0084 (132)

GATT_ERROR 0x0085 (133)

Vote Up Cheer Up :)

Community
  • 1
  • 1
Ashraf
  • 3,114
  • 3
  • 23
  • 22
0

My problem was caused by a timing issue. I was actually reading the characteristic before the device had fully paired. To solve this problem, I added a IntentFilter when I started connection to the device:

    IntentFilter filterScan = new IntentFilter();
    filterScan.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
    bluetoothReceiver = new BluetoothReceiver();
    context.registerReceiver(bluetoothReceiver, filterScan);

and then unregistered at close, of course:

    if(bluetoothReceiver != null) {
        context.unregisterReceiver(bluetoothReceiver);
        bluetoothReceiver = null;
    }

And here is the receiver:

private class BluetoothReceiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        BluetoothDevice deviceIn = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

        if (deviceIn != null) {
            if (deviceIn.equals(device)) {
                if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
                    int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
                    if(bondState == BluetoothDevice.BOND_BONDED){
                        //now start reading
                    }
                }
            }
        }
    }
}

Hope this helps.

Thom
  • 14,013
  • 25
  • 105
  • 185