iOSのBLEコントローラアプリ「RCBController」と接続し、コントローラの操作を取得するサンプルプログラムです。 mbed HRM1017で動作を確認しています。 2014.08.20時点でのBLEライブラリに対応しました。

Dependencies:   BLE_API mbed

Fork of BLE_RCBController by Junichi Katsu

Committer:
jksoft
Date:
Wed Aug 20 13:41:01 2014 +0000
Revision:
4:ebda47d22091
Parent:
nRF51822/nordic/nrf-sdk/ble/ble_services/ble_bps.h@1:48f6e08a3ac2
?????????

Who changed what in which revision?

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