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.

62 lines
1.9 KiB

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