nochanges
Dependents: BLE_Acceleration_Statejudging
Fork of nRF51822 by
nordic/nrf-sdk/ble/ble_services/ble_bps.h@37:c29c330d942c, 2014-07-07 (annotated)
- Committer:
- Rohit Grover
- Date:
- Mon Jul 07 13:43:31 2014 +0100
- Revision:
- 37:c29c330d942c
changes required to upgrade to V7 of the soft-device
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rohit Grover |
37:c29c330d942c | 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. |
Rohit Grover |
37:c29c330d942c | 2 | * |
Rohit Grover |
37:c29c330d942c | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
Rohit Grover |
37:c29c330d942c | 4 | * Terms and conditions of usage are described in detail in NORDIC |
Rohit Grover |
37:c29c330d942c | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
Rohit Grover |
37:c29c330d942c | 6 | * |
Rohit Grover |
37:c29c330d942c | 7 | * Licensees are granted free, non-transferable use of the information. NO |
Rohit Grover |
37:c29c330d942c | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
Rohit Grover |
37:c29c330d942c | 9 | * the file. |
Rohit Grover |
37:c29c330d942c | 10 | */ |
Rohit Grover |
37:c29c330d942c | 11 | |
Rohit Grover |
37:c29c330d942c | 12 | /** @file |
Rohit Grover |
37:c29c330d942c | 13 | * |
Rohit Grover |
37:c29c330d942c | 14 | * @defgroup ble_sdk_srv_bps Blood Pressure Service |
Rohit Grover |
37:c29c330d942c | 15 | * @{ |
Rohit Grover |
37:c29c330d942c | 16 | * @ingroup ble_sdk_srv |
Rohit Grover |
37:c29c330d942c | 17 | * @brief Blood Pressure Service module. |
Rohit Grover |
37:c29c330d942c | 18 | * |
Rohit Grover |
37:c29c330d942c | 19 | * @details This module implements the Blood Pressure Service. |
Rohit Grover |
37:c29c330d942c | 20 | * |
Rohit Grover |
37:c29c330d942c | 21 | * If an event handler is supplied by the application, the Blood Pressure |
Rohit Grover |
37:c29c330d942c | 22 | * Service will generate Blood Pressure Service events to the application. |
Rohit Grover |
37:c29c330d942c | 23 | * |
Rohit Grover |
37:c29c330d942c | 24 | * @note The application must propagate BLE stack events to the Blood Pressure Service |
Rohit Grover |
37:c29c330d942c | 25 | * module by calling ble_bps_on_ble_evt() from the from the @ref ble_stack_handler function. |
Rohit Grover |
37:c29c330d942c | 26 | * |
Rohit Grover |
37:c29c330d942c | 27 | * @note Attention! |
Rohit Grover |
37:c29c330d942c | 28 | * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile |
Rohit Grover |
37:c29c330d942c | 29 | * qualification listings, this section of source code must not be modified. |
Rohit Grover |
37:c29c330d942c | 30 | */ |
Rohit Grover |
37:c29c330d942c | 31 | |
Rohit Grover |
37:c29c330d942c | 32 | #ifndef BLE_BPS_H__ |
Rohit Grover |
37:c29c330d942c | 33 | #define BLE_BPS_H__ |
Rohit Grover |
37:c29c330d942c | 34 | |
Rohit Grover |
37:c29c330d942c | 35 | #include <stdint.h> |
Rohit Grover |
37:c29c330d942c | 36 | #include <stdbool.h> |
Rohit Grover |
37:c29c330d942c | 37 | #include "ble.h" |
Rohit Grover |
37:c29c330d942c | 38 | #include "ble_srv_common.h" |
Rohit Grover |
37:c29c330d942c | 39 | #include "ble_date_time.h" |
Rohit Grover |
37:c29c330d942c | 40 | |
Rohit Grover |
37:c29c330d942c | 41 | // Blood Pressure Feature bits |
Rohit Grover |
37:c29c330d942c | 42 | #define BLE_BPS_FEATURE_BODY_MOVEMENT_BIT (0x01 << 0) /**< Body Movement Detection Support bit. */ |
Rohit Grover |
37:c29c330d942c | 43 | #define BLE_BPS_FEATURE_CUFF_FIT_BIT (0x01 << 1) /**< Cuff Fit Detection Support bit. */ |
Rohit Grover |
37:c29c330d942c | 44 | #define BLE_BPS_FEATURE_IRREGULAR_PULSE_BIT (0x01 << 2) /**< Irregular Pulse Detection Support bit. */ |
Rohit Grover |
37:c29c330d942c | 45 | #define BLE_BPS_FEATURE_PULSE_RATE_RANGE_BIT (0x01 << 3) /**< Pulse Rate Range Detection Support bit. */ |
Rohit Grover |
37:c29c330d942c | 46 | #define BLE_BPS_FEATURE_MEASUREMENT_POSITION_BIT (0x01 << 4) /**< Measurement Position Detection Support bit. */ |
Rohit Grover |
37:c29c330d942c | 47 | #define BLE_BPS_FEATURE_MULTIPLE_BOND_BIT (0x01 << 5) /**< Multiple Bond Support bit. */ |
Rohit Grover |
37:c29c330d942c | 48 | |
Rohit Grover |
37:c29c330d942c | 49 | /**@brief Blood Pressure Service event type. */ |
Rohit Grover |
37:c29c330d942c | 50 | typedef enum |
Rohit Grover |
37:c29c330d942c | 51 | { |
Rohit Grover |
37:c29c330d942c | 52 | BLE_BPS_EVT_INDICATION_ENABLED, /**< Blood Pressure value indication enabled event. */ |
Rohit Grover |
37:c29c330d942c | 53 | BLE_BPS_EVT_INDICATION_DISABLED, /**< Blood Pressure value indication disabled event. */ |
Rohit Grover |
37:c29c330d942c | 54 | BLE_BPS_EVT_INDICATION_CONFIRMED /**< Confirmation of a blood pressure measurement indication has been received. */ |
Rohit Grover |
37:c29c330d942c | 55 | } ble_bps_evt_type_t; |
Rohit Grover |
37:c29c330d942c | 56 | |
Rohit Grover |
37:c29c330d942c | 57 | /**@brief Blood Pressure Service event. */ |
Rohit Grover |
37:c29c330d942c | 58 | typedef struct |
Rohit Grover |
37:c29c330d942c | 59 | { |
Rohit Grover |
37:c29c330d942c | 60 | ble_bps_evt_type_t evt_type; /**< Type of event. */ |
Rohit Grover |
37:c29c330d942c | 61 | } ble_bps_evt_t; |
Rohit Grover |
37:c29c330d942c | 62 | |
Rohit Grover |
37:c29c330d942c | 63 | // Forward declaration of the ble_bps_t type. |
Rohit Grover |
37:c29c330d942c | 64 | typedef struct ble_bps_s ble_bps_t; |
Rohit Grover |
37:c29c330d942c | 65 | |
Rohit Grover |
37:c29c330d942c | 66 | /**@brief Blood Pressure Service event handler type. */ |
Rohit Grover |
37:c29c330d942c | 67 | typedef void (*ble_bps_evt_handler_t) (ble_bps_t * p_bps, ble_bps_evt_t * p_evt); |
Rohit Grover |
37:c29c330d942c | 68 | |
Rohit Grover |
37:c29c330d942c | 69 | /**@brief SFLOAT format (IEEE-11073 16-bit FLOAT, defined as a 16-bit vlue with 12-bit mantissa and |
Rohit Grover |
37:c29c330d942c | 70 | * 4-bit exponent. */ |
Rohit Grover |
37:c29c330d942c | 71 | typedef struct |
Rohit Grover |
37:c29c330d942c | 72 | { |
Rohit Grover |
37:c29c330d942c | 73 | int8_t exponent; /**< Base 10 exponent, only 4 bits */ |
Rohit Grover |
37:c29c330d942c | 74 | int16_t mantissa; /**< Mantissa, only 12 bits */ |
Rohit Grover |
37:c29c330d942c | 75 | } ieee_float16_t; |
Rohit Grover |
37:c29c330d942c | 76 | |
Rohit Grover |
37:c29c330d942c | 77 | /**@brief Blood Pressure Service init structure. This contains all options and data |
Rohit Grover |
37:c29c330d942c | 78 | * needed for initialization of the service. */ |
Rohit Grover |
37:c29c330d942c | 79 | typedef struct |
Rohit Grover |
37:c29c330d942c | 80 | { |
Rohit Grover |
37:c29c330d942c | 81 | ble_bps_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Blood Pressure Service. */ |
Rohit Grover |
37:c29c330d942c | 82 | ble_srv_cccd_security_mode_t bps_meas_attr_md; /**< Initial security level for blood pressure measurement attribute */ |
Rohit Grover |
37:c29c330d942c | 83 | ble_srv_security_mode_t bps_feature_attr_md; /**< Initial security level for blood pressure feature attribute */ |
Rohit Grover |
37:c29c330d942c | 84 | uint16_t feature; /**< Initial value for blood pressure feature */ |
Rohit Grover |
37:c29c330d942c | 85 | } ble_bps_init_t; |
Rohit Grover |
37:c29c330d942c | 86 | |
Rohit Grover |
37:c29c330d942c | 87 | /**@brief Blood Pressure Service structure. This contains various status information for |
Rohit Grover |
37:c29c330d942c | 88 | * the service. */ |
Rohit Grover |
37:c29c330d942c | 89 | typedef struct ble_bps_s |
Rohit Grover |
37:c29c330d942c | 90 | { |
Rohit Grover |
37:c29c330d942c | 91 | ble_bps_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Blood Pressure Service. */ |
Rohit Grover |
37:c29c330d942c | 92 | uint16_t service_handle; /**< Handle of Blood Pressure Service (as provided by the BLE stack). */ |
Rohit Grover |
37:c29c330d942c | 93 | ble_gatts_char_handles_t meas_handles; /**< Handles related to the Blood Pressure Measurement characteristic. */ |
Rohit Grover |
37:c29c330d942c | 94 | ble_gatts_char_handles_t feature_handles; /**< Handles related to the Blood Pressure Feature characteristic. */ |
Rohit Grover |
37:c29c330d942c | 95 | uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ |
Rohit Grover |
37:c29c330d942c | 96 | uint16_t feature; /**< Value of Blood Pressure feature. */ |
Rohit Grover |
37:c29c330d942c | 97 | } ble_bps_t; |
Rohit Grover |
37:c29c330d942c | 98 | |
Rohit Grover |
37:c29c330d942c | 99 | /**@brief Blood Pressure Service measurement structure. This contains a Blood Pressure |
Rohit Grover |
37:c29c330d942c | 100 | * measurement. */ |
Rohit Grover |
37:c29c330d942c | 101 | typedef struct ble_bps_meas_s |
Rohit Grover |
37:c29c330d942c | 102 | { |
Rohit Grover |
37:c29c330d942c | 103 | bool blood_pressure_units_in_kpa; /**< Blood Pressure Units Flag, 0=mmHg, 1=kPa */ |
Rohit Grover |
37:c29c330d942c | 104 | bool time_stamp_present; /**< Time Stamp Flag, 0=not present, 1=present. */ |
Rohit Grover |
37:c29c330d942c | 105 | bool pulse_rate_present; /**< Pulse Rate Flag, 0=not present, 1=present. */ |
Rohit Grover |
37:c29c330d942c | 106 | bool user_id_present; /**< User ID Flag, 0=not present, 1=present. */ |
Rohit Grover |
37:c29c330d942c | 107 | bool measurement_status_present; /**< Measurement Status Flag, 0=not present, 1=present. */ |
Rohit Grover |
37:c29c330d942c | 108 | ieee_float16_t blood_pressure_systolic; /**< Blood Pressure Measurement Compound Value - Systolic. */ |
Rohit Grover |
37:c29c330d942c | 109 | ieee_float16_t blood_pressure_diastolic; /**< Blood Pressure Measurement Compound Value - Diastolic . */ |
Rohit Grover |
37:c29c330d942c | 110 | ieee_float16_t mean_arterial_pressure; /**< Blood Pressure Measurement Compound Value - Mean Arterial Pressure. */ |
Rohit Grover |
37:c29c330d942c | 111 | ble_date_time_t time_stamp; /**< Time Stamp. */ |
Rohit Grover |
37:c29c330d942c | 112 | ieee_float16_t pulse_rate; /**< Pulse Rate. */ |
Rohit Grover |
37:c29c330d942c | 113 | uint8_t user_id; /**< User ID. */ |
Rohit Grover |
37:c29c330d942c | 114 | uint16_t measurement_status; /**< Measurement Status. */ |
Rohit Grover |
37:c29c330d942c | 115 | } ble_bps_meas_t; |
Rohit Grover |
37:c29c330d942c | 116 | |
Rohit Grover |
37:c29c330d942c | 117 | /**@brief Function for initializing the Blood Pressure Service. |
Rohit Grover |
37:c29c330d942c | 118 | * |
Rohit Grover |
37:c29c330d942c | 119 | * @param[out] p_bps Blood Pressure Service structure. This structure will have to |
Rohit Grover |
37:c29c330d942c | 120 | * be supplied by the application. It will be initialized by this function, |
Rohit Grover |
37:c29c330d942c | 121 | * and will later be used to identify this particular service instance. |
Rohit Grover |
37:c29c330d942c | 122 | * @param[in] p_bps_init Information needed to initialize the service. |
Rohit Grover |
37:c29c330d942c | 123 | * |
Rohit Grover |
37:c29c330d942c | 124 | * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. |
Rohit Grover |
37:c29c330d942c | 125 | */ |
Rohit Grover |
37:c29c330d942c | 126 | uint32_t ble_bps_init(ble_bps_t * p_bps, const ble_bps_init_t * p_bps_init); |
Rohit Grover |
37:c29c330d942c | 127 | |
Rohit Grover |
37:c29c330d942c | 128 | /**@brief Function for handling the Application's BLE Stack events. |
Rohit Grover |
37:c29c330d942c | 129 | * |
Rohit Grover |
37:c29c330d942c | 130 | * @details Handles all events from the BLE stack of interest to the Blood Pressure Service. |
Rohit Grover |
37:c29c330d942c | 131 | * |
Rohit Grover |
37:c29c330d942c | 132 | * @param[in] p_bps Blood Pressure Service structure. |
Rohit Grover |
37:c29c330d942c | 133 | * @param[in] p_ble_evt Event received from the BLE stack. |
Rohit Grover |
37:c29c330d942c | 134 | */ |
Rohit Grover |
37:c29c330d942c | 135 | void ble_bps_on_ble_evt(ble_bps_t * p_bps, ble_evt_t * p_ble_evt); |
Rohit Grover |
37:c29c330d942c | 136 | |
Rohit Grover |
37:c29c330d942c | 137 | /**@brief Function for sending blood pressure measurement if indication has been enabled. |
Rohit Grover |
37:c29c330d942c | 138 | * |
Rohit Grover |
37:c29c330d942c | 139 | * @details The application calls this function after having performed a Blood Pressure |
Rohit Grover |
37:c29c330d942c | 140 | * measurement. If indication has been enabled, the measurement data is encoded and |
Rohit Grover |
37:c29c330d942c | 141 | * sent to the client. |
Rohit Grover |
37:c29c330d942c | 142 | * |
Rohit Grover |
37:c29c330d942c | 143 | * @param[in] p_bps Blood Pressure Service structure. |
Rohit Grover |
37:c29c330d942c | 144 | * @param[in] p_bps_meas Pointer to new blood pressure measurement. |
Rohit Grover |
37:c29c330d942c | 145 | * |
Rohit Grover |
37:c29c330d942c | 146 | * @return NRF_SUCCESS on success, otherwise an error code. |
Rohit Grover |
37:c29c330d942c | 147 | */ |
Rohit Grover |
37:c29c330d942c | 148 | uint32_t ble_bps_measurement_send(ble_bps_t * p_bps, ble_bps_meas_t * p_bps_meas); |
Rohit Grover |
37:c29c330d942c | 149 | |
Rohit Grover |
37:c29c330d942c | 150 | /**@brief Function for checking if indication of Blood Pressure Measurement is currently enabled. |
Rohit Grover |
37:c29c330d942c | 151 | * |
Rohit Grover |
37:c29c330d942c | 152 | * @param[in] p_bps Blood Pressure Service structure. |
Rohit Grover |
37:c29c330d942c | 153 | * @param[out] p_indication_enabled TRUE if indication is enabled, FALSE otherwise. |
Rohit Grover |
37:c29c330d942c | 154 | * |
Rohit Grover |
37:c29c330d942c | 155 | * @return NRF_SUCCESS on success, otherwise an error code. |
Rohit Grover |
37:c29c330d942c | 156 | */ |
Rohit Grover |
37:c29c330d942c | 157 | uint32_t ble_bps_is_indication_enabled(ble_bps_t * p_bps, bool * p_indication_enabled); |
Rohit Grover |
37:c29c330d942c | 158 | |
Rohit Grover |
37:c29c330d942c | 159 | #endif // BLE_BPS_H__ |
Rohit Grover |
37:c29c330d942c | 160 | |
Rohit Grover |
37:c29c330d942c | 161 | /** @} */ |