123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- #ifndef BLE_HRS_H__
- #define BLE_HRS_H__
- #include <stdint.h>
- #include <stdbool.h>
- #include "ble.h"
- #include "ble_srv_common.h"
- #include "nrf_sdh_ble.h"
- #include "nrf_ble_gatt.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define BLE_HRS_DEF(_name) \
- static ble_hrs_t _name; \
- NRF_SDH_BLE_OBSERVER(_name ## _obs, \
- BLE_HRS_BLE_OBSERVER_PRIO, \
- ble_hrs_on_ble_evt, &_name)
- #define BLE_HRS_BODY_SENSOR_LOCATION_OTHER 0
- #define BLE_HRS_BODY_SENSOR_LOCATION_CHEST 1
- #define BLE_HRS_BODY_SENSOR_LOCATION_WRIST 2
- #define BLE_HRS_BODY_SENSOR_LOCATION_FINGER 3
- #define BLE_HRS_BODY_SENSOR_LOCATION_HAND 4
- #define BLE_HRS_BODY_SENSOR_LOCATION_EAR_LOBE 5
- #define BLE_HRS_BODY_SENSOR_LOCATION_FOOT 6
- #define BLE_HRS_MAX_BUFFERED_RR_INTERVALS 20
- typedef enum
- {
- BLE_HRS_EVT_NOTIFICATION_ENABLED,
- BLE_HRS_EVT_NOTIFICATION_DISABLED
- } ble_hrs_evt_type_t;
- typedef struct
- {
- ble_hrs_evt_type_t evt_type;
- } ble_hrs_evt_t;
- typedef struct ble_hrs_s ble_hrs_t;
- typedef void (*ble_hrs_evt_handler_t) (ble_hrs_t * p_hrs, ble_hrs_evt_t * p_evt);
- typedef struct
- {
- ble_hrs_evt_handler_t evt_handler;
- bool is_sensor_contact_supported;
- uint8_t * p_body_sensor_location;
- security_req_t hrm_cccd_wr_sec;
- security_req_t bsl_rd_sec;
- } ble_hrs_init_t;
- struct ble_hrs_s
- {
- ble_hrs_evt_handler_t evt_handler;
- bool is_expended_energy_supported;
- bool is_sensor_contact_supported;
- uint16_t service_handle;
- ble_gatts_char_handles_t hrm_handles;
- ble_gatts_char_handles_t bsl_handles;
- ble_gatts_char_handles_t hrcp_handles;
- uint16_t conn_handle;
- bool is_sensor_contact_detected;
- uint16_t rr_interval[BLE_HRS_MAX_BUFFERED_RR_INTERVALS];
- uint16_t rr_interval_count;
- uint8_t max_hrm_len;
- };
- uint32_t ble_hrs_init(ble_hrs_t * p_hrs, ble_hrs_init_t const * p_hrs_init);
- void ble_hrs_on_gatt_evt(ble_hrs_t * p_hrs, nrf_ble_gatt_evt_t const * p_gatt_evt);
- void ble_hrs_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context);
- uint32_t ble_hrs_heart_rate_measurement_send(ble_hrs_t * p_hrs, uint16_t heart_rate);
- void ble_hrs_rr_interval_add(ble_hrs_t * p_hrs, uint16_t rr_interval);
- bool ble_hrs_rr_interval_buffer_is_full(ble_hrs_t * p_hrs);
- uint32_t ble_hrs_sensor_contact_supported_set(ble_hrs_t * p_hrs, bool is_sensor_contact_supported);
- void ble_hrs_sensor_contact_detected_update(ble_hrs_t * p_hrs, bool is_sensor_contact_detected);
- uint32_t ble_hrs_body_sensor_location_set(ble_hrs_t * p_hrs, uint8_t body_sensor_location);
- #ifdef __cplusplus
- }
- #endif
- #endif
|