Nordic stack and drivers for the mbed BLE API Modified for HRM1017 for library 0.1.0
Fork of nRF51822 by
ble_rscs.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 00013 /** @file 00014 * 00015 * @defgroup ble_sdk_srv_rsc Running Speed and Cadence Service 00016 * @{ 00017 * @ingroup ble_sdk_srv 00018 * @brief Running Speed and Cadence Service module. 00019 * 00020 * @details This module implements the Running Speed and Cadence Service. If enabled, notification 00021 * of the Running Speead and Candence Measurement is performed when the application 00022 * calls ble_rscs_measurement_send(). 00023 * 00024 * If an event handler is supplied by the application, the Running Speed and Cadence 00025 * Service will generate Running Speed and Cadence Service events to the application. 00026 * 00027 * @note The application must propagate BLE stack events to the Running Speead and Candence Service 00028 * module by calling ble_rscs_on_ble_evt() from the from the @ref ble_stack_handler function. 00029 * 00030 * @note Attention! 00031 * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile 00032 * qualification listings, this section of source code must not be modified. 00033 */ 00034 00035 #ifndef BLE_RSCS_H__ 00036 #define BLE_RSCS_H__ 00037 00038 #include <stdint.h> 00039 #include <stdbool.h> 00040 #include "ble.h" 00041 #include "ble_srv_common.h " 00042 00043 /**@brief Running Speed and Cadence Service feature bits. */ 00044 #define BLE_RSCS_FEATURE_INSTANT_STRIDE_LEN_BIT (0x01 << 0) /**< Instantaneous Stride Length Measurement Supported bit. */ 00045 #define BLE_RSCS_FEATURE_TOTAL_DISTANCE_BIT (0x01 << 1) /**< Total Distance Measurement Supported bit. */ 00046 #define BLE_RSCS_FEATURE_WALKING_OR_RUNNING_STATUS_BIT (0x01 << 2) /**< Walking or Running Status Supported bit. */ 00047 #define BLE_RSCS_FEATURE_CALIBRATION_PROCEDURE_BIT (0x01 << 3) /**< Calibration Procedure Supported bit. */ 00048 #define BLE_RSCS_FEATURE_MULTIPLE_SENSORS_BIT (0x01 << 4) /**< Multiple Sensor Locations Supported bit. */ 00049 00050 /**@brief Running Speed and Cadence Service event type. */ 00051 typedef enum 00052 { 00053 BLE_RSCS_EVT_NOTIFICATION_ENABLED, /**< Running Speed and Cadence value notification enabled event. */ 00054 BLE_RSCS_EVT_NOTIFICATION_DISABLED /**< Running Speed and Cadence value notification disabled event. */ 00055 } ble_rscs_evt_type_t; 00056 00057 /**@brief Running Speed and Cadence Service event. */ 00058 typedef struct 00059 { 00060 ble_rscs_evt_type_t evt_type; /**< Type of event. */ 00061 } ble_rscs_evt_t; 00062 00063 // Forward declaration of the ble_rsc_t type. 00064 typedef struct ble_rscs_s ble_rscs_t; 00065 00066 /**@brief Running Speed and Cadence Service event handler type. */ 00067 typedef void (*ble_rscs_evt_handler_t) (ble_rscs_t * p_rscs, ble_rscs_evt_t * p_evt); 00068 00069 /**@brief Running Speed and Cadence Service init structure. This contains all options and data 00070 * needed for initialization of the service. */ 00071 typedef struct 00072 { 00073 ble_rscs_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Running Speed and Cadence Service. */ 00074 ble_srv_cccd_security_mode_t rsc_meas_attr_md; /**< Initial security level for running speed and cadence measurement attribute */ 00075 ble_srv_security_mode_t rsc_feature_attr_md; /**< Initial security level for feature attribute */ 00076 uint16_t feature; /**< Initial value for features of sensor. */ 00077 } ble_rscs_init_t; 00078 00079 /**@brief Running Speed and Cadence Service structure. This contains various status information for 00080 * the service. */ 00081 typedef struct ble_rscs_s 00082 { 00083 ble_rscs_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Running Speed and Cadence Service. */ 00084 uint16_t service_handle; /**< Handle of Running Speed and Cadence Service (as provided by the BLE stack). */ 00085 ble_gatts_char_handles_t meas_handles; /**< Handles related to the Running Speed and Cadence Measurement characteristic. */ 00086 ble_gatts_char_handles_t feature_handles; /**< Handles related to the Running Speed and Cadence feature characteristic. */ 00087 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). */ 00088 uint16_t feature; /**< Bit mask of features available on sensor. */ 00089 } ble_rscs_t; 00090 00091 /**@brief Running Speed and Cadence Service measurement structure. This contains a Running Speed and 00092 * Cadence measurement. */ 00093 typedef struct ble_rscs_meas_s 00094 { 00095 bool is_inst_stride_len_present; /**< True if Instantaneous Stride Length is present in the measurement. */ 00096 bool is_total_distance_present; /**< True if Total Distance is present in the measurement. */ 00097 bool is_running; /**< True if running, False if walking. */ 00098 uint16_t inst_speed; /**< Instantaneous Speed. */ 00099 uint8_t inst_cadence; /**< Instantaneous Cadence. */ 00100 uint16_t inst_stride_length; /**< Instantaneous Stride Length. */ 00101 uint32_t total_distance; /**< Total Distance. */ 00102 } ble_rscs_meas_t; 00103 00104 /**@brief Function for initializing the Running Speed and Cadence Service. 00105 * 00106 * @param[out] p_rscs Running Speed and Cadence Service structure. This structure will have to 00107 * be supplied by the application. It will be initialized by this function, 00108 * and will later be used to identify this particular service instance. 00109 * @param[in] p_rscs_init Information needed to initialize the service. 00110 * 00111 * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. 00112 */ 00113 uint32_t ble_rscs_init(ble_rscs_t * p_rscs, const ble_rscs_init_t * p_rscs_init); 00114 00115 /**@brief Function for handling the Application's BLE Stack events. 00116 * 00117 * @details Handles all events from the BLE stack of interest to the Running Speed and Cadence 00118 * Service. 00119 * 00120 * @param[in] p_rscs Running Speed and Cadence Service structure. 00121 * @param[in] p_ble_evt Event received from the BLE stack. 00122 */ 00123 void ble_rscs_on_ble_evt(ble_rscs_t * p_rscs, ble_evt_t * p_ble_evt); 00124 00125 /**@brief Function for sending running speed and cadence measurement if notification has been enabled. 00126 * 00127 * @details The application calls this function after having performed a Running Speed and Cadence 00128 * measurement. If notification has been enabled, the measurement data is encoded and sent 00129 * to the client. 00130 * 00131 * @param[in] p_rscs Running Speed and Cadence Service structure. 00132 * @param[in] p_measurement Pointer to new running speed and cadence measurement. 00133 * 00134 * @return NRF_SUCCESS on success, otherwise an error code. 00135 */ 00136 uint32_t ble_rscs_measurement_send(ble_rscs_t * p_rscs, ble_rscs_meas_t * p_measurement); 00137 00138 #endif // BLE_RSCS_H__ 00139 00140 /** @} */
Generated on Tue Jul 12 2022 14:11:55 by 1.7.2