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_hts.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_hts Health Thermometer Service
jksoft 1:48f6e08a3ac2 15 * @{
jksoft 1:48f6e08a3ac2 16 * @ingroup ble_sdk_srv
jksoft 1:48f6e08a3ac2 17 * @brief Health Thermometer Service module.
jksoft 1:48f6e08a3ac2 18 *
jksoft 1:48f6e08a3ac2 19 * @details This module implements the Health Thermometer Service.
jksoft 1:48f6e08a3ac2 20 *
jksoft 1:48f6e08a3ac2 21 * If an event handler is supplied by the application, the Health Thermometer
jksoft 1:48f6e08a3ac2 22 * Service will generate Health Thermometer Service events to the application.
jksoft 1:48f6e08a3ac2 23 *
jksoft 1:48f6e08a3ac2 24 * @note The application must propagate BLE stack events to the Health Thermometer Service
jksoft 1:48f6e08a3ac2 25 * module by calling ble_hts_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_HTS_H__
jksoft 1:48f6e08a3ac2 33 #define BLE_HTS_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 // Temperature Type measurement locations
jksoft 1:48f6e08a3ac2 42 #define BLE_HTS_TEMP_TYPE_ARMPIT 1
jksoft 1:48f6e08a3ac2 43 #define BLE_HTS_TEMP_TYPE_BODY 2
jksoft 1:48f6e08a3ac2 44 #define BLE_HTS_TEMP_TYPE_EAR 3
jksoft 1:48f6e08a3ac2 45 #define BLE_HTS_TEMP_TYPE_FINGER 4
jksoft 1:48f6e08a3ac2 46 #define BLE_HTS_TEMP_TYPE_GI_TRACT 5
jksoft 1:48f6e08a3ac2 47 #define BLE_HTS_TEMP_TYPE_MOUTH 6
jksoft 1:48f6e08a3ac2 48 #define BLE_HTS_TEMP_TYPE_RECTUM 7
jksoft 1:48f6e08a3ac2 49 #define BLE_HTS_TEMP_TYPE_TOE 8
jksoft 1:48f6e08a3ac2 50 #define BLE_HTS_TEMP_TYPE_EAR_DRUM 9
jksoft 1:48f6e08a3ac2 51
jksoft 1:48f6e08a3ac2 52 /**@brief Health Thermometer Service event type. */
jksoft 1:48f6e08a3ac2 53 typedef enum
jksoft 1:48f6e08a3ac2 54 {
jksoft 1:48f6e08a3ac2 55 BLE_HTS_EVT_INDICATION_ENABLED, /**< Health Thermometer value indication enabled event. */
jksoft 1:48f6e08a3ac2 56 BLE_HTS_EVT_INDICATION_DISABLED, /**< Health Thermometer value indication disabled event. */
jksoft 1:48f6e08a3ac2 57 BLE_HTS_EVT_INDICATION_CONFIRMED /**< Confirmation of a temperature measurement indication has been received. */
jksoft 1:48f6e08a3ac2 58 } ble_hts_evt_type_t;
jksoft 1:48f6e08a3ac2 59
jksoft 1:48f6e08a3ac2 60 /**@brief Health Thermometer Service event. */
jksoft 1:48f6e08a3ac2 61 typedef struct
jksoft 1:48f6e08a3ac2 62 {
jksoft 1:48f6e08a3ac2 63 ble_hts_evt_type_t evt_type; /**< Type of event. */
jksoft 1:48f6e08a3ac2 64 } ble_hts_evt_t;
jksoft 1:48f6e08a3ac2 65
jksoft 1:48f6e08a3ac2 66 // Forward declaration of the ble_hts_t type.
jksoft 1:48f6e08a3ac2 67 typedef struct ble_hts_s ble_hts_t;
jksoft 1:48f6e08a3ac2 68
jksoft 1:48f6e08a3ac2 69 /**@brief Health Thermometer Service event handler type. */
jksoft 1:48f6e08a3ac2 70 typedef void (*ble_hts_evt_handler_t) (ble_hts_t * p_hts, ble_hts_evt_t * p_evt);
jksoft 1:48f6e08a3ac2 71
jksoft 1:48f6e08a3ac2 72 /**@brief FLOAT format (IEEE-11073 32-bit FLOAT, defined as a 32-bit value with a 24-bit mantissa
jksoft 1:48f6e08a3ac2 73 * and an 8-bit exponent. */
jksoft 1:48f6e08a3ac2 74 typedef struct
jksoft 1:48f6e08a3ac2 75 {
jksoft 1:48f6e08a3ac2 76 int8_t exponent; /**< Base 10 exponent */
jksoft 1:48f6e08a3ac2 77 int32_t mantissa; /**< Mantissa, should be using only 24 bits */
jksoft 1:48f6e08a3ac2 78 } ieee_float32_t;
jksoft 1:48f6e08a3ac2 79
jksoft 1:48f6e08a3ac2 80 /**@brief Health Thermometer Service init structure. This contains all options and data
jksoft 1:48f6e08a3ac2 81 * needed for initialization of the service. */
jksoft 1:48f6e08a3ac2 82 typedef struct
jksoft 1:48f6e08a3ac2 83 {
jksoft 1:48f6e08a3ac2 84 ble_hts_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Health Thermometer Service. */
jksoft 1:48f6e08a3ac2 85 ble_srv_cccd_security_mode_t hts_meas_attr_md; /**< Initial security level for health thermometer measurement attribute */
jksoft 1:48f6e08a3ac2 86 ble_srv_security_mode_t hts_temp_type_attr_md; /**< Initial security level for health thermometer tempearture type attribute */
jksoft 1:48f6e08a3ac2 87 uint8_t temp_type_as_characteristic; /**< Set non-zero if temp type given as characteristic */
jksoft 1:48f6e08a3ac2 88 uint8_t temp_type; /**< Temperature type if temperature characteristic is used */
jksoft 1:48f6e08a3ac2 89 } ble_hts_init_t;
jksoft 1:48f6e08a3ac2 90
jksoft 1:48f6e08a3ac2 91 /**@brief Health Thermometer Service structure. This contains various status information for
jksoft 1:48f6e08a3ac2 92 * the service. */
jksoft 1:48f6e08a3ac2 93 typedef struct ble_hts_s
jksoft 1:48f6e08a3ac2 94 {
jksoft 1:48f6e08a3ac2 95 ble_hts_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Health Thermometer Service. */
jksoft 1:48f6e08a3ac2 96 uint16_t service_handle; /**< Handle of Health Thermometer Service (as provided by the BLE stack). */
jksoft 1:48f6e08a3ac2 97 ble_gatts_char_handles_t meas_handles; /**< Handles related to the Health Thermometer Measurement characteristic. */
jksoft 1:48f6e08a3ac2 98 ble_gatts_char_handles_t temp_type_handles; /**< Handles related to the Health Thermometer Temperature Type characteristic. */
jksoft 1:48f6e08a3ac2 99 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 100 uint8_t temp_type; /**< Temperature type indicates where the measurement was taken. */
jksoft 1:48f6e08a3ac2 101 } ble_hts_t;
jksoft 1:48f6e08a3ac2 102
jksoft 1:48f6e08a3ac2 103 /**@brief Health Thermometer Service measurement structure. This contains a Health Thermometer
jksoft 1:48f6e08a3ac2 104 * measurement. */
jksoft 1:48f6e08a3ac2 105 typedef struct ble_hts_meas_s
jksoft 1:48f6e08a3ac2 106 {
jksoft 1:48f6e08a3ac2 107 bool temp_in_fahr_units; /**< True if Temperature is in Fahrenheit units, Celcius otherwise. */
jksoft 1:48f6e08a3ac2 108 bool time_stamp_present; /**< True if Time Stamp is present. */
jksoft 1:48f6e08a3ac2 109 bool temp_type_present; /**< True if Temperature Type is present. */
jksoft 1:48f6e08a3ac2 110 ieee_float32_t temp_in_celcius; /**< Temperature Measurement Value (Celcius). */
jksoft 1:48f6e08a3ac2 111 ieee_float32_t temp_in_fahr; /**< Temperature Measurement Value (Fahrenheit). */
jksoft 1:48f6e08a3ac2 112 ble_date_time_t time_stamp; /**< Time Stamp. */
jksoft 1:48f6e08a3ac2 113 uint8_t temp_type; /**< Temperature Type. */
jksoft 1:48f6e08a3ac2 114 } ble_hts_meas_t;
jksoft 1:48f6e08a3ac2 115
jksoft 1:48f6e08a3ac2 116 /**@brief Function for initializing the Health Thermometer Service.
jksoft 1:48f6e08a3ac2 117 *
jksoft 1:48f6e08a3ac2 118 * @param[out] p_hts Health Thermometer Service structure. This structure will have to
jksoft 1:48f6e08a3ac2 119 * be supplied by the application. It will be initialized by this function,
jksoft 1:48f6e08a3ac2 120 * and will later be used to identify this particular service instance.
jksoft 1:48f6e08a3ac2 121 * @param[in] p_hts_init Information needed to initialize the service.
jksoft 1:48f6e08a3ac2 122 *
jksoft 1:48f6e08a3ac2 123 * @return NRF_SUCCESS on successful initialization of service, otherwise an error code.
jksoft 1:48f6e08a3ac2 124 */
jksoft 1:48f6e08a3ac2 125 uint32_t ble_hts_init(ble_hts_t * p_hts, const ble_hts_init_t * p_hts_init);
jksoft 1:48f6e08a3ac2 126
jksoft 1:48f6e08a3ac2 127 /**@brief Function for handling the Application's BLE Stack events.
jksoft 1:48f6e08a3ac2 128 *
jksoft 1:48f6e08a3ac2 129 * @details Handles all events from the BLE stack of interest to the Health Thermometer Service.
jksoft 1:48f6e08a3ac2 130 *
jksoft 1:48f6e08a3ac2 131 * @param[in] p_hts Health Thermometer Service structure.
jksoft 1:48f6e08a3ac2 132 * @param[in] p_ble_evt Event received from the BLE stack.
jksoft 1:48f6e08a3ac2 133 */
jksoft 1:48f6e08a3ac2 134 void ble_hts_on_ble_evt(ble_hts_t * p_hts, ble_evt_t * p_ble_evt);
jksoft 1:48f6e08a3ac2 135
jksoft 1:48f6e08a3ac2 136 /**@brief Function for sending health thermometer measurement if indication has been enabled.
jksoft 1:48f6e08a3ac2 137 *
jksoft 1:48f6e08a3ac2 138 * @details The application calls this function after having performed a Health Thermometer
jksoft 1:48f6e08a3ac2 139 * measurement. If indication has been enabled, the measurement data is encoded and
jksoft 1:48f6e08a3ac2 140 * sent to the client.
jksoft 1:48f6e08a3ac2 141 *
jksoft 1:48f6e08a3ac2 142 * @param[in] p_hts Health Thermometer Service structure.
jksoft 1:48f6e08a3ac2 143 * @param[in] p_hts_meas Pointer to new health thermometer measurement.
jksoft 1:48f6e08a3ac2 144 *
jksoft 1:48f6e08a3ac2 145 * @return NRF_SUCCESS on success, otherwise an error code.
jksoft 1:48f6e08a3ac2 146 */
jksoft 1:48f6e08a3ac2 147 uint32_t ble_hts_measurement_send(ble_hts_t * p_hts, ble_hts_meas_t * p_hts_meas);
jksoft 1:48f6e08a3ac2 148
jksoft 1:48f6e08a3ac2 149 /**@brief Function for checking if indication of Temperature Measurement is currently enabled.
jksoft 1:48f6e08a3ac2 150 *
jksoft 1:48f6e08a3ac2 151 * @param[in] p_hts Health Thermometer Service structure.
jksoft 1:48f6e08a3ac2 152 * @param[out] p_indication_enabled TRUE if indication is enabled, FALSE otherwise.
jksoft 1:48f6e08a3ac2 153 *
jksoft 1:48f6e08a3ac2 154 * @return NRF_SUCCESS on success, otherwise an error code.
jksoft 1:48f6e08a3ac2 155 */
jksoft 1:48f6e08a3ac2 156 uint32_t ble_hts_is_indication_enabled(ble_hts_t * p_hts, bool * p_indication_enabled);
jksoft 1:48f6e08a3ac2 157
jksoft 1:48f6e08a3ac2 158 #endif // BLE_HTS_H__
jksoft 1:48f6e08a3ac2 159
jksoft 1:48f6e08a3ac2 160 /** @} */