|
|
@ -1,5 +1,14 @@ |
|
|
|
#include "t_bluetooth.h" |
|
|
|
|
|
|
|
/*********************************************************************************************************************** |
|
|
|
* *******************************************************user******************************************************** * |
|
|
|
***********************************************************************************************************************/ |
|
|
|
|
|
|
|
static ble_gatts_str_t *ble_gatts_a_structer; |
|
|
|
|
|
|
|
/*********************************************************************************************************************** |
|
|
|
* ******************************************************************************************************************* * |
|
|
|
***********************************************************************************************************************/ |
|
|
|
/// Declare the static function |
|
|
|
static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param); |
|
|
|
static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param); |
|
|
@ -70,8 +79,6 @@ static esp_ble_adv_data_t scan_rsp_data = { |
|
|
|
.flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT), |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static esp_ble_adv_params_t adv_params = { |
|
|
|
.adv_int_min = 0x20, |
|
|
|
.adv_int_max = 0x40, |
|
|
@ -252,7 +259,6 @@ void example_exec_write_event_env(prepare_type_env_t *prepare_write_env, esp_ble |
|
|
|
|
|
|
|
static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param) |
|
|
|
{ |
|
|
|
// gatts_profile_a_constructor(event, gatts_if, param); |
|
|
|
switch (event) |
|
|
|
{ |
|
|
|
case ESP_GATTS_REG_EVT: |
|
|
@ -303,6 +309,7 @@ static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_i |
|
|
|
break; |
|
|
|
case ESP_GATTS_READ_EVT: |
|
|
|
{ |
|
|
|
gatts_profile_a_constructor(event, gatts_if, param); |
|
|
|
ESP_LOGI(GATTS_TAG, "GATT_READ_EVT, conn_id %d, trans_id %d, handle %d\n", param->read.conn_id, param->read.trans_id, param->read.handle); |
|
|
|
esp_gatt_rsp_t rsp; |
|
|
|
memset(&rsp, 0, sizeof(esp_gatt_rsp_t)); |
|
|
@ -470,7 +477,7 @@ static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_i |
|
|
|
{ |
|
|
|
ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, value len %d, value :", param->write.len); |
|
|
|
esp_log_buffer_hex(GATTS_TAG, param->write.value, param->write.len); |
|
|
|
ESP_LOGI(GATTS_TAG,"ye!!!!!!!!!"); |
|
|
|
ESP_LOGI(GATTS_TAG, "ye!!!!!!!!!"); |
|
|
|
// start_receive_data_to_buffer(param->write.len, param->write.value); |
|
|
|
// for (int i = 0; i < param->write.len; i++) |
|
|
|
// { |
|
|
@ -601,10 +608,12 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ |
|
|
|
} while (0); |
|
|
|
} |
|
|
|
|
|
|
|
void esp_ble_gatts_init() |
|
|
|
void esp_ble_gatts_init(ble_gatts_str_t *ble_gatts_a_str) |
|
|
|
{ |
|
|
|
esp_err_t ret; |
|
|
|
|
|
|
|
ble_gatts_a_structer = ble_gatts_a_str; |
|
|
|
|
|
|
|
// Initialize NVS. |
|
|
|
ret = nvs_flash_init(); |
|
|
|
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) |
|
|
@ -679,4 +688,11 @@ void esp_ble_gatts_init() |
|
|
|
{ |
|
|
|
ESP_LOGE(GATTS_TAG, "set local MTU failed, error code = %x", local_mtu_ret); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void gatts_profile_a_constructor(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param) |
|
|
|
{ |
|
|
|
ble_gatts_a_structer->attr_handle = param->read.handle; |
|
|
|
ble_gatts_a_structer->send_conn_id = param->read.conn_id; |
|
|
|
ble_gatts_a_structer->send_gatts_if = gatts_if; |
|
|
|
} |