For some reason, most of the time I'm not able to connect to the ESP32 GATT server demo (example 14) using the Android app "BLE Scanner", while on iOS with "LightBlue", connection seems to work without any problems. User mephistod2 found out, that a connection to Android 4.4 seems to work, which I was able to verify.
Looking at the logs of an Andorid 6.0 phone (Sony Xperia Z5 Compact), the connection attempt looks like in the following listing (timestamp of disconnection is 01-06 10:45:28.531). Note, that on an Android 7.0 device (Motorola Nexus 6) it looks more or less the same.
Code: Select all
01-06 10:45:23.381 2521 5693 D BluetoothGatt: connect() - device: 24:0A:C4:00:1F:24, auto: false
01-06 10:45:23.381 2521 5693 D BluetoothGatt: registerApp()
01-06 10:45:23.381 2521 5693 D BluetoothGatt: registerApp() - UUID=3fc70ab5-ae10-45f8-8f2c-e4f26b349286
01-06 10:45:23.385 4293 4589 D BtGatt.GattService: registerClient() - UUID=3fc70ab5-ae10-45f8-8f2c-e4f26b349286
01-06 10:45:23.386 4293 4376 D BtGatt.GattService: onClientRegistered() - UUID=3fc70ab5-ae10-45f8-8f2c-e4f26b349286, clientIf=5
01-06 10:45:23.387 2521 2562 D BluetoothGatt: onClientRegistered() - status=0 clientIf=5
01-06 10:45:23.387 4293 4312 D A2dpService: getA2DPService(): returning com.android.bluetooth.a2dp.A2dpService@4978e40
01-06 10:45:23.388 4293 4312 I A2dpService: audio isMusicActive is false
01-06 10:45:23.389 4293 4312 D BtGatt.GattService: clientConnect() - address=24:0A:C4:00:1F:24, isDirect=true
01-06 10:45:23.390 4293 4376 D bt_btif_config: btif_get_address_type: Device [24:0a:c4:00:1f:24] address type 0
01-06 10:45:23.390 4293 4376 D bt_btif_config: btif_get_device_type: Device [24:0a:c4:00:1f:24] type 3
01-06 10:45:23.390 4293 4454 W bt_l2cap: L2CA_ErtmConnectReq() PSM: 0x001f BDA: 240ac4001f24 p_ertm_info: 0x00000000 allowed:0x0 preferred:0
01-06 10:45:28.530 4293 4454 W bt_l2cap: L2CAP - st: CLOSED evt: 1
01-06 10:45:28.531 4293 4454 W bt_btif : bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0004
01-06 10:45:28.531 4293 4454 W bt_btif : bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0004
01-06 10:45:28.531 4293 4454 W bt_btif : bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0004
01-06 10:45:28.531 4293 4376 D BtGatt.GattService: onConnected() - clientIf=5, connId=0, address=24:0A:C4:00:1F:24
01-06 10:45:28.532 2521 2531 D BluetoothGatt: onClientConnectionState() - status=133 clientIf=5 device=24:0A:C4:00:1F:24
01-06 10:45:28.532 2521 2531 E c : Disconnected
01-06 10:45:28.533 2521 2531 D BluetoothGatt: refresh() - device: 24:0A:C4:00:1F:24
01-06 10:45:28.536 4293 4319 D BtGatt.GattService: refreshDevice() - address=24:0A:C4:00:1F:24
01-06 10:45:28.537 2521 2531 D BluetoothGatt: close()
01-06 10:45:28.537 2521 2531 D BluetoothGatt: unregisterApp() - mClientIf=5
01-06 10:45:28.538 4293 4593 D BtGatt.GattService: unregisterClient() - clientIf=5
At some point, for some reason the connection with Android > 5.0 seemed to work sometimes. Unfortunately, I can't reproduce this currently and I'm not entirely sure what code exactly ran on the ESP32 when it did. But when it did, as soon as I tried to read or write a characteristic, the ESP32 crashed with the following dump:
Code: Select all
E (87702) BT: command_timed_out hci layer timeout waiting for response to a command. opcode: 0x41d
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0)
Register dump:
PC : 0x40085074 PS : 0x00060034 A0 : 0x80083012 A1 : 0x3ffcf360
A2 : 0x3ffceed4 A3 : 0x00060023 A4 : 0x00060020 A5 : 0x3ffd0480
A6 : 0x00000003 A7 : 0x00060e23 A8 : 0xb33f0000 A9 : 0xb33fffff
A10 : 0x00060023 A11 : 0x00000000 A12 : 0x0000006e A13 : 0xb33f0000
A14 : 0xb33fffff A15 : 0x00000005 SAR : 0x00000004 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffb
Backtrace: 0x40085074:0x3ffcf360 0x40083012:0x3ffcf380 0x40084817:0x3ffcf3a0 0x4008516c:0x3ffcf3e0 0x40085186:0x3ffcf420
Rebooting...
So in conclusion:
- Most of the time, connecting to the GATTS demo with Android >= 5.0 does not work
- In the rare cases it does work (which I unforunately cannot reproduce right now), the ESP32 crashes with the dump posted above.