|
@ -1,6 +1,8 @@ |
|
|
#include "ble_gatts_table.h" |
|
|
#include "ble_gatts_table.h" |
|
|
|
|
|
|
|
|
static uint16_t *hid_conn_id; |
|
|
static uint16_t *hid_conn_id; |
|
|
|
|
|
static esp_gatt_if_t *hid_gatts_if; |
|
|
|
|
|
static uint16_t *hid_handle; |
|
|
|
|
|
|
|
|
static uint8_t adv_config_done = 0; |
|
|
static uint8_t adv_config_done = 0; |
|
|
|
|
|
|
|
@ -354,6 +356,10 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_ |
|
|
{ |
|
|
{ |
|
|
ESP_LOGE(GATTS_TABLE_TAG, "create attr table failed, error code = %x", create_attr_ret); |
|
|
ESP_LOGE(GATTS_TABLE_TAG, "create attr table failed, error code = %x", create_attr_ret); |
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
*hid_gatts_if = gatts_if; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case ESP_GATTS_READ_EVT: |
|
|
case ESP_GATTS_READ_EVT: |
|
@ -441,6 +447,7 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_ |
|
|
// start sent the update connection parameters to the peer device. |
|
|
// start sent the update connection parameters to the peer device. |
|
|
esp_ble_gap_update_conn_params(&conn_params); |
|
|
esp_ble_gap_update_conn_params(&conn_params); |
|
|
*hid_conn_id = param->connect.conn_id; |
|
|
*hid_conn_id = param->connect.conn_id; |
|
|
|
|
|
*hid_handle = heart_rate_handle_table[IDX_CHAR_VAL_A]; |
|
|
// *hid_conn_id = 100; |
|
|
// *hid_conn_id = 100; |
|
|
break; |
|
|
break; |
|
|
case ESP_GATTS_DISCONNECT_EVT: |
|
|
case ESP_GATTS_DISCONNECT_EVT: |
|
@ -515,11 +522,13 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ |
|
|
} while (0); |
|
|
} while (0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ble_init(uint16_t *conn_id_ble) |
|
|
|
|
|
|
|
|
void ble_init(uint16_t *conn_id_ble, esp_gatt_if_t *gatts_if_ble, uint16_t *handle_ble) |
|
|
{ |
|
|
{ |
|
|
esp_err_t ret; |
|
|
esp_err_t ret; |
|
|
|
|
|
|
|
|
hid_conn_id = conn_id_ble; |
|
|
hid_conn_id = conn_id_ble; |
|
|
|
|
|
hid_gatts_if = gatts_if_ble; |
|
|
|
|
|
hid_handle = handle_ble; |
|
|
|
|
|
|
|
|
/* Initialize NVS. */ |
|
|
/* Initialize NVS. */ |
|
|
ret = nvs_flash_init(); |
|
|
ret = nvs_flash_init(); |
|
|