123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- #ifndef BLE_HRS_C_H__
- #define BLE_HRS_C_H__
- #include <stdint.h>
- #include "ble.h"
- #include "ble_db_discovery.h"
- #include "ble_srv_common.h"
- #include "sdk_config.h"
- #include "nrf_ble_gq.h"
- #include "nrf_sdh_ble.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define BLE_HRS_C_DEF(_name) \
- static ble_hrs_c_t _name; \
- NRF_SDH_BLE_OBSERVER(_name ## _obs, \
- BLE_HRS_C_BLE_OBSERVER_PRIO, \
- ble_hrs_c_on_ble_evt, &_name)
- #define BLE_HRS_C_ARRAY_DEF(_name, _cnt) \
- static ble_hrs_c_t _name[_cnt]; \
- NRF_SDH_BLE_OBSERVERS(_name ## _obs, \
- BLE_HRS_C_BLE_OBSERVER_PRIO, \
- ble_hrs_c_on_ble_evt, &_name, _cnt)
- #ifndef BLE_HRS_C_RR_INTERVALS_MAX_CNT
- #define BLE_HRS_C_RR_INTERVALS_MAX_CNT 20
- #endif
- typedef enum
- {
- BLE_HRS_C_EVT_DISCOVERY_COMPLETE = 1,
- BLE_HRS_C_EVT_HRM_NOTIFICATION
- } ble_hrs_c_evt_type_t;
- typedef struct
- {
- uint16_t hr_value;
- uint8_t rr_intervals_cnt;
- uint16_t rr_intervals[BLE_HRS_C_RR_INTERVALS_MAX_CNT];
- } ble_hrm_t;
- typedef struct
- {
- uint16_t hrm_cccd_handle;
- uint16_t hrm_handle;
- } hrs_db_t;
- typedef struct
- {
- ble_hrs_c_evt_type_t evt_type;
- uint16_t conn_handle;
- union
- {
- hrs_db_t peer_db;
- ble_hrm_t hrm;
- } params;
- } ble_hrs_c_evt_t;
- typedef struct ble_hrs_c_s ble_hrs_c_t;
- typedef void (* ble_hrs_c_evt_handler_t) (ble_hrs_c_t * p_ble_hrs_c, ble_hrs_c_evt_t * p_evt);
- struct ble_hrs_c_s
- {
- uint16_t conn_handle;
- hrs_db_t peer_hrs_db;
- ble_hrs_c_evt_handler_t evt_handler;
- ble_srv_error_handler_t error_handler;
- nrf_ble_gq_t * p_gatt_queue;
- };
- typedef struct
- {
- ble_hrs_c_evt_handler_t evt_handler;
- ble_srv_error_handler_t error_handler;
- nrf_ble_gq_t * p_gatt_queue;
- } ble_hrs_c_init_t;
- uint32_t ble_hrs_c_init(ble_hrs_c_t * p_ble_hrs_c, ble_hrs_c_init_t * p_ble_hrs_c_init);
- void ble_hrs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context);
- uint32_t ble_hrs_c_hrm_notif_enable(ble_hrs_c_t * p_ble_hrs_c);
- void ble_hrs_on_db_disc_evt(ble_hrs_c_t * p_ble_hrs_c, const ble_db_discovery_evt_t * p_evt);
- uint32_t ble_hrs_c_handles_assign(ble_hrs_c_t * p_ble_hrs_c,
- uint16_t conn_handle,
- const hrs_db_t * p_peer_hrs_handles);
-
- #ifdef __cplusplus
- }
- #endif
- #endif
-
|