ble_wechat.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef BLE_WECHAT_H
  2. #define BLE_WECHAT_H
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include <stdlib.h>
  6. #include "_string.h"
  7. #include "sdk_config.h"
  8. #include "ble_config.h"
  9. #include "ble.h"
  10. #include "ble_srv_common.h"
  11. #include "nrf_sdh_ble.h"
  12. #include "ble_link_ctx_manager.h"
  13. #include "ble_wechat_util.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. // 蓝牙微信服务实例宏定义
  18. // _name ->实例名称
  19. #define BLE_WECHAT_DEF(_name) \
  20. static ble_wechat_t _name; \
  21. NRF_SDH_BLE_OBSERVER(_name ## _obs, \
  22. BLE_WECHAT_BLE_OBSERVER_PRIO, \
  23. ble_evt_handler, &_name)
  24. // 蓝牙微信服务UUID定义
  25. #define BLE_UUID_WECHAT_SERVICE 0xFEE7
  26. #define BLE_UUID_WECHAT_WRITE_CHARACTERISTICS 0xFEC7
  27. #define BLE_UUID_WECHAT_INDICATE_CHARACTERISTICS 0xFEC8
  28. #define BLE_UUID_WECHAT_READ_CHARACTERISTICS 0xFEC9
  29. #define BLE_WECHAT_MAX_DATA_LEN 20
  30. #define BLE_OWNED_MAX_DATA_LEN 64
  31. extern uint8_t m_addl_adv_manuf_data[];
  32. typedef struct
  33. {
  34. uint16_t service_handle;
  35. ble_gatts_char_handles_t indicate_handles;
  36. ble_gatts_char_handles_t write_handles;
  37. ble_gatts_char_handles_t read_handles;
  38. ble_gatts_char_handles_t active_indicate_handles;
  39. ble_gatts_char_handles_t biz_indicate_handles;
  40. uint16_t conn_handle;
  41. bool active_server_on;
  42. bool biz_server_on;
  43. } ble_wechat_t;
  44. typedef struct
  45. {
  46. uint8_t *data;
  47. uint16_t len;
  48. uint16_t offset;
  49. } data_info;
  50. int ble_wechat_indicate_data(ble_wechat_t *p_wcs,data_handler *p_data_handler, uint8_t *data, int len);
  51. void ble_wechat_on_ble_evt(ble_wechat_t *p_wcs,ble_evt_t * p_ble_evt, data_handler *p_data_handler);
  52. uint32_t ble_wechat_add_service(ble_wechat_t *p_wechat);
  53. uint32_t ble_wechat_add_characteristics(ble_wechat_t *p_wechat);
  54. uint32_t ble_wechat_init(ble_wechat_t * p_wechat);
  55. #ifdef __cplusplus
  56. }
  57. #endif
  58. #endif // BLE_WECHAT_H