#include #include #include #include "cJSON.h" #include "cJSON_Utils.h" #include "driver/timer.h" #include "esp_gatts_api.h" #include "esp_log.h" #include "esp_system.h" #define profile_b_buffer_size 128 #define set_position "setPosition" #define get_status "getStatus" typedef struct bluetooth_processer { char *bluetooth_processer_rx_buf; uint8_t bluetooth_processer_rx_buf_size; // char *bluetooth_processer_tx_buf; uint8_t bluetooth_processer_tx_buf_size; // int bluetooth_baundrate_one_packet_delay_ms; void (*port_delay_ms)(uint64_t us); bool bluetooth_rx_buffer_start_receving; bool bluetooth_rx_buffer_processing; char *order; //指令名称 int index; // int speedLevel; // double position; //角度 int direction; //旋转方向 int code; //错误码 char *info; //错误码信息 char *deviceState; //设备状态 int deviceException; //设备异常编号 char *deviceExceptionInfo; //设备异常信息 uint16_t table_conn_id_m; esp_gatt_if_t table_gatts_if_m; uint16_t table_handle_m; bool cmd_flag; bool auto_report_flag; } bluetooth_processer_t; void constructor_bluetooth_processer(bluetooth_processer_t *bluetooth_processer); void bluetooth_gatts_try_process_data(); void start_receive_data_to_buffer(uint16_t length, uint8_t *value); void buffer_all_init(); bool parse_rxbuffer_and_validation_data(cJSON **json_tmp); bool parse_json_to_struct(cJSON *ch); void receipt_json_set_position(); void receipt_json_get_status(); void bluetooth_auto_report_format_receipt(); void bluetooth_tx_buffer_send_indicate(); void string_copy_by_num(char *dest, const char *src, uint8_t count, uint8_t num);