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.

74 lines
2.0 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. #include "esp_gatts_api.h"
  2. #include "esp_log.h"
  3. #include "esp_system.h"
  4. #include "freertos/FreeRTOS.h"
  5. #include "freertos/event_groups.h"
  6. #include "freertos/task.h"
  7. #include "nvs_flash.h"
  8. #include "string.h"
  9. //
  10. #include "ble_spp_server_demo.h"
  11. #include "ble_uart.h"
  12. #include "motor_drive.h"
  13. #include "timer_u.h"
  14. #include "rgb_led.h"
  15. #define MAIN_TAG "MAIN"
  16. static char bluetooth_tx_buffer[profile_b_buffer_size] = {0};
  17. static char bluetooth_rx_buffer[profile_b_buffer_size] = {0};
  18. bluetooth_processer_t s_bluetooth_processer = {
  19. .bluetooth_processer_rx_buf = bluetooth_rx_buffer,
  20. .bluetooth_processer_rx_buf_size = sizeof(bluetooth_rx_buffer),
  21. .bluetooth_processer_tx_buf = bluetooth_tx_buffer,
  22. .bluetooth_processer_tx_buf_size = sizeof(bluetooth_tx_buffer),
  23. .bluetooth_baundrate_one_packet_delay_ms = kbluetooth_baundrate_one_packet_delay_ms,
  24. .port_delay_ms = port_timer_delay_ms,
  25. .bluetooth_rx_buffer_start_receving = false,
  26. .bluetooth_rx_buffer_processing = false,
  27. .order = "order",
  28. .index = 0,
  29. .speedLevel = 0,
  30. .position = 0.0,
  31. .direction = 0,
  32. .code = 0,
  33. .info = "noerror",
  34. .deviceState = "init",
  35. .deviceException = 0,
  36. .deviceExceptionInfo = "noexception",
  37. .table_conn_id_m = 0,
  38. .table_gatts_if_m = 0,
  39. .table_handle_m = 0,
  40. .cmd_flag = false,
  41. .auto_report_flag = false,
  42. .motor_drive_turn_flag = false,
  43. };
  44. void app_main(void) {
  45. constructor_bluetooth_processer(&s_bluetooth_processer);
  46. ble_spp_server_demo_app_main(&s_bluetooth_processer);
  47. timer_group_init(TIMER_GROUP_0, TIMER_0, false, timer_group0_interval_num, timer_interval_ms);
  48. motor_drive_uart_init();
  49. gpio_rgb_init();
  50. while (true) {
  51. bluetooth_gatts_try_process_data();
  52. // if (s_bluetooth_processer.auto_report_flag) {
  53. // receipt_json_get_status();
  54. // encoder = motor_drive_read_encoder();
  55. // ESP_LOGI(MAIN_TAG, "encoder :%.2lf", encoder);
  56. // s_bluetooth_processer.auto_report_flag = false;
  57. // }
  58. // motor_drive_set_motor_to_angle(0,35.32,5);
  59. }
  60. return;
  61. }