Nordic stack and drivers for the mbed BLE API Modified for HRM1017 for library 0.1.0
Fork of nRF51822 by
ble_bps.h
00001 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 00002 * 00003 * The information contained herein is property of Nordic Semiconductor ASA. 00004 * Terms and conditions of usage are described in detail in NORDIC 00005 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 00006 * 00007 * Licensees are granted free, non-transferable use of the information. NO 00008 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 00009 * the file. 00010 */ 00011 00012 /** @file 00013 * 00014 * @defgroup ble_sdk_srv_bps Blood Pressure Service 00015 * @{ 00016 * @ingroup ble_sdk_srv 00017 * @brief Blood Pressure Service module. 00018 * 00019 * @details This module implements the Blood Pressure Service. 00020 * 00021 * If an event handler is supplied by the application, the Blood Pressure 00022 * Service will generate Blood Pressure Service events to the application. 00023 * 00024 * @note The application must propagate BLE stack events to the Blood Pressure Service 00025 * module by calling ble_bps_on_ble_evt() from the from the @ref ble_stack_handler function. 00026 * 00027 * @note Attention! 00028 * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 00029 * qualification listings, this section of source code must not be modified. 00030 */ 00031 00032 #ifndef BLE_BPS_H__ 00033 #define BLE_BPS_H__ 00034 00035 #include <stdint.h> 00036 #include <stdbool.h> 00037 #include "ble.h" 00038 #include "ble_srv_common.h " 00039 #include "ble_date_time.h" 00040 00041 // Blood Pressure Feature bits 00042 #define BLE_BPS_FEATURE_BODY_MOVEMENT_BIT (0x01 << 0) /**< Body Movement Detection Support bit. */ 00043 #define BLE_BPS_FEATURE_CUFF_FIT_BIT (0x01 << 1) /**< Cuff Fit Detection Support bit. */ 00044 #define BLE_BPS_FEATURE_IRREGULAR_PULSE_BIT (0x01 << 2) /**< Irregular Pulse Detection Support bit. */ 00045 #define BLE_BPS_FEATURE_PULSE_RATE_RANGE_BIT (0x01 << 3) /**< Pulse Rate Range Detection Support bit. */ 00046 #define BLE_BPS_FEATURE_MEASUREMENT_POSITION_BIT (0x01 << 4) /**< Measurement Position Detection Support bit. */ 00047 #define BLE_BPS_FEATURE_MULTIPLE_BOND_BIT (0x01 << 5) /**< Multiple Bond Support bit. */ 00048 00049 /**@brief Blood Pressure Service event type. */ 00050 typedef enum 00051 { 00052 BLE_BPS_EVT_INDICATION_ENABLED, /**< Blood Pressure value indication enabled event. */ 00053 BLE_BPS_EVT_INDICATION_DISABLED, /**< Blood Pressure value indication disabled event. */ 00054 BLE_BPS_EVT_INDICATION_CONFIRMED /**< Confirmation of a blood pressure measurement indication has been received. */ 00055 } ble_bps_evt_type_t; 00056 00057 /**@brief Blood Pressure Service event. */ 00058 typedef struct 00059 { 00060 ble_bps_evt_type_t evt_type; /**< Type of event. */ 00061 } ble_bps_evt_t; 00062 00063 // Forward declaration of the ble_bps_t type. 00064 typedef struct ble_bps_s ble_bps_t; 00065 00066 /**@brief Blood Pressure Service event handler type. */ 00067 typedef void (*ble_bps_evt_handler_t) (ble_bps_t * p_bps, ble_bps_evt_t * p_evt); 00068 00069 /**@brief SFLOAT format (IEEE-11073 16-bit FLOAT, defined as a 16-bit vlue with 12-bit mantissa and 00070 * 4-bit exponent. */ 00071 typedef struct 00072 { 00073 int8_t exponent; /**< Base 10 exponent, only 4 bits */ 00074 int16_t mantissa; /**< Mantissa, only 12 bits */ 00075 } ieee_float16_t; 00076 00077 /**@brief Blood Pressure Service init structure. This contains all options and data 00078 * needed for initialization of the service. */ 00079 typedef struct 00080 { 00081 ble_bps_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Blood Pressure Service. */ 00082 ble_srv_cccd_security_mode_t bps_meas_attr_md; /**< Initial security level for blood pressure measurement attribute */ 00083 ble_srv_security_mode_t bps_feature_attr_md; /**< Initial security level for blood pressure feature attribute */ 00084 uint16_t feature; /**< Initial value for blood pressure feature */ 00085 } ble_bps_init_t; 00086 00087 /**@brief Blood Pressure Service structure. This contains various status information for 00088 * the service. */ 00089 typedef struct ble_bps_s 00090 { 00091 ble_bps_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Blood Pressure Service. */ 00092 uint16_t service_handle; /**< Handle of Blood Pressure Service (as provided by the BLE stack). */ 00093 ble_gatts_char_handles_t meas_handles; /**< Handles related to the Blood Pressure Measurement characteristic. */ 00094 ble_gatts_char_handles_t feature_handles; /**< Handles related to the Blood Pressure Feature characteristic. */ 00095 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). */ 00096 uint16_t feature; /**< Value of Blood Pressure feature. */ 00097 } ble_bps_t; 00098 00099 /**@brief Blood Pressure Service measurement structure. This contains a Blood Pressure 00100 * measurement. */ 00101 typedef struct ble_bps_meas_s 00102 { 00103 bool blood_pressure_units_in_kpa; /**< Blood Pressure Units Flag, 0=mmHg, 1=kPa */ 00104 bool time_stamp_present; /**< Time Stamp Flag, 0=not present, 1=present. */ 00105 bool pulse_rate_present; /**< Pulse Rate Flag, 0=not present, 1=present. */ 00106 bool user_id_present; /**< User ID Flag, 0=not present, 1=present. */ 00107 bool measurement_status_present; /**< Measurement Status Flag, 0=not present, 1=present. */ 00108 ieee_float16_t blood_pressure_systolic; /**< Blood Pressure Measurement Compound Value - Systolic. */ 00109 ieee_float16_t blood_pressure_diastolic; /**< Blood Pressure Measurement Compound Value - Diastolic . */ 00110 ieee_float16_t mean_arterial_pressure; /**< Blood Pressure Measurement Compound Value - Mean Arterial Pressure. */ 00111 ble_date_time_t time_stamp; /**< Time Stamp. */ 00112 ieee_float16_t pulse_rate; /**< Pulse Rate. */ 00113 uint8_t user_id; /**< User ID. */ 00114 uint16_t measurement_status; /**< Measurement Status. */ 00115 } ble_bps_meas_t; 00116 00117 /**@brief Function for initializing the Blood Pressure Service. 00118 * 00119 * @param[out] p_bps Blood Pressure Service structure. This structure will have to 00120 * be supplied by the application. It will be initialized by this function, 00121 * and will later be used to identify this particular service instance. 00122 * @param[in] p_bps_init Information needed to initialize the service. 00123 * 00124 * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. 00125 */ 00126 uint32_t ble_bps_init(ble_bps_t * p_bps, const ble_bps_init_t * p_bps_init); 00127 00128 /**@brief Function for handling the Application's BLE Stack events. 00129 * 00130 * @details Handles all events from the BLE stack of interest to the Blood Pressure Service. 00131 * 00132 * @param[in] p_bps Blood Pressure Service structure. 00133 * @param[in] p_ble_evt Event received from the BLE stack. 00134 */ 00135 void ble_bps_on_ble_evt(ble_bps_t * p_bps, ble_evt_t * p_ble_evt); 00136 00137 /**@brief Function for sending blood pressure measurement if indication has been enabled. 00138 * 00139 * @details The application calls this function after having performed a Blood Pressure 00140 * measurement. If indication has been enabled, the measurement data is encoded and 00141 * sent to the client. 00142 * 00143 * @param[in] p_bps Blood Pressure Service structure. 00144 * @param[in] p_bps_meas Pointer to new blood pressure measurement. 00145 * 00146 * @return NRF_SUCCESS on success, otherwise an error code. 00147 */ 00148 uint32_t ble_bps_measurement_send(ble_bps_t * p_bps, ble_bps_meas_t * p_bps_meas); 00149 00150 /**@brief Function for checking if indication of Blood Pressure Measurement is currently enabled. 00151 * 00152 * @param[in] p_bps Blood Pressure Service structure. 00153 * @param[out] p_indication_enabled TRUE if indication is enabled, FALSE otherwise. 00154 * 00155 * @return NRF_SUCCESS on success, otherwise an error code. 00156 */ 00157 uint32_t ble_bps_is_indication_enabled(ble_bps_t * p_bps, bool * p_indication_enabled); 00158 00159 #endif // BLE_BPS_H__ 00160 00161 /** @} */
Generated on Tue Jul 12 2022 14:11:54 by 1.7.2