テスト用です。

Dependencies:   mbed

Committer:
jksoft
Date:
Tue Oct 11 11:09:42 2016 +0000
Revision:
0:8468a4403fea
SB??ver;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:8468a4403fea 1 /*
jksoft 0:8468a4403fea 2 * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
jksoft 0:8468a4403fea 3 *
jksoft 0:8468a4403fea 4 * The information contained herein is confidential property of Nordic Semiconductor. The use,
jksoft 0:8468a4403fea 5 * copying, transfer or disclosure of such information is prohibited except by express written
jksoft 0:8468a4403fea 6 * agreement with Nordic Semiconductor.
jksoft 0:8468a4403fea 7 *
jksoft 0:8468a4403fea 8 */
jksoft 0:8468a4403fea 9
jksoft 0:8468a4403fea 10 /**@file
jksoft 0:8468a4403fea 11 *
jksoft 0:8468a4403fea 12 * @defgroup ble_sdk_srv_hrs_c Heart Rate Service Client
jksoft 0:8468a4403fea 13 * @{
jksoft 0:8468a4403fea 14 * @ingroup ble_sdk_srv
jksoft 0:8468a4403fea 15 * @brief Heart Rate Service Client module.
jksoft 0:8468a4403fea 16 *
jksoft 0:8468a4403fea 17 * @details This module contains the APIs and types exposed by the Heart Rate Service Client
jksoft 0:8468a4403fea 18 * module. These APIs and types can be used by the application to perform discovery of
jksoft 0:8468a4403fea 19 * Heart Rate Service at the peer and interact with it.
jksoft 0:8468a4403fea 20 *
jksoft 0:8468a4403fea 21 * @warning Currently this module only has support for Heart Rate Measurement characteristic. This
jksoft 0:8468a4403fea 22 * means that it will be able to enable notification of the characteristic at the peer and
jksoft 0:8468a4403fea 23 * be able to receive Heart Rate Measurement notifications from the peer. It does not
jksoft 0:8468a4403fea 24 * support the Body Sensor Location and the Heart Rate Control Point characteristics.
jksoft 0:8468a4403fea 25 * When a Heart Rate Measurement is received, this module will decode only the
jksoft 0:8468a4403fea 26 * Heart Rate Measurement Value (both 8 bit and 16 bit) field from it and provide it to
jksoft 0:8468a4403fea 27 * the application.
jksoft 0:8468a4403fea 28 *
jksoft 0:8468a4403fea 29 * @note The application must propagate BLE stack events to this module by calling
jksoft 0:8468a4403fea 30 * ble_hrs_c_on_ble_evt().
jksoft 0:8468a4403fea 31 *
jksoft 0:8468a4403fea 32 */
jksoft 0:8468a4403fea 33
jksoft 0:8468a4403fea 34 #ifndef BLE_HRS_C_H__
jksoft 0:8468a4403fea 35 #define BLE_HRS_C_H__
jksoft 0:8468a4403fea 36
jksoft 0:8468a4403fea 37 #include <stdint.h>
jksoft 0:8468a4403fea 38 #include "ble.h"
jksoft 0:8468a4403fea 39
jksoft 0:8468a4403fea 40 /**
jksoft 0:8468a4403fea 41 * @defgroup hrs_c_enums Enumerations
jksoft 0:8468a4403fea 42 * @{
jksoft 0:8468a4403fea 43 */
jksoft 0:8468a4403fea 44
jksoft 0:8468a4403fea 45 /**@brief HRS Client event type. */
jksoft 0:8468a4403fea 46 typedef enum
jksoft 0:8468a4403fea 47 {
jksoft 0:8468a4403fea 48 BLE_HRS_C_EVT_DISCOVERY_COMPLETE = 1, /**< Event indicating that the Heart Rate Service has been discovered at the peer. */
jksoft 0:8468a4403fea 49 BLE_HRS_C_EVT_HRM_NOTIFICATION /**< Event indicating that a notification of the Heart Rate Measurement characteristic has been received from the peer. */
jksoft 0:8468a4403fea 50 } ble_hrs_c_evt_type_t;
jksoft 0:8468a4403fea 51
jksoft 0:8468a4403fea 52 /** @} */
jksoft 0:8468a4403fea 53
jksoft 0:8468a4403fea 54 /**
jksoft 0:8468a4403fea 55 * @defgroup hrs_c_structs Structures
jksoft 0:8468a4403fea 56 * @{
jksoft 0:8468a4403fea 57 */
jksoft 0:8468a4403fea 58
jksoft 0:8468a4403fea 59 /**@brief Structure containing the heart rate measurement received from the peer. */
jksoft 0:8468a4403fea 60 typedef struct
jksoft 0:8468a4403fea 61 {
jksoft 0:8468a4403fea 62 uint16_t hr_value; /**< Heart Rate Value. */
jksoft 0:8468a4403fea 63 } ble_hrm_t;
jksoft 0:8468a4403fea 64
jksoft 0:8468a4403fea 65 /**@brief Heart Rate Event structure. */
jksoft 0:8468a4403fea 66 typedef struct
jksoft 0:8468a4403fea 67 {
jksoft 0:8468a4403fea 68 ble_hrs_c_evt_type_t evt_type; /**< Type of the event. */
jksoft 0:8468a4403fea 69 union
jksoft 0:8468a4403fea 70 {
jksoft 0:8468a4403fea 71 ble_hrm_t hrm; /**< Heart rate measurement received. This will be filled if the evt_type is @ref BLE_HRS_C_EVT_HRM_NOTIFICATION. */
jksoft 0:8468a4403fea 72 } params;
jksoft 0:8468a4403fea 73 } ble_hrs_c_evt_t;
jksoft 0:8468a4403fea 74
jksoft 0:8468a4403fea 75 /** @} */
jksoft 0:8468a4403fea 76
jksoft 0:8468a4403fea 77 /**
jksoft 0:8468a4403fea 78 * @defgroup hrs_c_types Types
jksoft 0:8468a4403fea 79 * @{
jksoft 0:8468a4403fea 80 */
jksoft 0:8468a4403fea 81
jksoft 0:8468a4403fea 82 // Forward declaration of the ble_bas_t type.
jksoft 0:8468a4403fea 83 typedef struct ble_hrs_c_s ble_hrs_c_t;
jksoft 0:8468a4403fea 84
jksoft 0:8468a4403fea 85 /**@brief Event handler type.
jksoft 0:8468a4403fea 86 *
jksoft 0:8468a4403fea 87 * @details This is the type of the event handler that should be provided by the application
jksoft 0:8468a4403fea 88 * of this module in order to receive events.
jksoft 0:8468a4403fea 89 */
jksoft 0:8468a4403fea 90 typedef void (* ble_hrs_c_evt_handler_t) (ble_hrs_c_t * p_ble_hrs_c, ble_hrs_c_evt_t * p_evt);
jksoft 0:8468a4403fea 91
jksoft 0:8468a4403fea 92 /** @} */
jksoft 0:8468a4403fea 93
jksoft 0:8468a4403fea 94 /**
jksoft 0:8468a4403fea 95 * @addtogroup hrs_c_structs
jksoft 0:8468a4403fea 96 * @{
jksoft 0:8468a4403fea 97 */
jksoft 0:8468a4403fea 98
jksoft 0:8468a4403fea 99 /**@brief Heart Rate Client structure.
jksoft 0:8468a4403fea 100 */
jksoft 0:8468a4403fea 101 typedef struct ble_hrs_c_s
jksoft 0:8468a4403fea 102 {
jksoft 0:8468a4403fea 103 uint16_t conn_handle; /**< Connection handle as provided by the SoftDevice. */
jksoft 0:8468a4403fea 104 uint16_t hrm_cccd_handle; /**< Handle of the CCCD of the Heart Rate Measurement characteristic. */
jksoft 0:8468a4403fea 105 uint16_t hrm_handle; /**< Handle of the Heart Rate Measurement characteristic as provided by the SoftDevice. */
jksoft 0:8468a4403fea 106 ble_hrs_c_evt_handler_t evt_handler; /**< Application event handler to be called when there is an event related to the heart rate service. */
jksoft 0:8468a4403fea 107 } ble_hrs_c_t;
jksoft 0:8468a4403fea 108
jksoft 0:8468a4403fea 109 /**@brief Heart Rate Client initialization structure.
jksoft 0:8468a4403fea 110 */
jksoft 0:8468a4403fea 111 typedef struct
jksoft 0:8468a4403fea 112 {
jksoft 0:8468a4403fea 113 ble_hrs_c_evt_handler_t evt_handler; /**< Event handler to be called by the Heart Rate Client module whenever there is an event related to the Heart Rate Service. */
jksoft 0:8468a4403fea 114 } ble_hrs_c_init_t;
jksoft 0:8468a4403fea 115
jksoft 0:8468a4403fea 116 /** @} */
jksoft 0:8468a4403fea 117
jksoft 0:8468a4403fea 118 /**
jksoft 0:8468a4403fea 119 * @defgroup hrs_c_functions Functions
jksoft 0:8468a4403fea 120 * @{
jksoft 0:8468a4403fea 121 */
jksoft 0:8468a4403fea 122
jksoft 0:8468a4403fea 123 /**@brief Function for initializing the heart rate client module.
jksoft 0:8468a4403fea 124 *
jksoft 0:8468a4403fea 125 * @details This function will register with the DB Discovery module. There it
jksoft 0:8468a4403fea 126 * registers for the Heart Rate Service. Doing so will make the DB Discovery
jksoft 0:8468a4403fea 127 * module look for the presence of a Heart Rate Service instance at the peer when a
jksoft 0:8468a4403fea 128 * discovery is started.
jksoft 0:8468a4403fea 129 *
jksoft 0:8468a4403fea 130 * @param[in] p_ble_hrs_c Pointer to the heart rate client structure.
jksoft 0:8468a4403fea 131 * @param[in] p_ble_hrs_c_init Pointer to the heart rate initialization structure containing the
jksoft 0:8468a4403fea 132 * initialization information.
jksoft 0:8468a4403fea 133 *
jksoft 0:8468a4403fea 134 * @retval NRF_SUCCESS On successful initialization. Otherwise an error code. This function
jksoft 0:8468a4403fea 135 * propagates the error code returned by the Database Discovery module API
jksoft 0:8468a4403fea 136 * @ref ble_db_discovery_evt_register.
jksoft 0:8468a4403fea 137 */
jksoft 0:8468a4403fea 138 uint32_t ble_hrs_c_init(ble_hrs_c_t * p_ble_hrs_c, ble_hrs_c_init_t * p_ble_hrs_c_init);
jksoft 0:8468a4403fea 139
jksoft 0:8468a4403fea 140 /**@brief Function for handling BLE events from the SoftDevice.
jksoft 0:8468a4403fea 141 *
jksoft 0:8468a4403fea 142 * @details This function will handle the BLE events received from the SoftDevice. If a BLE
jksoft 0:8468a4403fea 143 * event is relevant to the Heart Rate Client module, then it uses it to update
jksoft 0:8468a4403fea 144 * interval variables and, if necessary, send events to the application.
jksoft 0:8468a4403fea 145 *
jksoft 0:8468a4403fea 146 * @param[in] p_ble_hrs_c Pointer to the heart rate client structure.
jksoft 0:8468a4403fea 147 * @param[in] p_ble_evt Pointer to the BLE event.
jksoft 0:8468a4403fea 148 */
jksoft 0:8468a4403fea 149 void ble_hrs_c_on_ble_evt(ble_hrs_c_t * p_ble_hrs_c, const ble_evt_t * p_ble_evt);
jksoft 0:8468a4403fea 150
jksoft 0:8468a4403fea 151
jksoft 0:8468a4403fea 152 /**@brief Function for requesting the peer to start sending notification of Heart Rate
jksoft 0:8468a4403fea 153 * Measurement.
jksoft 0:8468a4403fea 154 *
jksoft 0:8468a4403fea 155 * @details This function will enable to notification of the Heart Rate Measurement at the peer
jksoft 0:8468a4403fea 156 * by writing to the CCCD of the Heart Rate Measurement Characteristic.
jksoft 0:8468a4403fea 157 *
jksoft 0:8468a4403fea 158 * @param p_ble_hrs_c Pointer to the heart rate client structure.
jksoft 0:8468a4403fea 159 *
jksoft 0:8468a4403fea 160 * @retval NRF_SUCCESS If the SoftDevice has been requested to write to the CCCD of the peer.
jksoft 0:8468a4403fea 161 * Otherwise, an error code. This function propagates the error code returned
jksoft 0:8468a4403fea 162 * by the SoftDevice API @ref sd_ble_gattc_write.
jksoft 0:8468a4403fea 163 */
jksoft 0:8468a4403fea 164 uint32_t ble_hrs_c_hrm_notif_enable(ble_hrs_c_t * p_ble_hrs_c);
jksoft 0:8468a4403fea 165
jksoft 0:8468a4403fea 166 /** @} */ // End tag for Function group.
jksoft 0:8468a4403fea 167
jksoft 0:8468a4403fea 168 #endif // BLE_HRS_C_H__
jksoft 0:8468a4403fea 169
jksoft 0:8468a4403fea 170 /** @} */ // End tag for the file.