123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- #ifndef BLE_IAS_H__
- #define BLE_IAS_H__
- #include <stdint.h>
- #include "ble.h"
- #include "nrf_sdh_ble.h"
- #include "ble_link_ctx_manager.h"
- #include "ble_srv_common.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #define BLE_IAS_DEF(_name, _ias_max_clients) \
- BLE_LINK_CTX_MANAGER_DEF(CONCAT_2(_name, _link_ctx_storage), \
- (_ias_max_clients), \
- sizeof(ble_ias_client_context_t)); \
- static ble_ias_t _name = \
- { \
- .p_link_ctx_storage = &CONCAT_2(_name, _link_ctx_storage) \
- }; \
- NRF_SDH_BLE_OBSERVER(_name ## _obs, \
- BLE_IAS_BLE_OBSERVER_PRIO, \
- ble_ias_on_ble_evt, \
- &_name)
- typedef enum
- {
- BLE_IAS_EVT_ALERT_LEVEL_UPDATED
- } ble_ias_evt_type_t;
- typedef struct
- {
- uint8_t alert_level;
- } ble_ias_client_context_t;
- typedef struct
- {
- ble_ias_evt_type_t evt_type;
- uint16_t conn_handle;
- ble_ias_client_context_t * p_link_ctx;
- } ble_ias_evt_t;
- typedef struct ble_ias_s ble_ias_t;
- typedef void (*ble_ias_evt_handler_t) (ble_ias_t * p_ias, ble_ias_evt_t * p_evt);
- typedef struct
- {
- ble_ias_evt_handler_t evt_handler;
- security_req_t alert_wr_sec;
- } ble_ias_init_t;
- struct ble_ias_s
- {
- ble_ias_evt_handler_t evt_handler;
- uint16_t service_handle;
- ble_gatts_char_handles_t alert_level_handles;
- blcm_link_ctx_storage_t * const p_link_ctx_storage;
- };
- uint32_t ble_ias_init(ble_ias_t * p_ias, const ble_ias_init_t * p_ias_init);
- void ble_ias_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context);
- uint32_t ble_ias_alert_level_get(ble_ias_t * p_ias, uint16_t conn_handle, uint8_t * p_alert_level);
- #ifdef __cplusplus
- }
- #endif
- #endif
|