espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.53k stars 7.26k forks source link

"esp_ble_gattc_close" disconnects from all clients (IDFGH-3119) #5138

Open fbgencer opened 4 years ago

fbgencer commented 4 years ago

Environment

Problem Description

I have two devices which I can connect them succesfully via esp_ble_gattc_app_register and esp_ble_gattc_open functions. Also when callback returns conn_id and gattc_if values, clients update their conn_id and gattc_if.

For disconnection I was using esp_ble_gattc_close which takes two inputs gatt_if and conn_id, which succesfully disconnects from one device. However when I have two connections, the esp_ble_gattc_close request returns me the following warning on my terminal :

W (5743) BT_APPL: bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0016
W (5753) BT_APPL: bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0016

First of all, clients have conn_id: 0 and conn_id:1 not 3 and 4 as printed in the warning. Printed gattc_if values match with previosly returned gattc_if (they were taken when ESP_GATTC_REG_EVT event is invoked). Disconnection reason is also checkhed which is ESP_GATT_CONN_TERMINATE_LOCAL_HOST, and true because I requested this event.

Expected Behavior

Disconnection should occur for a requested client only, esp should not close all connections.

Actual Behavior

ESP Disconnects from all clients instead of the expected client.

WCCWCC commented 4 years ago

Hi @fbgencer ,

esp_ble_gattc_close, from your description, there are certain problems with the behavior of this api.

In order to solve this problem faster, can you provide the code to use this API esp_ble_gattc_close?

I will also reproduce this problem locally.

esp-zhp commented 11 months ago

@fbgencer Has the issue been solved?