|
|
@ -66,9 +66,11 @@ uint32_t total = 0; |
|
|
|
#define set_position "setPosition" |
|
|
|
#define get_status "getStatus" |
|
|
|
|
|
|
|
esp_gatts_cb_event_t constructor_event; |
|
|
|
esp_gatt_if_t constructor_gatts_if; |
|
|
|
esp_ble_gatts_cb_param_t *constructor_param; |
|
|
|
ble_gatts_str_t ble_gatts_a_str = { |
|
|
|
.attr_handle = 0, |
|
|
|
.send_conn_id = 0, |
|
|
|
.send_gatts_if = 0, |
|
|
|
}; |
|
|
|
|
|
|
|
/*********************************************************************************************************************** |
|
|
|
* **********************************************user_function_statement********************************************** * |
|
|
@ -149,20 +151,40 @@ void timer_group_init(int group, int timer, bool auto_reload, int timer_interval |
|
|
|
***********************************************************************************************************************/ |
|
|
|
void app_main(void) |
|
|
|
{ |
|
|
|
esp_ble_gatts_init(); |
|
|
|
esp_ble_gatts_init(&ble_gatts_a_str); |
|
|
|
// motor_init(); |
|
|
|
// motor_encoder_init(); |
|
|
|
// timer_group_init(TIMER_GROUP_0, TIMER_0, false, timer_group0_interval_num, timer_interval_ms); |
|
|
|
|
|
|
|
motor_init(); |
|
|
|
motor_encoder_init(); |
|
|
|
timer_group_init(TIMER_GROUP_0, TIMER_0, false, timer_group0_interval_num, timer_interval_ms); |
|
|
|
// uint8_t temp[5] = "hello"; |
|
|
|
// esp_gatt_rsp_t rsp; |
|
|
|
// memset(&rsp, 0, sizeof(esp_gatt_rsp_t)); |
|
|
|
// rsp.attr_value.len = 4; |
|
|
|
// rsp.attr_value.value[0] = 0x11; |
|
|
|
// rsp.attr_value.value[1] = 0x22; |
|
|
|
// rsp.attr_value.value[2] = 0x33; |
|
|
|
// rsp.attr_value.value[3] = 0x44; |
|
|
|
|
|
|
|
while (true) |
|
|
|
{ |
|
|
|
bluetooth_gatts_try_process_data(); |
|
|
|
if (s_bluetooth_processer.actively_report_flag) |
|
|
|
{ |
|
|
|
receipt_json_get_status(); |
|
|
|
s_bluetooth_processer.actively_report_flag = false; |
|
|
|
} |
|
|
|
// if (ble_gatts_a_str.attr_handle != 0) |
|
|
|
// { |
|
|
|
// rsp.attr_value.handle = ble_gatts_a_str.attr_handle; |
|
|
|
// ESP_LOGI(GATTS_TAG, "%d,%d,%d", ble_gatts_a_str.attr_handle, ble_gatts_a_str.send_conn_id, ble_gatts_a_str.send_gatts_if); |
|
|
|
// esp_ble_gatts_send_indicate(ble_gatts_a_str.send_gatts_if, ble_gatts_a_str.send_conn_id, |
|
|
|
// ble_gatts_a_str.attr_handle, 5, temp, true); |
|
|
|
// esp_ble_gatts_send_response(ble_gatts_a_str.send_gatts_if, ble_gatts_a_str.send_conn_id, 1, |
|
|
|
// ESP_GATT_OK, &rsp); |
|
|
|
// ets_delay_us(1000000); |
|
|
|
// } |
|
|
|
// esp_ble_gatts_set_attr_value(ble_gatts_a_str.constructor_param->read.handle, 5, temp); |
|
|
|
|
|
|
|
// bluetooth_gatts_try_process_data(); |
|
|
|
// if (s_bluetooth_processer.actively_report_flag) |
|
|
|
// { |
|
|
|
// receipt_json_get_status(); |
|
|
|
// s_bluetooth_processer.actively_report_flag = false; |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
@ -417,10 +439,3 @@ void receipt_json_get_status() |
|
|
|
|
|
|
|
cJSON_Delete(pRoot); |
|
|
|
} |
|
|
|
|
|
|
|
void gatts_profile_a_constructor(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param) |
|
|
|
{ |
|
|
|
constructor_event = event; |
|
|
|
constructor_gatts_if = gatts_if; |
|
|
|
constructor_param = param; |
|
|
|
} |