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
  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. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include "ble_parse_data.h"
  11. #include "driver/uart.h"
  12. #include "esp_bt.h"
  13. #include "esp_bt_defs.h"
  14. #include "esp_bt_main.h"
  15. #include "esp_gap_ble_api.h"
  16. #include "esp_gatts_api.h"
  17. #include "esp_log.h"
  18. #include "esp_system.h"
  19. #include "freertos/FreeRTOS.h"
  20. #include "freertos/event_groups.h"
  21. #include "freertos/task.h"
  22. #include "nvs_flash.h"
  23. /*
  24. * DEFINES
  25. ****************************************************************************************
  26. */
  27. //#define SUPPORT_HEARTBEAT
  28. //#define SPP_DEBUG_MODE
  29. #define spp_sprintf(s, ...) sprintf((char *)(s), ##__VA_ARGS__)
  30. #define SPP_DATA_MAX_LEN (512)
  31. #define SPP_CMD_MAX_LEN (20)
  32. #define SPP_STATUS_MAX_LEN (20)
  33. #define SPP_DATA_BUFF_MAX_LEN (2 * 1024)
  34. /// Attributes State Machine
  35. enum {
  36. SPP_IDX_SVC,
  37. SPP_IDX_SPP_DATA_NOTIFY_CHAR,
  38. SPP_IDX_SPP_DATA_NTY_VAL,
  39. SPP_IDX_SPP_DATA_NTF_CFG,
  40. SPP_IDX_SPP_DATA_RECV_CHAR,
  41. SPP_IDX_SPP_DATA_RECV_VAL,
  42. SPP_IDX_SPP_COMMAND_CHAR,
  43. SPP_IDX_SPP_COMMAND_VAL,
  44. SPP_IDX_SPP_STATUS_CHAR,
  45. SPP_IDX_SPP_STATUS_VAL,
  46. SPP_IDX_SPP_STATUS_CFG,
  47. #ifdef SUPPORT_HEARTBEAT
  48. SPP_IDX_SPP_HEARTBEAT_CHAR,
  49. SPP_IDX_SPP_HEARTBEAT_VAL,
  50. SPP_IDX_SPP_HEARTBEAT_CFG,
  51. #endif
  52. SPP_IDX_NB,
  53. };
  54. void ble_spp_server_demo_app_main(bluetooth_processer_t *bluetooth_processer);