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.

64 lines
1.6 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. /*
  2. This example code is in the Public Domain (or CC0 licensed, at your option.)
  3. Unless required by applicable law or agreed to in writing, this
  4. software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  5. CONDITIONS OF ANY KIND, either express or implied.
  6. */
  7. #pragma once
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include "ble_parse_data.h"
  12. #include "driver/uart.h"
  13. #include "esp_bt.h"
  14. #include "esp_bt_defs.h"
  15. #include "esp_bt_main.h"
  16. #include "esp_gap_ble_api.h"
  17. #include "esp_gatts_api.h"
  18. #include "esp_log.h"
  19. #include "esp_system.h"
  20. #include "freertos/FreeRTOS.h"
  21. #include "freertos/event_groups.h"
  22. #include "freertos/task.h"
  23. #include "nvs_flash.h"
  24. /*
  25. * DEFINES
  26. ****************************************************************************************
  27. */
  28. //#define SUPPORT_HEARTBEAT
  29. //#define SPP_DEBUG_MODE
  30. #define spp_sprintf(s, ...) sprintf((char *)(s), ##__VA_ARGS__)
  31. #define SPP_DATA_MAX_LEN (512)
  32. #define SPP_CMD_MAX_LEN (20)
  33. #define SPP_STATUS_MAX_LEN (20)
  34. #define SPP_DATA_BUFF_MAX_LEN (2 * 1024)
  35. /// Attributes State Machine
  36. enum {
  37. SPP_IDX_SVC,
  38. SPP_IDX_SPP_DATA_NOTIFY_CHAR,
  39. SPP_IDX_SPP_DATA_NTY_VAL,
  40. SPP_IDX_SPP_DATA_NTF_CFG,
  41. SPP_IDX_SPP_DATA_RECV_CHAR,
  42. SPP_IDX_SPP_DATA_RECV_VAL,
  43. SPP_IDX_SPP_COMMAND_CHAR,
  44. SPP_IDX_SPP_COMMAND_VAL,
  45. SPP_IDX_SPP_STATUS_CHAR,
  46. SPP_IDX_SPP_STATUS_VAL,
  47. SPP_IDX_SPP_STATUS_CFG,
  48. #ifdef SUPPORT_HEARTBEAT
  49. SPP_IDX_SPP_HEARTBEAT_CHAR,
  50. SPP_IDX_SPP_HEARTBEAT_VAL,
  51. SPP_IDX_SPP_HEARTBEAT_CFG,
  52. #endif
  53. SPP_IDX_NB,
  54. };
  55. void ble_spp_server_demo_app_main(bluetooth_processer_t *bluetooth_processer);