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.

56 lines
1.4 KiB

3 years ago
  1. #include "freertos/FreeRTOS.h"
  2. #include "freertos/task.h"
  3. #include "freertos/event_groups.h"
  4. #include "esp_system.h"
  5. #include "esp_log.h"
  6. #include "nvs_flash.h"
  7. #include "esp_bt.h"
  8. #include "esp_gap_ble_api.h"
  9. #include "esp_gatts_api.h"
  10. #include "esp_bt_main.h"
  11. #include "gatts_table_creat_demo.h"
  12. #include "esp_gatt_common_api.h"
  13. #define GATTS_TABLE_TAG "GATTS_TABLE_DEMO"
  14. #define PROFILE_NUM 1
  15. #define PROFILE_APP_IDX 0
  16. #define ESP_APP_ID 0x55
  17. #define SAMPLE_DEVICE_NAME "ESP_GATTS_DEMO"
  18. #define SVC_INST_ID 0
  19. /* The max length of characteristic value. When the GATT client performs a write or prepare write operation,
  20. * the data length must be less than GATTS_DEMO_CHAR_VAL_LEN_MAX.
  21. */
  22. #define GATTS_DEMO_CHAR_VAL_LEN_MAX 500
  23. #define PREPARE_BUF_MAX_SIZE 1024
  24. #define CHAR_DECLARATION_SIZE (sizeof(uint8_t))
  25. #define ADV_CONFIG_FLAG (1 << 0)
  26. #define SCAN_RSP_CONFIG_FLAG (1 << 1)
  27. typedef struct
  28. {
  29. uint8_t *prepare_buf;
  30. int prepare_len;
  31. } prepare_type_env_t;
  32. #define CONFIG_SET_RAW_ADV_DATA
  33. struct gatts_profile_inst
  34. {
  35. esp_gatts_cb_t gatts_cb;
  36. uint16_t gatts_if;
  37. uint16_t app_id;
  38. uint16_t conn_id;
  39. uint16_t service_handle;
  40. esp_gatt_srvc_id_t service_id;
  41. uint16_t char_handle;
  42. esp_bt_uuid_t char_uuid;
  43. esp_gatt_perm_t perm;
  44. esp_gatt_char_prop_t property;
  45. uint16_t descr_handle;
  46. esp_bt_uuid_t descr_uuid;
  47. };
  48. void ble_init(uint16_t *conn_id_ble, esp_gatt_if_t *gatts_if_ble, uint16_t *handle_ble);