Skip to content Skip to sidebar Skip to footer

Reading Values From Ti Ble Cc2540 On Android Fails With Status = 10

I have a device with CC2540 chip that I try to connect and read / write data from Android. The device is discovered, I am able to connect, but when I try to send read command I get

Solution 1:

What does "status = 10" stands for?

It can be anything really, since you can't access to BLE Device Monitor's source. You can find generic GATT profile status codes here(BluetoothGatt)

Do you see the same error code when you run TI's "BleSensorTag" source example?

Where does it comes from? The chip? Android? How can debug it?

That's what Android's BluetoothGattCallback() function interprets from the chip accessing it through BluetoothAdapter.

I recommend focusing on "BleSensorTag" source code; For the status code find

privateBluetoothGattCallbackmGattCallbacks=newBluetoothGattCallback() 

in "BluetoothLeService.java" about line #82. That's where you get the status code and those overridden callbacks then registered to BluetoothDevice object's connectGatt() method.

mBluetoothGatt = device.connectGatt(this, false, mGattCallbacks)

I would also make sure that my BLE packets are in the correct form using TI's sniffer if possible. If not you may as well debug what's coming out of BluetoothAdapter.LeScanCallback

Again in the "BleSensorTag" find public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) method in MainActivity.java. And change;

publicvoidonLeScan(final BluetoothDevice device, finalint rssi, byte[] scanRecord) {
      runOnUiThread(newRunnable() {
        publicvoidrun() {
            // Filter devices

to:

publicvoidonLeScan(final BluetoothDevice device, finalint rssi, byte[] scanRecord) {

      finalbyte[] scanRecordStream = scanRecord;

      runOnUiThread(newRunnable() {
        publicvoidrun() {
            // Filter devices

            Log.i(TAG, "scanRecord:" + Conversion.BytetohexString(scanRecordStream, scanRecordStream.length));

rest is the same and you should see your byte stream in the logcat.

[edit] Here is the LE Generic Packet Structure according to Core Bluetooth Spec V4.0

enter image description here

The following is an example BLE packet byte structure, I added it as an example in case you might want to compare your packet's length when you log it on the console and have something to use as a reference.

A BLE advertising packet could be expected to have the generic form:

02 01 06 1A FF 4C 00 02 15:iBeaconprefix(fixed)B9 40 7F 30 F5 F8 46 6E AF F9 25 55 6B 57 FE 6D:proximityUUID(here:Estimote’sfixedUUID)00 49:major00 0A:minorC5:2’scomplementofmeasuredTXpower

Happy debugging.

Post a Comment for "Reading Values From Ti Ble Cc2540 On Android Fails With Status = 10"