espressif / esp-idf

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

Events from gattc_gatts_coex duplicated (IDFGH-5977) #7664

Closed twomas closed 3 years ago

twomas commented 3 years ago

Environment

Problem Description

Using example gattc_gatts_coex Log from esp32s3 I (22284) GATTC_GATTS_COEX: ESP_GATTS_CONNECT_EVT, conn_id 0, remote 7f:a6:cc:23:bf:dc

I (22284) GATTC_GATTS_COEX: CONNECT_EVT, conn_id 0, remote 7f:a6:cc:23:bf:dc

I (22294) GATTC_GATTS_COEX: ESP_GATTC_CONNECT_EVT conn_id 0, if 5

Did not expect callbacks from local client when connecting to local server from remote device.

Expected Behavior

Only this event ESP_GATTS_CONNECT_EVT

Actual Behavior

Duplicate events ESP_GATTS_CONNECT_EVT and ESP_GATTC_CONNECT_EVT

Steps to reproduce

Connect to ESP_GATTS_DEMO ( gattc_gatts_coex) via nRF Connect from mobile phone

twomas commented 3 years ago

Probably duplicate to https://github.com/espressif/esp-idf/issues/5149

xiewenxiang commented 3 years ago

Hi @twomas ,

The connect.link_role Parameters can be used to determine which end the connection is initiated from.

    /**
     * @brief ESP_GATTS_CONNECT_EVT
     */
    struct gatts_connect_evt_param {
        uint16_t conn_id;               /*!< Connection id */
        uint8_t link_role;              /*!< Link role : master role = 0  ; slave role = 1*/
        esp_bd_addr_t remote_bda;       /*!< Remote bluetooth device address */
        esp_gatt_conn_params_t conn_params; /*!< current Connection parameters */
    } connect;                          /*!< Gatt server callback param of ESP_GATTS_CONNECT_EVT */                     /*!< Gatt server callback param of ESP_GATTS_CONNECT_EVT */

    /**
     * @brief ESP_GATTC_CONNECT_EVT
     */
    struct gattc_connect_evt_param {
        uint16_t conn_id;               /*!< Connection id */
        uint8_t link_role;              /*!< Link role : master role = 0  ; slave role = 1*/
        esp_bd_addr_t remote_bda;       /*!< Remote bluetooth device address */
        esp_gatt_conn_params_t conn_params; /*!< current connection parameters */
    } connect;                          /*!< Gatt client callback param of ESP_GATTC_CONNECT_EVT */
twomas commented 3 years ago

Using link_role