You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.5 KiB

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "cJSON.h"
  5. #include "cJSON_Utils.h"
  6. #include "driver/timer.h"
  7. #include "esp_gatts_api.h"
  8. #include "esp_log.h"
  9. #include "esp_system.h"
  10. #define profile_b_buffer_size 128
  11. #define set_position "setPosition"
  12. #define get_status "getStatus"
  13. typedef struct bluetooth_processer {
  14. char *bluetooth_processer_rx_buf;
  15. uint8_t bluetooth_processer_rx_buf_size; //
  16. int bluetooth_baundrate_one_packet_delay_ms;
  17. void (*port_delay_ms)(uint64_t us);
  18. bool bluetooth_rx_buffer_start_receving;
  19. bool bluetooth_rx_buffer_processing;
  20. char *order; //指令名称
  21. int index; //
  22. int speedLevel; //
  23. double position; //角度
  24. int direction; //旋转方向
  25. int code; //错误码
  26. char *info; //错误码信息
  27. char *deviceState; //设备状态
  28. int deviceException; //设备异常编号
  29. char *deviceExceptionInfo; //设备异常信息
  30. uint16_t table_conn_id_m;
  31. esp_gatt_if_t table_gatts_if_m;
  32. uint16_t table_handle_m;
  33. bool cmd_flag;
  34. bool auto_report_flag;
  35. } bluetooth_processer_t;
  36. void constructor_bluetooth_processer(bluetooth_processer_t *bluetooth_processer);
  37. void bluetooth_gatts_try_process_data();
  38. void start_receive_data_to_buffer(uint16_t length, uint8_t *value);
  39. void buffer_all_init();
  40. bool parse_rxbuffer_and_validation_data(cJSON **json_tmp);
  41. bool parse_json_to_struct(cJSON *ch);