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.

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