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