BLE graceful disconnect problem

lis8215
Posts: 2
Joined: Sat Jul 01, 2017 6:14 am

BLE graceful disconnect problem

Postby lis8215 » Sat Jul 01, 2017 6:33 am

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.

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: BLE graceful disconnect problem

Postby ESP_Sprite » Mon Jul 03, 2017 10:20 am

Move to SDK.

rf.akram.karimi
Posts: 4
Joined: Thu Sep 14, 2017 11:22 am

Re: BLE graceful disconnect problem

Postby rf.akram.karimi » Sun Oct 01, 2017 10:31 am

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

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: BLE graceful disconnect problem

Postby kolban » Sun Oct 01, 2017 11:36 pm

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
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Lucas.Hutchinson
Posts: 79
Joined: Tue Apr 26, 2016 5:10 am

Re: BLE graceful disconnect problem

Postby Lucas.Hutchinson » Mon Oct 02, 2017 12:58 am

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.

Who is online

Users browsing this forum: asargent, Gaston1980, Google [Bot] and 176 guests