Can't connect to NRF52 via BLE using Espressif IDE example GATT_client
Posted: Wed Mar 29, 2023 9:27 am
I got a trouble with creating the connection from esp32 to nrf52833. The weird thing is that when I used the Arduino example of BLE ESP32 (BLE_client), it went flawlessly. However, when it came to the Espressif IDE example (gatt_client), the nrf52833 kept terminating the connection after about 10-15 seconds. I tried to replicate the Arduino code to ESP-IDE but it didnt work as well. I looked over the source code of the Arduino and it seems that the code also came from basic library of ESP-IDE but Arduino organized it a little bit differently. Here is the log when esp32 connects to nrf52833 by using Arduino code:
I also got the nrf52 and it looks like this:
It is supposed to work like this when using example of ESP-IDE. But when I used it, the behaviour looks like this:
I looked into the reason and find that reason = 19 is about the peer terminating the connection. I guess that the esp32 somehow didn't respond a request from nrf52 in the ESP-IDE code but the Arduino code did.
Do you have any thoughts on this, please let me know ASAP. Any contribution is appreciated so feel free to discuss! Thank you for your time.
Regards,
Son
(Log of ESP32)
Code: Select all
[BLE Advertised Device found: Name: Nordic_UART, Address: f9:e0:0c:f5:4a:ca, serviceUUID: 6e400001-b5a3-f393-e0a9-e50e24dcca9e, rssi: -38
Forming a connection to f9:e0:0c:f5:4a:ca
- Created client
- Connected to server
- Found our service
- Found our characteristic
We are now connected to the BLE Server.]
[(Log of nrf52)]
Code: Select all
[00> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
00>
00> <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
00>
00> <info> app: Connected
00>
00> <debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).
00>
00> <info> app: Data len is set to 0xF4(244)
00>
00> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
00>
00> <debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.
00>
00> <debug> nrf_ble_gatt: max_rx_octets: 251
00>
00> <debug> nrf_ble_gatt: max_tx_octets: 251
00>
00> <debug> nrf_ble_gatt: max_rx_time: 2120
00>
00> <debug> nrf_ble_gatt: max_tx_time: 2120
00>
00> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
00>
00> <debug> nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 517 bytes.
00>
00> <debug> nrf_ble_gatt: Updating ATT MTU to 247 bytes (desired: 247) on connection 0x0.
00>
00> <info> app: Data len is set to 0xF4(244)
00>
00> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7]
(Log of ESP32)
Code: Select all
I (6077) GATTC_DEMO: f9 e0 0c f5 4a ca
I (6077) GATTC_DEMO: searched Adv Data Len 16, Scan Response Len 18
I (6077) GATTC_DEMO: searched Device Name Len 11
I (6077) GATTC_DEMO: Nordic_UART
I (6087) GATTC_DEMO:
I (6087) GATTC_DEMO: searched device Nordic_UART
I (6097) GATTC_DEMO: connect to the remote device.
I (6107) GATTC_DEMO: stop scan successfully
I (6137) GATTC_DEMO: ESP_GATTC_CONNECT_EVT conn_id 0, if 1
I (6137) GATTC_DEMO: REMOTE BDA:
I (6137) GATTC_DEMO: f9 e0 0c f5 4a ca
I (6137) GATTC_DEMO: open success
I (6557) GATTC_DEMO: discover service complete conn_id 0
I (6557) GATTC_DEMO: SEARCH RES: conn_id = 0 is primary service 1
I (6557) GATTC_DEMO: start handle 11 end handle 65535 current handle value 11
I (6567) GATTC_DEMO: 9e ca dc 24 0e e5 a9 e0 93 f3 a3 b5 01 00 40 6e
I (6577) GATTC_DEMO: service uuid128 found
I (6577) GATTC_DEMO: Get service information from remote device
I (6587) GATTC_DEMO: ESP_GATTC_SEARCH_CMPL_EVT
I (6587) GATTC_DEMO: ESP_GATTC_CFG_MTU_EVT, Status 0, MTU 247, conn_id 0
I (11287) GATTC_DEMO: update connection params status = 0, min_int = 16, max_int = 60,conn_int = 60,latency = 0, timeout = 400
W (36267) BT_HCI: hcif disc complete: hdl 0x0, rsn 0x13
W (36267) BT_APPL: gattc_conn_cb: if=1 st=0 id=1 rsn=0x13
I (36267) GATTC_DEMO: ESP_GATTC_DISCONNECT_EVT, reason = 19
(Log of nrf52)
Code: Select all
00> <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
00>
00> <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
00>
00> <info> app: Connected
00>
00> <debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.
00>
00> <debug> nrf_ble_gatt: max_rx_octets: 251
00>
00> <debug> nrf_ble_gatt: max_tx_octets: 251
00>
00> <debug> nrf_ble_gatt: max_rx_time: 2120
00>
00> <debug> nrf_ble_gatt: max_tx_time: 2120
00>
00> <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
00>
00> <debug> nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 517 bytes.
00>
00> <debug> nrf_ble_gatt: Updating ATT MTU to 247 bytes (desired: 247) on connection 0x0.
00>
00> <info> app: Disconnected
00>
Do you have any thoughts on this, please let me know ASAP. Any contribution is appreciated so feel free to discuss! Thank you for your time.
Regards,
Son