Page 1 of 1

BLE graceful disconnect problem

Posted: Sat Jul 01, 2017 6:33 am
by lis8215
Hello all,

I have trouble with subject of this topic.

I use gatt_client example as base, and can establish connection to Peripherals without problems.
But i can't disconnect from Peripherals later even esp_ble_gattc_app_unregister(gattc_if) not helps - after that conenction was gone from API but real connection to Peripheral stays active in background.

Any help will be appreciated.

Thanks.

Re: BLE graceful disconnect problem

Posted: Mon Jul 03, 2017 10:20 am
by ESP_Sprite
Move to SDK.

Re: BLE graceful disconnect problem

Posted: Sun Oct 01, 2017 10:31 am
by rf.akram.karimi
Hello everyone,
I am facing the same problem. I am unable to disconnect from peripheral even by using "esp_ble_gattc_app_unregister" and "esp_ble_gattc_close".
Can anyone tell me how can I disconnect from the peripheral so that the event ESP_GATTC_DISCONNECT_EVT could be raised.

Thanks

Re: BLE graceful disconnect problem

Posted: Sun Oct 01, 2017 11:36 pm
by kolban
Testing with the C++ BLE classes found here,

https://github.com/nkolban/esp32-snippe ... /cpp_utils

I seem to find that a esp_ble_gattc_close causes a disconnect. I see the expected event as well as an actual disconnection on the BLE server. Here are the trace logs:

Code: Select all

D (7238) BLEClient: >> disconnect()
E (7240) BT: bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0016
D (7240) BLEDevice: gattClientEventHandler [esp_gatt_if: 3] ... ESP_GATTC_CLOSE_EVT
D (7247) BLEUtils: GATT Event: ESP_GATTC_CLOSE_EVT
D (7251) BLEUtils: [status: ESP_GATT_OK, reason:ESP_GATT_CONN_UNKNOWN, conn_id: 0]
D (7258) BLEDevice: gattClientEventHandler [esp_gatt_if: 3] ... ESP_GATTC_DISCONNECT_EVT
D (7266) BLEUtils: GATT Event: ESP_GATTC_DISCONNECT_EVT
D (7272) BLEUtils: [staus: ESP_GATT_OK, conn_id: 0, remote_bda: 4c:14:6c:ea:23:1c]
D (7280) BLEClient: << disconnect()
D (7283) SampleClientDisconnect: peer address: 00:00:00:00:00:00
D (7330) SampleClientDisconnect: -- End of task

Re: BLE graceful disconnect problem

Posted: Mon Oct 02, 2017 12:58 am
by Lucas.Hutchinson
Yes I will second that "esp_ble_gattc_close" is the correct function to call to disconnect from a peripheral.

The register and un-register api calls are to register an application callback with the stack.
In my application i register 3 of these (My application can handle up to 3 connected peripherals at a time) at startup, then I never un-register these applications.