1

I'm developing a BLE central application (server) and testing it on my Samsung Galaxy S8. The application was working before my phone decided to update (from 7.1.0 to 8.0.0).

I'm doing a standard read from a known characteristic / service. The device is connecting properly in the function

public void onConnectionStateChange(final BluetoothGatt gatt, int status, int newState)

and the expected service appears in the function

public void onServicesDiscovered(final BluetoothGatt gatt, int status)

. In both of these callbacks, status is equal to 0. So everything seems like it is working until I call

gatt.readCharacteristic(characteristic);

from the onServicesDiscovered callback, after which there is a long pause and then a call to

public void onCharacteristicRead(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, int status)

with status equal to 133 and "null" when I check the characteristic's value with Log.d("DEBUG", "" + characteristic.getStringValue(0));. characteristic.getValue() is also returning null.

The strangest thing is that this code was all working successfully before the update. (I've copied the BLE code into a new project now to isolate it, and believe that I've copied the appropriate permissions from the original project.)

What would cause error 133 in this particular callback? I can't seem to find 133 in the documentation (https://developer.android.com/reference/android/bluetooth/BluetoothGatt), so even just help interpreting the error would be a good step.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
wheresmycookie
  • 683
  • 3
  • 16
  • 39
  • Code 133 is a generic "gatt error", per https://android.googlesource.com/platform/system/bt/+/android-6.0.1_r80/stack/include/gatt_api.h#55, which is sadly not very helpful in diagnosing issues. Are you seeing a 133 every single time, or only some of the time? – stkent May 03 '18 at 16:49
  • Also, are you correctly calling disconnect _and_ close on your `BluetoothGatt` instance? Sometimes omitting the latter can get you into weird states. – stkent May 03 '18 at 16:52
  • @stkent every time unfortunately – wheresmycookie May 03 '18 at 17:26
  • Do you have another 8.0.0 device to test with? That might help narrow down the issue to Samsung vs Android changes. – stkent May 03 '18 at 17:32
  • @stkent good suggestion - I'll try to find one – wheresmycookie May 03 '18 at 18:23
  • These issues are generally hard to debug, but most likely something is wrong with the Bluetooth stack in the phone. You should read the logcat output (not only filtered to your app) and check for bt messages. Also the hci snoop log could also give valuable information. – Emil May 03 '18 at 21:13
  • @wheresmycookie did you find out what was the problem? – Keselme Jul 07 '20 at 09:39

0 Answers0