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.

58 lines
1.8 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. char *bluetooth_processer_tx_buf;
  17. uint8_t bluetooth_processer_tx_buf_size; //
  18. int bluetooth_baundrate_one_packet_delay_ms;
  19. void (*port_delay_ms)(uint64_t us);
  20. bool bluetooth_rx_buffer_start_receving;
  21. bool bluetooth_rx_buffer_processing;
  22. char *order; //指令名称
  23. int index; //
  24. int speedLevel; //
  25. double position; //角度
  26. int direction; //旋转方向
  27. int code; //错误码
  28. char *info; //错误码信息
  29. char *deviceState; //设备状态
  30. int deviceException; //设备异常编号
  31. char *deviceExceptionInfo; //设备异常信息
  32. uint16_t table_conn_id_m;
  33. esp_gatt_if_t table_gatts_if_m;
  34. uint16_t table_handle_m;
  35. bool cmd_flag;
  36. bool auto_report_flag;
  37. } bluetooth_processer_t;
  38. void constructor_bluetooth_processer(bluetooth_processer_t *bluetooth_processer);
  39. void bluetooth_gatts_try_process_data();
  40. void start_receive_data_to_buffer(uint16_t length, uint8_t *value);
  41. void buffer_all_init();
  42. bool parse_rxbuffer_and_validation_data(cJSON **json_tmp);
  43. bool parse_json_to_struct(cJSON *ch);
  44. void receipt_json_set_position();
  45. void receipt_json_get_status();
  46. void bluetooth_auto_report_format_receipt();
  47. void bluetooth_tx_buffer_send_indicate();
  48. void string_copy_by_num(char *dest, const char *src, uint8_t count, uint8_t num);