|
@ -219,6 +219,7 @@ void bluetooth_gatts_try_process_data(); |
|
|
void timer_set_pause_and_counter_zero(int group, int timer); |
|
|
void timer_set_pause_and_counter_zero(int group, int timer); |
|
|
void port_timer_delay_ms(uint64_t delay); |
|
|
void port_timer_delay_ms(uint64_t delay); |
|
|
void start_receive_data_to_buffer(uint16_t length, uint8_t *value); |
|
|
void start_receive_data_to_buffer(uint16_t length, uint8_t *value); |
|
|
|
|
|
bool parse_rxbuffer_and_validation_data(cJSON **json_tmp); |
|
|
|
|
|
|
|
|
static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) |
|
|
static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) |
|
|
{ |
|
|
{ |
|
@ -882,19 +883,12 @@ void bluetooth_gatts_try_process_data() |
|
|
//打印输出 |
|
|
//打印输出 |
|
|
ESP_LOGI(GATTS_TAG, "%s", &bluetooth_rx_buffer[0]); |
|
|
ESP_LOGI(GATTS_TAG, "%s", &bluetooth_rx_buffer[0]); |
|
|
|
|
|
|
|
|
//解析数据 |
|
|
|
|
|
json_tmp = cJSON_Parse(&bluetooth_rx_buffer[0]); |
|
|
|
|
|
|
|
|
|
|
|
//验证解析数据是否正确 |
|
|
//验证解析数据是否正确 |
|
|
if (json_tmp == NULL) |
|
|
|
|
|
|
|
|
if (!parse_rxbuffer_and_validation_data(&json_tmp)) |
|
|
{ |
|
|
{ |
|
|
ESP_LOGE("ERROR", "json_tmp null"); |
|
|
|
|
|
cJSON_Delete(json_tmp); |
|
|
|
|
|
buffer_all_init(); |
|
|
|
|
|
bluetooth_rx_buffer_start_receving = false; |
|
|
|
|
|
bluetooth_rx_buffer_processing = false; |
|
|
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ch = json_tmp->child; |
|
|
ch = json_tmp->child; |
|
|
|
|
|
|
|
|
while (ch != NULL) |
|
|
while (ch != NULL) |
|
@ -966,3 +960,18 @@ void start_receive_data_to_buffer(uint16_t length, uint8_t *value) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool parse_rxbuffer_and_validation_data(cJSON **json_tmp) |
|
|
|
|
|
{ |
|
|
|
|
|
*json_tmp = cJSON_Parse(&bluetooth_rx_buffer[0]); |
|
|
|
|
|
if (*json_tmp == NULL) |
|
|
|
|
|
{ |
|
|
|
|
|
ESP_LOGE("ERROR", "json_tmp null"); |
|
|
|
|
|
cJSON_Delete(*json_tmp); |
|
|
|
|
|
buffer_all_init(); |
|
|
|
|
|
bluetooth_rx_buffer_start_receving = false; |
|
|
|
|
|
bluetooth_rx_buffer_processing = false; |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
} |