Yutaka Yoshida / Mbed 2 deprecated BLE_WallbotBLE_Challenge_byYUTAKA3

Dependencies:   mbed

Fork of BLE_WallbotBLE_Challenge_byYUTAKA3 by Maiko Matsumoto

Committer:
jksoft
Date:
Wed Nov 12 02:40:34 2014 +0000
Revision:
0:76dfa9657d9d
????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:76dfa9657d9d 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
jksoft 0:76dfa9657d9d 2 *
jksoft 0:76dfa9657d9d 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 0:76dfa9657d9d 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 0:76dfa9657d9d 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 0:76dfa9657d9d 6 *
jksoft 0:76dfa9657d9d 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 0:76dfa9657d9d 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 0:76dfa9657d9d 9 * the file.
jksoft 0:76dfa9657d9d 10 */
jksoft 0:76dfa9657d9d 11
jksoft 0:76dfa9657d9d 12 /** @file
jksoft 0:76dfa9657d9d 13 *
jksoft 0:76dfa9657d9d 14 * @defgroup ble_sdk_srv_gls Glucose Service
jksoft 0:76dfa9657d9d 15 * @{
jksoft 0:76dfa9657d9d 16 * @ingroup ble_sdk_srv
jksoft 0:76dfa9657d9d 17 * @brief Glucose Service module.
jksoft 0:76dfa9657d9d 18 *
jksoft 0:76dfa9657d9d 19 * @details This module implements the Glucose Service.
jksoft 0:76dfa9657d9d 20 *
jksoft 0:76dfa9657d9d 21 * @note The application must propagate BLE stack events to the Glucose Service module by calling
jksoft 0:76dfa9657d9d 22 * ble_gls_on_ble_evt() from the from the @ref ble_stack_handler callback.
jksoft 0:76dfa9657d9d 23 *
jksoft 0:76dfa9657d9d 24 * @note Attention!
jksoft 0:76dfa9657d9d 25 * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile
jksoft 0:76dfa9657d9d 26 * qualification listings, this section of source code must not be modified.
jksoft 0:76dfa9657d9d 27 */
jksoft 0:76dfa9657d9d 28
jksoft 0:76dfa9657d9d 29 #ifndef BLE_GLS_H__
jksoft 0:76dfa9657d9d 30 #define BLE_GLS_H__
jksoft 0:76dfa9657d9d 31
jksoft 0:76dfa9657d9d 32 #include <stdint.h>
jksoft 0:76dfa9657d9d 33 #include <stdbool.h>
jksoft 0:76dfa9657d9d 34 #include "ble.h"
jksoft 0:76dfa9657d9d 35 #include "ble_srv_common.h"
jksoft 0:76dfa9657d9d 36 #include "ble_date_time.h"
jksoft 0:76dfa9657d9d 37
jksoft 0:76dfa9657d9d 38 /**@brief Glucose feature */
jksoft 0:76dfa9657d9d 39 #define BLE_GLS_FEATURE_LOW_BATT 0x0001 /**< Low Battery Detection During Measurement Supported */
jksoft 0:76dfa9657d9d 40 #define BLE_GLS_FEATURE_MALFUNC 0x0002 /**< Sensor Malfunction Detection Supported */
jksoft 0:76dfa9657d9d 41 #define BLE_GLS_FEATURE_SAMPLE_SIZE 0x0004 /**< Sensor Sample Size Supported */
jksoft 0:76dfa9657d9d 42 #define BLE_GLS_FEATURE_INSERT_ERR 0x0008 /**< Sensor Strip Insertion Error Detection Supported */
jksoft 0:76dfa9657d9d 43 #define BLE_GLS_FEATURE_TYPE_ERR 0x0010 /**< Sensor Strip Type Error Detection Supported */
jksoft 0:76dfa9657d9d 44 #define BLE_GLS_FEATURE_RES_HIGH_LOW 0x0020 /**< Sensor Result High-Low Detection Supported */
jksoft 0:76dfa9657d9d 45 #define BLE_GLS_FEATURE_TEMP_HIGH_LOW 0x0040 /**< Sensor Temperature High-Low Detection Supported */
jksoft 0:76dfa9657d9d 46 #define BLE_GLS_FEATURE_READ_INT 0x0080 /**< Sensor Read Interrupt Detection Supported */
jksoft 0:76dfa9657d9d 47 #define BLE_GLS_FEATURE_GENERAL_FAULT 0x0100 /**< General Device Fault Supported */
jksoft 0:76dfa9657d9d 48 #define BLE_GLS_FEATURE_TIME_FAULT 0x0200 /**< Time Fault Supported */
jksoft 0:76dfa9657d9d 49 #define BLE_GLS_FEATURE_MULTI_BOND 0x0400 /**< Multiple Bond Supported */
jksoft 0:76dfa9657d9d 50
jksoft 0:76dfa9657d9d 51 /**@brief Glucose measurement flags */
jksoft 0:76dfa9657d9d 52 #define BLE_GLS_MEAS_FLAG_TIME_OFFSET 0x01 /**< Time Offset Present */
jksoft 0:76dfa9657d9d 53 #define BLE_GLS_MEAS_FLAG_CONC_TYPE_LOC 0x02 /**< Glucose Concentration, Type, and Sample Location Present */
jksoft 0:76dfa9657d9d 54 #define BLE_GLS_MEAS_FLAG_UNITS_KG_L 0x00 /**< Glucose Concentration Units kg/L */
jksoft 0:76dfa9657d9d 55 #define BLE_GLS_MEAS_FLAG_UNITS_MOL_L 0x04 /**< Glucose Concentration Units mol/L */
jksoft 0:76dfa9657d9d 56 #define BLE_GLS_MEAS_FLAG_SENSOR_STATUS 0x08 /**< Sensor Status Annunciation Present */
jksoft 0:76dfa9657d9d 57 #define BLE_GLS_MEAS_FLAG_CONTEXT_INFO 0x10 /**< Context Information Follows */
jksoft 0:76dfa9657d9d 58
jksoft 0:76dfa9657d9d 59 /**@brief Glucose measurement type */
jksoft 0:76dfa9657d9d 60 #define BLE_GLS_MEAS_TYPE_CAP_BLOOD 1 /**< Capillary whole blood */
jksoft 0:76dfa9657d9d 61 #define BLE_GLS_MEAS_TYPE_CAP_PLASMA 2 /**< Capillary plasma */
jksoft 0:76dfa9657d9d 62 #define BLE_GLS_MEAS_TYPE_VEN_BLOOD 3 /**< Venous whole blood */
jksoft 0:76dfa9657d9d 63 #define BLE_GLS_MEAS_TYPE_VEN_PLASMA 4 /**< Venous plasma */
jksoft 0:76dfa9657d9d 64 #define BLE_GLS_MEAS_TYPE_ART_BLOOD 5 /**< Arterial whole blood */
jksoft 0:76dfa9657d9d 65 #define BLE_GLS_MEAS_TYPE_ART_PLASMA 6 /**< Arterial plasma */
jksoft 0:76dfa9657d9d 66 #define BLE_GLS_MEAS_TYPE_UNDET_BLOOD 7 /**< Undetermined whole blood */
jksoft 0:76dfa9657d9d 67 #define BLE_GLS_MEAS_TYPE_UNDET_PLASMA 8 /**< Undetermined plasma */
jksoft 0:76dfa9657d9d 68 #define BLE_GLS_MEAS_TYPE_FLUID 9 /**< Interstitial fluid (ISF) */
jksoft 0:76dfa9657d9d 69 #define BLE_GLS_MEAS_TYPE_CONTROL 10 /**< Control solution */
jksoft 0:76dfa9657d9d 70
jksoft 0:76dfa9657d9d 71 /**@brief Glucose measurement location */
jksoft 0:76dfa9657d9d 72 #define BLE_GLS_MEAS_LOC_FINGER 1 /**< Finger */
jksoft 0:76dfa9657d9d 73 #define BLE_GLS_MEAS_LOC_AST 2 /**< Alternate Site Test (AST) */
jksoft 0:76dfa9657d9d 74 #define BLE_GLS_MEAS_LOC_EAR 3 /**< Earlobe */
jksoft 0:76dfa9657d9d 75 #define BLE_GLS_MEAS_LOC_CONTROL 4 /**< Control solution */
jksoft 0:76dfa9657d9d 76 #define BLE_GLS_MEAS_LOC_NOT_AVAIL 15 /**< Sample Location value not available */
jksoft 0:76dfa9657d9d 77
jksoft 0:76dfa9657d9d 78 /**@brief Glucose sensor status annunciation */
jksoft 0:76dfa9657d9d 79 #define BLE_GLS_MEAS_STATUS_BATT_LOW 0x0001 /**< Device battery low at time of measurement */
jksoft 0:76dfa9657d9d 80 #define BLE_GLS_MEAS_STATUS_SENSOR_FAULT 0x0002 /**< Sensor malfunction or faulting at time of measurement */
jksoft 0:76dfa9657d9d 81 #define BLE_GLS_MEAS_STATUS_SAMPLE_SIZE 0x0004 /**< Sample size for blood or control solution insufficient at time of measurement */
jksoft 0:76dfa9657d9d 82 #define BLE_GLS_MEAS_STATUS_STRIP_INSERT 0x0008 /**< Strip insertion error */
jksoft 0:76dfa9657d9d 83 #define BLE_GLS_MEAS_STATUS_STRIP_TYPE 0x0010 /**< Strip type incorrect for device */
jksoft 0:76dfa9657d9d 84 #define BLE_GLS_MEAS_STATUS_RESULT_HIGH 0x0020 /**< Sensor result higher than the device can process */
jksoft 0:76dfa9657d9d 85 #define BLE_GLS_MEAS_STATUS_RESULT_LOW 0x0040 /**< Sensor result lower than the device can process */
jksoft 0:76dfa9657d9d 86 #define BLE_GLS_MEAS_STATUS_TEMP_HIGH 0x0080 /**< Sensor temperature too high for valid test/result at time of measurement */
jksoft 0:76dfa9657d9d 87 #define BLE_GLS_MEAS_STATUS_TEMP_LOW 0x0100 /**< Sensor temperature too low for valid test/result at time of measurement */
jksoft 0:76dfa9657d9d 88 #define BLE_GLS_MEAS_STATUS_STRIP_PULL 0x0200 /**< Sensor read interrupted because strip was pulled too soon at time of measurement */
jksoft 0:76dfa9657d9d 89 #define BLE_GLS_MEAS_STATUS_GENERAL_FAULT 0x0400 /**< General device fault has occurred in the sensor */
jksoft 0:76dfa9657d9d 90 #define BLE_GLS_MEAS_STATUS_TIME_FAULT 0x0800 /**< Time fault has occurred in the sensor and time may be inaccurate */
jksoft 0:76dfa9657d9d 91
jksoft 0:76dfa9657d9d 92 /**@brief Glucose measurement context flags */
jksoft 0:76dfa9657d9d 93 #define BLE_GLS_CONTEXT_FLAG_CARB 0x01 /**< Carbohydrate id and carbohydrate present */
jksoft 0:76dfa9657d9d 94 #define BLE_GLS_CONTEXT_FLAG_MEAL 0x02 /**< Meal present */
jksoft 0:76dfa9657d9d 95 #define BLE_GLS_CONTEXT_FLAG_TESTER 0x04 /**< Tester-health present */
jksoft 0:76dfa9657d9d 96 #define BLE_GLS_CONTEXT_FLAG_EXERCISE 0x08 /**< Exercise duration and exercise intensity present */
jksoft 0:76dfa9657d9d 97 #define BLE_GLS_CONTEXT_FLAG_MED 0x10 /**< Medication ID and medication present */
jksoft 0:76dfa9657d9d 98 #define BLE_GLS_CONTEXT_FLAG_MED_KG 0x00 /**< Medication value units, kilograms */
jksoft 0:76dfa9657d9d 99 #define BLE_GLS_CONTEXT_FLAG_MED_L 0x20 /**< Medication value units, liters */
jksoft 0:76dfa9657d9d 100 #define BLE_GLS_CONTEXT_FLAG_HBA1C 0x40 /**< Hba1c present */
jksoft 0:76dfa9657d9d 101 #define BLE_GLS_CONTEXT_FLAG_EXT 0x80 /**< Extended flags present */
jksoft 0:76dfa9657d9d 102
jksoft 0:76dfa9657d9d 103 /**@brief Glucose measurement context carbohydrate ID */
jksoft 0:76dfa9657d9d 104 #define BLE_GLS_CONTEXT_CARB_BREAKFAST 1 /**< Breakfast */
jksoft 0:76dfa9657d9d 105 #define BLE_GLS_CONTEXT_CARB_LUNCH 2 /**< Lunch */
jksoft 0:76dfa9657d9d 106 #define BLE_GLS_CONTEXT_CARB_DINNER 3 /**< Dinner */
jksoft 0:76dfa9657d9d 107 #define BLE_GLS_CONTEXT_CARB_SNACK 4 /**< Snack */
jksoft 0:76dfa9657d9d 108 #define BLE_GLS_CONTEXT_CARB_DRINK 5 /**< Drink */
jksoft 0:76dfa9657d9d 109 #define BLE_GLS_CONTEXT_CARB_SUPPER 6 /**< Supper */
jksoft 0:76dfa9657d9d 110 #define BLE_GLS_CONTEXT_CARB_BRUNCH 7 /**< Brunch */
jksoft 0:76dfa9657d9d 111
jksoft 0:76dfa9657d9d 112 /**@brief Glucose measurement context meal */
jksoft 0:76dfa9657d9d 113 #define BLE_GLS_CONTEXT_MEAL_PREPRANDIAL 1 /**< Preprandial (before meal) */
jksoft 0:76dfa9657d9d 114 #define BLE_GLS_CONTEXT_MEAL_POSTPRANDIAL 2 /**< Postprandial (after meal) */
jksoft 0:76dfa9657d9d 115 #define BLE_GLS_CONTEXT_MEAL_FASTING 3 /**< Fasting */
jksoft 0:76dfa9657d9d 116 #define BLE_GLS_CONTEXT_MEAL_CASUAL 4 /**< Casual (snacks, drinks, etc.) */
jksoft 0:76dfa9657d9d 117 #define BLE_GLS_CONTEXT_MEAL_BEDTIME 5 /**< Bedtime */
jksoft 0:76dfa9657d9d 118
jksoft 0:76dfa9657d9d 119 /**@brief Glucose measurement context tester */
jksoft 0:76dfa9657d9d 120 #define BLE_GLS_CONTEXT_TESTER_SELF 1 /**< Self */
jksoft 0:76dfa9657d9d 121 #define BLE_GLS_CONTEXT_TESTER_PRO 2 /**< Health care professional */
jksoft 0:76dfa9657d9d 122 #define BLE_GLS_CONTEXT_TESTER_LAB 3 /**< Lab test */
jksoft 0:76dfa9657d9d 123 #define BLE_GLS_CONTEXT_TESTER_NOT_AVAIL 15 /**< Tester value not available */
jksoft 0:76dfa9657d9d 124
jksoft 0:76dfa9657d9d 125 /**@brief Glucose measurement context health */
jksoft 0:76dfa9657d9d 126 #define BLE_GLS_CONTEXT_HEALTH_MINOR 1 /**< Minor health issues */
jksoft 0:76dfa9657d9d 127 #define BLE_GLS_CONTEXT_HEALTH_MAJOR 2 /**< Major health issues */
jksoft 0:76dfa9657d9d 128 #define BLE_GLS_CONTEXT_HEALTH_MENSES 3 /**< During menses */
jksoft 0:76dfa9657d9d 129 #define BLE_GLS_CONTEXT_HEALTH_STRESS 4 /**< Under stress */
jksoft 0:76dfa9657d9d 130 #define BLE_GLS_CONTEXT_HEALTH_NONE 5 /**< No health issues */
jksoft 0:76dfa9657d9d 131 #define BLE_GLS_CONTEXT_HEALTH_NOT_AVAIL 15 /**< Health value not available */
jksoft 0:76dfa9657d9d 132
jksoft 0:76dfa9657d9d 133 /**@brief Glucose measurement context medication ID */
jksoft 0:76dfa9657d9d 134 #define BLE_GLS_CONTEXT_MED_RAPID 1 /**< Rapid acting insulin */
jksoft 0:76dfa9657d9d 135 #define BLE_GLS_CONTEXT_MED_SHORT 2 /**< Short acting insulin */
jksoft 0:76dfa9657d9d 136 #define BLE_GLS_CONTEXT_MED_INTERMED 3 /**< Intermediate acting insulin */
jksoft 0:76dfa9657d9d 137 #define BLE_GLS_CONTEXT_MED_LONG 4 /**< Long acting insulin */
jksoft 0:76dfa9657d9d 138 #define BLE_GLS_CONTEXT_MED_PREMIX 5 /**< Pre-mixed insulin */
jksoft 0:76dfa9657d9d 139
jksoft 0:76dfa9657d9d 140 /**@brief SFLOAT format (IEEE-11073 16-bit FLOAT, meaning 4 bits for exponent (base 10) and 12 bits mantissa) */
jksoft 0:76dfa9657d9d 141 typedef struct
jksoft 0:76dfa9657d9d 142 {
jksoft 0:76dfa9657d9d 143 int8_t exponent; /**< Base 10 exponent, should be using only 4 bits */
jksoft 0:76dfa9657d9d 144 int16_t mantissa; /**< Mantissa, should be using only 12 bits */
jksoft 0:76dfa9657d9d 145 } sfloat_t;
jksoft 0:76dfa9657d9d 146
jksoft 0:76dfa9657d9d 147 /**@brief Glucose Service event type. */
jksoft 0:76dfa9657d9d 148 typedef enum
jksoft 0:76dfa9657d9d 149 {
jksoft 0:76dfa9657d9d 150 BLE_GLS_EVT_NOTIFICATION_ENABLED, /**< Glucose value notification enabled event. */
jksoft 0:76dfa9657d9d 151 BLE_GLS_EVT_NOTIFICATION_DISABLED /**< Glucose value notification disabled event. */
jksoft 0:76dfa9657d9d 152 } ble_gls_evt_type_t;
jksoft 0:76dfa9657d9d 153
jksoft 0:76dfa9657d9d 154 /**@brief Glucose Service event. */
jksoft 0:76dfa9657d9d 155 typedef struct
jksoft 0:76dfa9657d9d 156 {
jksoft 0:76dfa9657d9d 157 ble_gls_evt_type_t evt_type; /**< Type of event. */
jksoft 0:76dfa9657d9d 158 } ble_gls_evt_t;
jksoft 0:76dfa9657d9d 159
jksoft 0:76dfa9657d9d 160 // Forward declaration of the ble_gls_t type.
jksoft 0:76dfa9657d9d 161 typedef struct ble_gls_s ble_gls_t;
jksoft 0:76dfa9657d9d 162
jksoft 0:76dfa9657d9d 163 /**@brief Glucose Service event handler type. */
jksoft 0:76dfa9657d9d 164 typedef void (*ble_gls_evt_handler_t) (ble_gls_t * p_gls, ble_gls_evt_t * p_evt);
jksoft 0:76dfa9657d9d 165
jksoft 0:76dfa9657d9d 166 /**@brief Glucose Measurement structure. This contains glucose measurement value. */
jksoft 0:76dfa9657d9d 167 typedef struct
jksoft 0:76dfa9657d9d 168 {
jksoft 0:76dfa9657d9d 169 uint8_t flags; /**< Flags */
jksoft 0:76dfa9657d9d 170 uint16_t sequence_number; /**< Sequence number */
jksoft 0:76dfa9657d9d 171 ble_date_time_t base_time; /**< Time stamp */
jksoft 0:76dfa9657d9d 172 int16_t time_offset; /**< Time offset */
jksoft 0:76dfa9657d9d 173 sfloat_t glucose_concentration; /**< Glucose concentration */
jksoft 0:76dfa9657d9d 174 uint8_t type; /**< Type */
jksoft 0:76dfa9657d9d 175 uint8_t sample_location; /**< Sample location */
jksoft 0:76dfa9657d9d 176 uint16_t sensor_status_annunciation; /**< Sensor status annunciation */
jksoft 0:76dfa9657d9d 177 } ble_gls_meas_t;
jksoft 0:76dfa9657d9d 178
jksoft 0:76dfa9657d9d 179 /**@brief Glucose measurement context structure */
jksoft 0:76dfa9657d9d 180 typedef struct
jksoft 0:76dfa9657d9d 181 {
jksoft 0:76dfa9657d9d 182 uint8_t flags; /**< Flags */
jksoft 0:76dfa9657d9d 183 uint8_t extended_flags; /**< Extended Flags */
jksoft 0:76dfa9657d9d 184 uint8_t carbohydrate_id; /**< Carbohydrate ID */
jksoft 0:76dfa9657d9d 185 sfloat_t carbohydrate; /**< Carbohydrate */
jksoft 0:76dfa9657d9d 186 uint8_t meal; /**< Meal */
jksoft 0:76dfa9657d9d 187 uint8_t tester_and_health; /**< Tester and health */
jksoft 0:76dfa9657d9d 188 uint16_t exercise_duration; /**< Exercise Duration */
jksoft 0:76dfa9657d9d 189 uint8_t exercise_intensity; /**< Exercise Intensity */
jksoft 0:76dfa9657d9d 190 uint8_t medication_id; /**< Medication ID */
jksoft 0:76dfa9657d9d 191 sfloat_t medication; /**< Medication */
jksoft 0:76dfa9657d9d 192 uint16_t hba1c; /**< HbA1c */
jksoft 0:76dfa9657d9d 193 } ble_gls_meas_context_t;
jksoft 0:76dfa9657d9d 194
jksoft 0:76dfa9657d9d 195 /**@brief Glucose measurement record */
jksoft 0:76dfa9657d9d 196 typedef struct
jksoft 0:76dfa9657d9d 197 {
jksoft 0:76dfa9657d9d 198 ble_gls_meas_t meas; /**< Glucose measurement */
jksoft 0:76dfa9657d9d 199 ble_gls_meas_context_t context; /**< Glucose measurement context */
jksoft 0:76dfa9657d9d 200 } ble_gls_rec_t;
jksoft 0:76dfa9657d9d 201
jksoft 0:76dfa9657d9d 202 /**@brief Glucose Service init structure. This contains all options and data needed for
jksoft 0:76dfa9657d9d 203 * initialization of the service. */
jksoft 0:76dfa9657d9d 204 typedef struct
jksoft 0:76dfa9657d9d 205 {
jksoft 0:76dfa9657d9d 206 ble_gls_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Glucose Service. */
jksoft 0:76dfa9657d9d 207 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
jksoft 0:76dfa9657d9d 208 uint16_t feature; /**< Glucose Feature value indicating supported features. */
jksoft 0:76dfa9657d9d 209 bool is_context_supported; /**< Determines if optional Glucose Measurement Context is to be supported. */
jksoft 0:76dfa9657d9d 210 } ble_gls_init_t;
jksoft 0:76dfa9657d9d 211
jksoft 0:76dfa9657d9d 212 /**@brief Glucose Service structure. This contains various status information for the service. */
jksoft 0:76dfa9657d9d 213 typedef struct ble_gls_s
jksoft 0:76dfa9657d9d 214 {
jksoft 0:76dfa9657d9d 215 ble_gls_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the Glucose Service. */
jksoft 0:76dfa9657d9d 216 ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */
jksoft 0:76dfa9657d9d 217 uint16_t service_handle; /**< Handle of Glucose Service (as provided by the BLE stack). */
jksoft 0:76dfa9657d9d 218 ble_gatts_char_handles_t glm_handles; /**< Handles related to the Glucose Measurement characteristic. */
jksoft 0:76dfa9657d9d 219 ble_gatts_char_handles_t glm_context_handles; /**< Handles related to the Glucose Measurement Context characteristic. */
jksoft 0:76dfa9657d9d 220 ble_gatts_char_handles_t glf_handles; /**< Handles related to the Glucose Feature characteristic. */
jksoft 0:76dfa9657d9d 221 ble_gatts_char_handles_t racp_handles; /**< Handles related to the Record Access Control Point characteristic. */
jksoft 0:76dfa9657d9d 222 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 0:76dfa9657d9d 223 uint16_t feature;
jksoft 0:76dfa9657d9d 224 bool is_context_supported;
jksoft 0:76dfa9657d9d 225 } ble_gls_t;
jksoft 0:76dfa9657d9d 226
jksoft 0:76dfa9657d9d 227 /**@brief Function for initializing the Glucose Service.
jksoft 0:76dfa9657d9d 228 *
jksoft 0:76dfa9657d9d 229 * @details This call allows the application to initialize the Glucose Service.
jksoft 0:76dfa9657d9d 230 *
jksoft 0:76dfa9657d9d 231 * @param[out] p_gls Glucose Service structure. This structure will have to be supplied by
jksoft 0:76dfa9657d9d 232 * the application. It will be initialized by this function, and will later
jksoft 0:76dfa9657d9d 233 * be used to identify this particular service instance.
jksoft 0:76dfa9657d9d 234 * @param[in] p_gls_init Information needed to initialize the service.
jksoft 0:76dfa9657d9d 235 *
jksoft 0:76dfa9657d9d 236 * @return NRF_SUCCESS on successful initialization of service, otherwise an error code.
jksoft 0:76dfa9657d9d 237 */
jksoft 0:76dfa9657d9d 238 uint32_t ble_gls_init(ble_gls_t * p_gls, const ble_gls_init_t * p_gls_init);
jksoft 0:76dfa9657d9d 239
jksoft 0:76dfa9657d9d 240 /**@brief Function for handling the Application's BLE Stack events.
jksoft 0:76dfa9657d9d 241 *
jksoft 0:76dfa9657d9d 242 * @details Handles all events from the BLE stack of interest to the Glucose Service.
jksoft 0:76dfa9657d9d 243 *
jksoft 0:76dfa9657d9d 244 * @param[in] p_gls Glucose Service structure.
jksoft 0:76dfa9657d9d 245 * @param[in] p_ble_evt Event received from the BLE stack.
jksoft 0:76dfa9657d9d 246 */
jksoft 0:76dfa9657d9d 247 void ble_gls_on_ble_evt(ble_gls_t * p_gls, ble_evt_t * p_ble_evt);
jksoft 0:76dfa9657d9d 248
jksoft 0:76dfa9657d9d 249 /**@brief Function for reporting a new glucose measurement to the glucose service module.
jksoft 0:76dfa9657d9d 250 *
jksoft 0:76dfa9657d9d 251 * @details The application calls this function after having performed a new glucose measurement.
jksoft 0:76dfa9657d9d 252 * The new measurement is recorded in the RACP database.
jksoft 0:76dfa9657d9d 253 *
jksoft 0:76dfa9657d9d 254 * @param[in] p_gls Glucose Service structure.
jksoft 0:76dfa9657d9d 255 * @param[in] p_rec Pointer to glucose record (measurement plus context).
jksoft 0:76dfa9657d9d 256 *
jksoft 0:76dfa9657d9d 257 * @return NRF_SUCCESS on success, otherwise an error code.
jksoft 0:76dfa9657d9d 258 */
jksoft 0:76dfa9657d9d 259 uint32_t ble_gls_glucose_new_meas(ble_gls_t * p_gls, ble_gls_rec_t * p_rec);
jksoft 0:76dfa9657d9d 260
jksoft 0:76dfa9657d9d 261 #endif // BLE_GLS_H__
jksoft 0:76dfa9657d9d 262
jksoft 0:76dfa9657d9d 263 /** @} */
jksoft 0:76dfa9657d9d 264
jksoft 0:76dfa9657d9d 265 /** @endcond */