diff --git a/main/ble_gatts_table.c b/main/ble_gatts_table.c index 6c1ed47..a15a095 100644 --- a/main/ble_gatts_table.c +++ b/main/ble_gatts_table.c @@ -1,5 +1,7 @@ #include "ble_gatts_table.h" +static uint16_t *hid_conn_id; + static uint8_t adv_config_done = 0; uint16_t heart_rate_handle_table[HRS_IDX_NB]; @@ -438,6 +440,8 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_ conn_params.timeout = 400; // timeout = 400*10ms = 4000ms // start sent the update connection parameters to the peer device. esp_ble_gap_update_conn_params(&conn_params); + *hid_conn_id = param->connect.conn_id; + // *hid_conn_id = 100; break; case ESP_GATTS_DISCONNECT_EVT: ESP_LOGI(GATTS_TABLE_TAG, "ESP_GATTS_DISCONNECT_EVT, reason = 0x%x", param->disconnect.reason); @@ -511,10 +515,12 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ } while (0); } -void ble_init(void) +void ble_init(uint16_t *conn_id_ble) { esp_err_t ret; + hid_conn_id = conn_id_ble; + /* Initialize NVS. */ ret = nvs_flash_init(); if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) diff --git a/main/ble_gatts_table.h b/main/ble_gatts_table.h index 4ccf805..26b8958 100644 --- a/main/ble_gatts_table.h +++ b/main/ble_gatts_table.h @@ -54,4 +54,4 @@ struct gatts_profile_inst esp_bt_uuid_t descr_uuid; }; -void ble_init(void); \ No newline at end of file +void ble_init(uint16_t *conn_id_ble); \ No newline at end of file diff --git a/main/gatts_table_creat_demo.c b/main/gatts_table_creat_demo.c index 1849beb..2454026 100644 --- a/main/gatts_table_creat_demo.c +++ b/main/gatts_table_creat_demo.c @@ -17,6 +17,12 @@ ****************************************************************************/ #include "ble_gatts_table.h" +uint16_t table_conn_id_m; + void app_main(void){ - ble_init(); + ble_init(&table_conn_id_m); + + while(true){ + ESP_LOGI("test","%d",table_conn_id_m); + } }