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.

53 lines
1.2 KiB

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. /*
  11. * DEFINES
  12. ****************************************************************************************
  13. */
  14. //#define SUPPORT_HEARTBEAT
  15. //#define SPP_DEBUG_MODE
  16. #define spp_sprintf(s, ...) sprintf((char *)(s), ##__VA_ARGS__)
  17. #define SPP_DATA_MAX_LEN (512)
  18. #define SPP_CMD_MAX_LEN (20)
  19. #define SPP_STATUS_MAX_LEN (20)
  20. #define SPP_DATA_BUFF_MAX_LEN (2 * 1024)
  21. /// Attributes State Machine
  22. enum
  23. {
  24. SPP_IDX_SVC,
  25. SPP_IDX_SPP_DATA_RECV_CHAR,
  26. SPP_IDX_SPP_DATA_RECV_VAL,
  27. SPP_IDX_SPP_DATA_NOTIFY_CHAR,
  28. SPP_IDX_SPP_DATA_NTY_VAL,
  29. SPP_IDX_SPP_DATA_NTF_CFG,
  30. SPP_IDX_SPP_COMMAND_CHAR,
  31. SPP_IDX_SPP_COMMAND_VAL,
  32. SPP_IDX_SPP_STATUS_CHAR,
  33. SPP_IDX_SPP_STATUS_VAL,
  34. SPP_IDX_SPP_STATUS_CFG,
  35. #ifdef SUPPORT_HEARTBEAT
  36. SPP_IDX_SPP_HEARTBEAT_CHAR,
  37. SPP_IDX_SPP_HEARTBEAT_VAL,
  38. SPP_IDX_SPP_HEARTBEAT_CFG,
  39. #endif
  40. SPP_IDX_NB,
  41. };
  42. void ble_spp_server_init();