Browse Source

封住解析buffer

master
zwsd 3 years ago
parent
commit
61e34e3093
  1. 27
      main/gatts_demo.c

27
main/gatts_demo.c

@ -219,6 +219,7 @@ void bluetooth_gatts_try_process_data();
void timer_set_pause_and_counter_zero(int group, int timer);
void port_timer_delay_ms(uint64_t delay);
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)
{
@ -882,19 +883,12 @@ void bluetooth_gatts_try_process_data()
//
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;
}
ch = json_tmp->child;
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;
}
Loading…
Cancel
Save