I am trying to use the BLE module (bluegiga BLE112) with my nexus 4 (android 4.3). I can connect, get the device name, connect to GATT, but service discovery fails.
Here's how the initial gatt connection happens (which seems to work successfully:
dev.connectGatt(getBaseContext(), true, btGattCB);
Here's the GATT callback:
private BluetoothGattCallback btGattCB = new BluetoothGattCallback() { @Override public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { super.onConnectionStateChange(gatt, status, newState); if(newState == BluetoothProfile.STATE_CONNECTED){ Log.i(TAG, "Gatt Connected"); gatt.discoverServices(); } else if(newState == BluetoothProfile.STATE_DISCONNECTED){ Log.i(TAG, "Gatt Disconnected"); } } @Override public void onServicesDiscovered(BluetoothGatt gatt, int status){ Log.i(TAG,"Status onServiceDiscovered: "+status);
And here is my magazine:
09-28 12:58:37.611 4118-4130/com.jnewt.btFive I/PDU? Scan Callback 09-28 12:58:37.611 4118-4130/com.jnewt.btFive I/PDU? Device is: 00:07:80:67:2F:63 09-28 12:58:37.611 4118-4130/com.jnewt.btFive I/PDU? Device Name: BGT GPIO Test 09-28 12:58:43.607 4118-4118/com.jnewt.btFive I/PDU? Scan Timeout 09-28 12:59:13.539 4118-4129/com.jnewt.btFive I/PDU? Gatt Connected 09-28 12:59:43.561 4118-4190/com.jnewt.btFive I/PDU? Service Discovery Failed 09-28 12:59:43.581 4118-4130/com.jnewt.btFive I/PDU? Gatt Disconnected 09-28 13:00:00.920 4118-4129/com.jnewt.btFive I/PDU? Gatt Connected 09-28 13:00:30.902 4118-4130/com.jnewt.btFive I/PDU? Service Discovery Failed 09-28 13:00:30.922 4118-4190/com.jnewt.btFive I/PDU? Gatt Disconnected 09-28 13:01:20.265 4118-4129/com.jnewt.btFive I/PDU? Gatt Connected 09-28 13:01:50.277 4118-4190/com.jnewt.btFive I/PDU? Service Discovery Failed 09-28 13:01:50.297 4118-4130/com.jnewt.btFive I/PDU? Gatt Disconnected 09-28 13:01:56.113 4118-4129/com.jnewt.btFive I/PDU? Gatt Connected 09-28 13:02:26.115 4118-4190/com.jnewt.btFive I/PDU? Service Discovery Failed 09-28 13:02:26.125 4118-4130/com.jnewt.btFive I/PDU? Gatt Disconnected
On the page https://developer.android.com/reference/android/bluetooth/BluetoothGatt.html I do not mention 129 as a possible status (none of the constants matches 129).
At the moment I have all the ideas. I highlighted the problem on an Android phone by testing a similar example for iphone. I also tried several applications available in the playback store, and they have a similar problem (you can connect, get a name, etc., but no services).
android nexus-4 bluetooth-lowenergy
jnewt
source share