Page 1 of 1

how to use esp_ble_gatts_close ?

Posted: Thu Jul 25, 2019 6:44 am
by datluong
Hi all,
Currently, I want to terminate the connection between esp32 and mobile application by pressing a button.
How can I do that?
I have checked and then found this function:
  1. esp_ble_gatts_close(gatts_if, conn_id);
But I don't know how to implemet this function into my code, where can I find those two parameters, gatts_if and conn_id.
I used example code in example gatt_security_server in esp-idf folder.
Thank you very much,

Re: how to use esp_ble_gatts_close ?

Posted: Sat Jul 27, 2019 2:34 am
by chegewara
When succesfully connected you will receive `ESP_GATTS_CONNECT_EVT`:
https://docs.espressif.com/projects/esp ... evt_paramE

Re: how to use esp_ble_gatts_close ?

Posted: Sat Dec 19, 2020 11:01 am
by kongon
Hi,

You can find those values at gatts_profile_event_handler.

case ESP_GATTS_CONNECT_EVT:
spp_conn_id = p_data->connect.conn_id;
spp_gatts_if = gatts_if;