Nicolas Borla / Mbed OS ROME2_Robot_Firmware
Committer:
boro
Date:
Mon Mar 16 13:12:31 2020 +0000
Revision:
0:4beb2ea291ec
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
boro 0:4beb2ea291ec 1 /* mbed Microcontroller Library
boro 0:4beb2ea291ec 2 * Copyright (c) 2006-2013 ARM Limited
boro 0:4beb2ea291ec 3 *
boro 0:4beb2ea291ec 4 * Licensed under the Apache License, Version 2.0 (the "License");
boro 0:4beb2ea291ec 5 * you may not use this file except in compliance with the License.
boro 0:4beb2ea291ec 6 * You may obtain a copy of the License at
boro 0:4beb2ea291ec 7 *
boro 0:4beb2ea291ec 8 * http://www.apache.org/licenses/LICENSE-2.0
boro 0:4beb2ea291ec 9 *
boro 0:4beb2ea291ec 10 * Unless required by applicable law or agreed to in writing, software
boro 0:4beb2ea291ec 11 * distributed under the License is distributed on an "AS IS" BASIS,
boro 0:4beb2ea291ec 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
boro 0:4beb2ea291ec 13 * See the License for the specific language governing permissions and
boro 0:4beb2ea291ec 14 * limitations under the License.
boro 0:4beb2ea291ec 15 */
boro 0:4beb2ea291ec 16
boro 0:4beb2ea291ec 17 #ifndef __GATT_CHARACTERISTIC_H__
boro 0:4beb2ea291ec 18 #define __GATT_CHARACTERISTIC_H__
boro 0:4beb2ea291ec 19
boro 0:4beb2ea291ec 20 #include "Gap.h"
boro 0:4beb2ea291ec 21 #include "SecurityManager.h"
boro 0:4beb2ea291ec 22 #include "GattAttribute.h"
boro 0:4beb2ea291ec 23 #include "GattCallbackParamTypes.h"
boro 0:4beb2ea291ec 24 #include "FunctionPointerWithContext.h"
boro 0:4beb2ea291ec 25
boro 0:4beb2ea291ec 26 /**
boro 0:4beb2ea291ec 27 * @addtogroup ble
boro 0:4beb2ea291ec 28 * @{
boro 0:4beb2ea291ec 29 * @addtogroup gatt
boro 0:4beb2ea291ec 30 * @{
boro 0:4beb2ea291ec 31 * @addtogroup server
boro 0:4beb2ea291ec 32 * @{
boro 0:4beb2ea291ec 33 */
boro 0:4beb2ea291ec 34
boro 0:4beb2ea291ec 35 /**
boro 0:4beb2ea291ec 36 * Representation of a GattServer characteristic.
boro 0:4beb2ea291ec 37 *
boro 0:4beb2ea291ec 38 * A characteristic is a typed value enclosed in a GATT service (GattService).
boro 0:4beb2ea291ec 39 *
boro 0:4beb2ea291ec 40 * @par Type
boro 0:4beb2ea291ec 41 *
boro 0:4beb2ea291ec 42 * The type of the value defines the purpose of the characteristic, and a
boro 0:4beb2ea291ec 43 * UUID represents it. Standard characteristic types may be consulted at
boro 0:4beb2ea291ec 44 * https://www.bluetooth.com/specifications/gatt/characteristics
boro 0:4beb2ea291ec 45 *
boro 0:4beb2ea291ec 46 * @par Supported operations
boro 0:4beb2ea291ec 47 * A set of properties define what client operations the characteristic
boro 0:4beb2ea291ec 48 * supports. See GattServer::Properties_t
boro 0:4beb2ea291ec 49 *
boro 0:4beb2ea291ec 50 * @par Descriptors
boro 0:4beb2ea291ec 51 *
boro 0:4beb2ea291ec 52 * Additional information, such as the unit of the characteristic value, a
boro 0:4beb2ea291ec 53 * description string or a client control point, can be added to the
boro 0:4beb2ea291ec 54 * characteristic.
boro 0:4beb2ea291ec 55 *
boro 0:4beb2ea291ec 56 * See BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] - 3.3.1.1
boro 0:4beb2ea291ec 57 *
boro 0:4beb2ea291ec 58 * One of the most important types of descriptor is the Client Characteristic
boro 0:4beb2ea291ec 59 * Configuration Descriptor (CCCD) that must be present if the characteristic
boro 0:4beb2ea291ec 60 * properties allow a client to subscribe to updates of the characteristic
boro 0:4beb2ea291ec 61 * value.
boro 0:4beb2ea291ec 62 *
boro 0:4beb2ea291ec 63 * @par Characteristic breakdown
boro 0:4beb2ea291ec 64 *
boro 0:4beb2ea291ec 65 * A characteristic is composed of several GATT attributes (GattAttribute):
boro 0:4beb2ea291ec 66 * - Characteristic declaration: It contains the properties of the
boro 0:4beb2ea291ec 67 * characteristic, its type and the handle of its value.
boro 0:4beb2ea291ec 68 * - Characteristic value: The value of the characteristic.
boro 0:4beb2ea291ec 69 * - Descriptors: A single GATT attribute stores each descriptor.
boro 0:4beb2ea291ec 70 *
boro 0:4beb2ea291ec 71 * When the GattService containing the characteristic is registered in the
boro 0:4beb2ea291ec 72 * GattServer, a unique attribute handle is assigned to the various attributes
boro 0:4beb2ea291ec 73 * of the characteristic. Clients use this handle to interact with the
boro 0:4beb2ea291ec 74 * characteristic. This handle is used locally in GattServer APIs.
boro 0:4beb2ea291ec 75 *
boro 0:4beb2ea291ec 76 *
boro 0:4beb2ea291ec 77 *
boro 0:4beb2ea291ec 78 *
boro 0:4beb2ea291ec 79 *
boro 0:4beb2ea291ec 80 *
boro 0:4beb2ea291ec 81 *
boro 0:4beb2ea291ec 82 *
boro 0:4beb2ea291ec 83 * Representation of a GattServer characteristic.
boro 0:4beb2ea291ec 84 *
boro 0:4beb2ea291ec 85 * A characteristic is a typed value used in a service. It contains a set of
boro 0:4beb2ea291ec 86 * properties that define client operations supported by the characteristic.
boro 0:4beb2ea291ec 87 * A characteristic may also include descriptors; a descriptor exposes
boro 0:4beb2ea291ec 88 * metainformation associated to a characteristic, such as the unit of its value,
boro 0:4beb2ea291ec 89 * its human readable name or a control point attribute that allows the client to
boro 0:4beb2ea291ec 90 * subscribe to the characteristic notifications.
boro 0:4beb2ea291ec 91 *
boro 0:4beb2ea291ec 92 * The GattCharacteristic class allows application code to construct
boro 0:4beb2ea291ec 93 * and monitor characteristics presents in a GattServer.
boro 0:4beb2ea291ec 94 */
boro 0:4beb2ea291ec 95 class GattCharacteristic {
boro 0:4beb2ea291ec 96 public:
boro 0:4beb2ea291ec 97
boro 0:4beb2ea291ec 98 /*
boro 0:4beb2ea291ec 99 * Enumeration of characteristic UUID defined by the Bluetooth body.
boro 0:4beb2ea291ec 100 */
boro 0:4beb2ea291ec 101 enum {
boro 0:4beb2ea291ec 102 /**
boro 0:4beb2ea291ec 103 * Not used in actual BLE service.
boro 0:4beb2ea291ec 104 */
boro 0:4beb2ea291ec 105 UUID_BATTERY_LEVEL_STATE_CHAR = 0x2A1B,
boro 0:4beb2ea291ec 106
boro 0:4beb2ea291ec 107 /**
boro 0:4beb2ea291ec 108 * Not used in actual BLE service.
boro 0:4beb2ea291ec 109 */
boro 0:4beb2ea291ec 110 UUID_BATTERY_POWER_STATE_CHAR = 0x2A1A,
boro 0:4beb2ea291ec 111
boro 0:4beb2ea291ec 112 /**
boro 0:4beb2ea291ec 113 * Not used in actual BLE service.
boro 0:4beb2ea291ec 114 */
boro 0:4beb2ea291ec 115 UUID_REMOVABLE_CHAR = 0x2A3A,
boro 0:4beb2ea291ec 116
boro 0:4beb2ea291ec 117 /**
boro 0:4beb2ea291ec 118 * Not used in actual BLE service.
boro 0:4beb2ea291ec 119 */
boro 0:4beb2ea291ec 120 UUID_SERVICE_REQUIRED_CHAR = 0x2A3B,
boro 0:4beb2ea291ec 121
boro 0:4beb2ea291ec 122 /**
boro 0:4beb2ea291ec 123 * Not used as a characteristic UUID.
boro 0:4beb2ea291ec 124 */
boro 0:4beb2ea291ec 125 UUID_ALERT_CATEGORY_ID_CHAR = 0x2A43,
boro 0:4beb2ea291ec 126
boro 0:4beb2ea291ec 127 /**
boro 0:4beb2ea291ec 128 * Not used as a characteristic UUID.
boro 0:4beb2ea291ec 129 */
boro 0:4beb2ea291ec 130 UUID_ALERT_CATEGORY_ID_BIT_MASK_CHAR = 0x2A42,
boro 0:4beb2ea291ec 131
boro 0:4beb2ea291ec 132 /**
boro 0:4beb2ea291ec 133 * Control point of the Immediate Alert service that allows the client to
boro 0:4beb2ea291ec 134 * command the server to alert to a given level.
boro 0:4beb2ea291ec 135 */
boro 0:4beb2ea291ec 136 UUID_ALERT_LEVEL_CHAR = 0x2A06,
boro 0:4beb2ea291ec 137
boro 0:4beb2ea291ec 138 /**
boro 0:4beb2ea291ec 139 * Control point of the Alert Notification service that allows the client
boro 0:4beb2ea291ec 140 * finely tune the notification configuration.
boro 0:4beb2ea291ec 141 */
boro 0:4beb2ea291ec 142 UUID_ALERT_NOTIFICATION_CONTROL_POINT_CHAR = 0x2A44,
boro 0:4beb2ea291ec 143
boro 0:4beb2ea291ec 144 /**
boro 0:4beb2ea291ec 145 * Part of the Alert Notification service, which exposes the count of
boro 0:4beb2ea291ec 146 * unread alert events existing in the server.
boro 0:4beb2ea291ec 147 */
boro 0:4beb2ea291ec 148 UUID_ALERT_STATUS_CHAR = 0x2A3F,
boro 0:4beb2ea291ec 149
boro 0:4beb2ea291ec 150 /**
boro 0:4beb2ea291ec 151 * Characteristic of the Battery service, which exposes the current
boro 0:4beb2ea291ec 152 * battery level as a percentage.
boro 0:4beb2ea291ec 153 */
boro 0:4beb2ea291ec 154 UUID_BATTERY_LEVEL_CHAR = 0x2A19,
boro 0:4beb2ea291ec 155
boro 0:4beb2ea291ec 156 /**
boro 0:4beb2ea291ec 157 * Describe the features supported by the blood pressure sensor exposed
boro 0:4beb2ea291ec 158 * by the Blood Pressure service.
boro 0:4beb2ea291ec 159 */
boro 0:4beb2ea291ec 160 UUID_BLOOD_PRESSURE_FEATURE_CHAR = 0x2A49,
boro 0:4beb2ea291ec 161
boro 0:4beb2ea291ec 162 /**
boro 0:4beb2ea291ec 163 * Characteristic of the Blood Pressure service that exposes the
boro 0:4beb2ea291ec 164 * measurement of the blood sensor.
boro 0:4beb2ea291ec 165 */
boro 0:4beb2ea291ec 166 UUID_BLOOD_PRESSURE_MEASUREMENT_CHAR = 0x2A35,
boro 0:4beb2ea291ec 167
boro 0:4beb2ea291ec 168 /**
boro 0:4beb2ea291ec 169 * Characteristic of the Heart Rate service that indicate the intended
boro 0:4beb2ea291ec 170 * location of the heart rate monitor.
boro 0:4beb2ea291ec 171 */
boro 0:4beb2ea291ec 172 UUID_BODY_SENSOR_LOCATION_CHAR = 0x2A38,
boro 0:4beb2ea291ec 173
boro 0:4beb2ea291ec 174 /**
boro 0:4beb2ea291ec 175 * Part of the Human Interface Device service.
boro 0:4beb2ea291ec 176 */
boro 0:4beb2ea291ec 177 UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR = 0x2A22,
boro 0:4beb2ea291ec 178
boro 0:4beb2ea291ec 179 /**
boro 0:4beb2ea291ec 180 * Part of the Human Interface Device service.
boro 0:4beb2ea291ec 181 */
boro 0:4beb2ea291ec 182 UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR = 0x2A32,
boro 0:4beb2ea291ec 183
boro 0:4beb2ea291ec 184 /**
boro 0:4beb2ea291ec 185 * Part of the Human Interface Device service.
boro 0:4beb2ea291ec 186 */
boro 0:4beb2ea291ec 187 UUID_BOOT_MOUSE_INPUT_REPORT_CHAR = 0x2A33,
boro 0:4beb2ea291ec 188
boro 0:4beb2ea291ec 189 /**
boro 0:4beb2ea291ec 190 * Characteristic of the Current Time service that contains the current
boro 0:4beb2ea291ec 191 * time.
boro 0:4beb2ea291ec 192 */
boro 0:4beb2ea291ec 193 UUID_CURRENT_TIME_CHAR = 0x2A2B,
boro 0:4beb2ea291ec 194
boro 0:4beb2ea291ec 195 /**
boro 0:4beb2ea291ec 196 * Not used in a service as a characteristic.
boro 0:4beb2ea291ec 197 */
boro 0:4beb2ea291ec 198 UUID_DATE_TIME_CHAR = 0x2A08,
boro 0:4beb2ea291ec 199
boro 0:4beb2ea291ec 200 /**
boro 0:4beb2ea291ec 201 * Not used in a service as a characteristic.
boro 0:4beb2ea291ec 202 */
boro 0:4beb2ea291ec 203 UUID_DAY_DATE_TIME_CHAR = 0x2A0A,
boro 0:4beb2ea291ec 204
boro 0:4beb2ea291ec 205 /**
boro 0:4beb2ea291ec 206 * Not used in a service as a characteristic.
boro 0:4beb2ea291ec 207 */
boro 0:4beb2ea291ec 208 UUID_DAY_OF_WEEK_CHAR = 0x2A09,
boro 0:4beb2ea291ec 209
boro 0:4beb2ea291ec 210 /**
boro 0:4beb2ea291ec 211 * Not used in a service as a characteristic.
boro 0:4beb2ea291ec 212 */
boro 0:4beb2ea291ec 213 UUID_DST_OFFSET_CHAR = 0x2A0D,
boro 0:4beb2ea291ec 214
boro 0:4beb2ea291ec 215 /**
boro 0:4beb2ea291ec 216 * Not used in a service as a characteristic.
boro 0:4beb2ea291ec 217 */
boro 0:4beb2ea291ec 218 UUID_EXACT_TIME_256_CHAR = 0x2A0C,
boro 0:4beb2ea291ec 219
boro 0:4beb2ea291ec 220 /**
boro 0:4beb2ea291ec 221 * Characteristic of the Device Information Service that contains a
boro 0:4beb2ea291ec 222 * UTF8 string representing the firmware revision for the firmware within
boro 0:4beb2ea291ec 223 * the device.
boro 0:4beb2ea291ec 224 */
boro 0:4beb2ea291ec 225 UUID_FIRMWARE_REVISION_STRING_CHAR = 0x2A26,
boro 0:4beb2ea291ec 226
boro 0:4beb2ea291ec 227 /**
boro 0:4beb2ea291ec 228 * Characteristic of the Glucose service that exposes features supported
boro 0:4beb2ea291ec 229 * by the server.
boro 0:4beb2ea291ec 230 */
boro 0:4beb2ea291ec 231 UUID_GLUCOSE_FEATURE_CHAR = 0x2A51,
boro 0:4beb2ea291ec 232
boro 0:4beb2ea291ec 233 /**
boro 0:4beb2ea291ec 234 * Characteristic of the Glucose service that exposes glucose
boro 0:4beb2ea291ec 235 * measurements.
boro 0:4beb2ea291ec 236 */
boro 0:4beb2ea291ec 237 UUID_GLUCOSE_MEASUREMENT_CHAR = 0x2A18,
boro 0:4beb2ea291ec 238
boro 0:4beb2ea291ec 239 /**
boro 0:4beb2ea291ec 240 * Characteristic of the Glucose service that sends additional
boro 0:4beb2ea291ec 241 * information related to the glucose measurements.
boro 0:4beb2ea291ec 242 */
boro 0:4beb2ea291ec 243 UUID_GLUCOSE_MEASUREMENT_CONTEXT_CHAR = 0x2A34,
boro 0:4beb2ea291ec 244
boro 0:4beb2ea291ec 245 /**
boro 0:4beb2ea291ec 246 * Characteristic of the Device Information Service that contains a
boro 0:4beb2ea291ec 247 * UTF8 string representing the hardware revision of the device.
boro 0:4beb2ea291ec 248 */
boro 0:4beb2ea291ec 249 UUID_HARDWARE_REVISION_STRING_CHAR = 0x2A27,
boro 0:4beb2ea291ec 250
boro 0:4beb2ea291ec 251 /**
boro 0:4beb2ea291ec 252 * Characteristic of the Heart Rate service used by the client to control
boro 0:4beb2ea291ec 253 * the service behavior.
boro 0:4beb2ea291ec 254 */
boro 0:4beb2ea291ec 255 UUID_HEART_RATE_CONTROL_POINT_CHAR = 0x2A39,
boro 0:4beb2ea291ec 256
boro 0:4beb2ea291ec 257 /**
boro 0:4beb2ea291ec 258 * Characteristic of the Heart Rate that sends heart rate measurements to
boro 0:4beb2ea291ec 259 * registered clients.
boro 0:4beb2ea291ec 260 */
boro 0:4beb2ea291ec 261 UUID_HEART_RATE_MEASUREMENT_CHAR = 0x2A37,
boro 0:4beb2ea291ec 262
boro 0:4beb2ea291ec 263 /**
boro 0:4beb2ea291ec 264 * Part of the Human Interface Device service.
boro 0:4beb2ea291ec 265 */
boro 0:4beb2ea291ec 266 UUID_HID_CONTROL_POINT_CHAR = 0x2A4C,
boro 0:4beb2ea291ec 267
boro 0:4beb2ea291ec 268 /**
boro 0:4beb2ea291ec 269 * Part of the Human Interface Device service.
boro 0:4beb2ea291ec 270 */
boro 0:4beb2ea291ec 271 UUID_HID_INFORMATION_CHAR = 0x2A4A,
boro 0:4beb2ea291ec 272
boro 0:4beb2ea291ec 273 /**
boro 0:4beb2ea291ec 274 * Characteristic of the Environmental Sensing service, which exposes
boro 0:4beb2ea291ec 275 * humidity measurements.
boro 0:4beb2ea291ec 276 */
boro 0:4beb2ea291ec 277 UUID_HUMIDITY_CHAR = 0x2A6F,
boro 0:4beb2ea291ec 278
boro 0:4beb2ea291ec 279 /**
boro 0:4beb2ea291ec 280 * Characteristic of the Device Information Service, which exposes
boro 0:4beb2ea291ec 281 * various regulatory or certification compliance items to which the
boro 0:4beb2ea291ec 282 * device claims adherence.
boro 0:4beb2ea291ec 283 */
boro 0:4beb2ea291ec 284 UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR = 0x2A2A,
boro 0:4beb2ea291ec 285
boro 0:4beb2ea291ec 286 /**
boro 0:4beb2ea291ec 287 * Characteristic of the Blood Pressure service, which exposes intermediate
boro 0:4beb2ea291ec 288 * cuff pressure measurements.
boro 0:4beb2ea291ec 289 */
boro 0:4beb2ea291ec 290 UUID_INTERMEDIATE_CUFF_PRESSURE_CHAR = 0x2A36,
boro 0:4beb2ea291ec 291
boro 0:4beb2ea291ec 292 /**
boro 0:4beb2ea291ec 293 * Characteristic of the Health Thermometer service that sends intermediate
boro 0:4beb2ea291ec 294 * temperature values while the measurement is in progress.
boro 0:4beb2ea291ec 295 */
boro 0:4beb2ea291ec 296 UUID_INTERMEDIATE_TEMPERATURE_CHAR = 0x2A1E,
boro 0:4beb2ea291ec 297
boro 0:4beb2ea291ec 298 /**
boro 0:4beb2ea291ec 299 * Characteristic of the current Time service that exposes information
boro 0:4beb2ea291ec 300 * about the local time.
boro 0:4beb2ea291ec 301 */
boro 0:4beb2ea291ec 302 UUID_LOCAL_TIME_INFORMATION_CHAR = 0x2A0F,
boro 0:4beb2ea291ec 303
boro 0:4beb2ea291ec 304 /**
boro 0:4beb2ea291ec 305 * Characteristic of the Device Information Service that contains a
boro 0:4beb2ea291ec 306 * UTF8 string representing the manufacturer name of the device.
boro 0:4beb2ea291ec 307 */
boro 0:4beb2ea291ec 308 UUID_MANUFACTURER_NAME_STRING_CHAR = 0x2A29,
boro 0:4beb2ea291ec 309
boro 0:4beb2ea291ec 310 /**
boro 0:4beb2ea291ec 311 * Characteristic of the Health Thermometer service that exposes the
boro 0:4beb2ea291ec 312 * interval time between two measurements.
boro 0:4beb2ea291ec 313 */
boro 0:4beb2ea291ec 314 UUID_MEASUREMENT_INTERVAL_CHAR = 0x2A21,
boro 0:4beb2ea291ec 315
boro 0:4beb2ea291ec 316 /**
boro 0:4beb2ea291ec 317 * Characteristic of the Device Information Service that contains a
boro 0:4beb2ea291ec 318 * UTF8 string representing the model number of the device assigned by
boro 0:4beb2ea291ec 319 * the vendor.
boro 0:4beb2ea291ec 320 */
boro 0:4beb2ea291ec 321 UUID_MODEL_NUMBER_STRING_CHAR = 0x2A24,
boro 0:4beb2ea291ec 322
boro 0:4beb2ea291ec 323 /**
boro 0:4beb2ea291ec 324 * Characteristic of the Alert Notification Service that shows how many
boro 0:4beb2ea291ec 325 * numbers of unread alerts exist in the specific category in the device.
boro 0:4beb2ea291ec 326 */
boro 0:4beb2ea291ec 327 UUID_UNREAD_ALERT_CHAR = 0x2A45,
boro 0:4beb2ea291ec 328
boro 0:4beb2ea291ec 329 /**
boro 0:4beb2ea291ec 330 * Characteristic of the Alert Notification Service that defines the
boro 0:4beb2ea291ec 331 * category of the alert and how many new alerts of that category have
boro 0:4beb2ea291ec 332 * occurred in the server.
boro 0:4beb2ea291ec 333 */
boro 0:4beb2ea291ec 334 UUID_NEW_ALERT_CHAR = 0x2A46,
boro 0:4beb2ea291ec 335
boro 0:4beb2ea291ec 336 /**
boro 0:4beb2ea291ec 337 * Characteristic of the Device Information Service; it is a set of
boro 0:4beb2ea291ec 338 * values used to create a device ID that is unique for this device.
boro 0:4beb2ea291ec 339 */
boro 0:4beb2ea291ec 340 UUID_PNP_ID_CHAR = 0x2A50,
boro 0:4beb2ea291ec 341
boro 0:4beb2ea291ec 342 /**
boro 0:4beb2ea291ec 343 * Characteristic of the Environmental Sensing Service that exposes the
boro 0:4beb2ea291ec 344 * pressure measured.
boro 0:4beb2ea291ec 345 */
boro 0:4beb2ea291ec 346 UUID_PRESSURE_CHAR = 0x2A6D,
boro 0:4beb2ea291ec 347
boro 0:4beb2ea291ec 348 /**
boro 0:4beb2ea291ec 349 * Part of the Human Interface Device service.
boro 0:4beb2ea291ec 350 */
boro 0:4beb2ea291ec 351 UUID_PROTOCOL_MODE_CHAR = 0x2A4E,
boro 0:4beb2ea291ec 352
boro 0:4beb2ea291ec 353 /**
boro 0:4beb2ea291ec 354 * Pulse Oxymeter, Glucose and Continuous Glucose Monitoring services
boro 0:4beb2ea291ec 355 * use this control point to provide basic management of the patient
boro 0:4beb2ea291ec 356 * record database.
boro 0:4beb2ea291ec 357 */
boro 0:4beb2ea291ec 358 UUID_RECORD_ACCESS_CONTROL_POINT_CHAR = 0x2A52,
boro 0:4beb2ea291ec 359
boro 0:4beb2ea291ec 360 /**
boro 0:4beb2ea291ec 361 * Characteristic of the Current Time service that exposes information
boro 0:4beb2ea291ec 362 * related to the current time served (accuracy, source, hours since
boro 0:4beb2ea291ec 363 * update and so on).
boro 0:4beb2ea291ec 364 */
boro 0:4beb2ea291ec 365 UUID_REFERENCE_TIME_INFORMATION_CHAR = 0x2A14,
boro 0:4beb2ea291ec 366
boro 0:4beb2ea291ec 367 /**
boro 0:4beb2ea291ec 368 * Part of the Human Interface Device service.
boro 0:4beb2ea291ec 369 */
boro 0:4beb2ea291ec 370 UUID_REPORT_CHAR = 0x2A4D,
boro 0:4beb2ea291ec 371
boro 0:4beb2ea291ec 372 /**
boro 0:4beb2ea291ec 373 * Part of the Human Interface Device service.
boro 0:4beb2ea291ec 374 */
boro 0:4beb2ea291ec 375 UUID_REPORT_MAP_CHAR = 0x2A4B,
boro 0:4beb2ea291ec 376
boro 0:4beb2ea291ec 377 /**
boro 0:4beb2ea291ec 378 * Characteristic of the Phone Alert Status service that allows a client
boro 0:4beb2ea291ec 379 * to configure operating mode.
boro 0:4beb2ea291ec 380 */
boro 0:4beb2ea291ec 381 UUID_RINGER_CONTROL_POINT_CHAR = 0x2A40,
boro 0:4beb2ea291ec 382
boro 0:4beb2ea291ec 383 /**
boro 0:4beb2ea291ec 384 * Characteristic of the Phone Alert Status service that returns the
boro 0:4beb2ea291ec 385 * ringer setting when read.
boro 0:4beb2ea291ec 386 */
boro 0:4beb2ea291ec 387 UUID_RINGER_SETTING_CHAR = 0x2A41,
boro 0:4beb2ea291ec 388
boro 0:4beb2ea291ec 389 /**
boro 0:4beb2ea291ec 390 * Characteristic of the Scan Parameter service that stores the client's
boro 0:4beb2ea291ec 391 * scan parameters (scan interval and scan window).
boro 0:4beb2ea291ec 392 */
boro 0:4beb2ea291ec 393 UUID_SCAN_INTERVAL_WINDOW_CHAR = 0x2A4F,
boro 0:4beb2ea291ec 394
boro 0:4beb2ea291ec 395 /**
boro 0:4beb2ea291ec 396 * Characteristic of the Scan Parameter service that sends a notification
boro 0:4beb2ea291ec 397 * to a client when the server requires its latest scan parameters.
boro 0:4beb2ea291ec 398 */
boro 0:4beb2ea291ec 399 UUID_SCAN_REFRESH_CHAR = 0x2A31,
boro 0:4beb2ea291ec 400
boro 0:4beb2ea291ec 401 /**
boro 0:4beb2ea291ec 402 * Characteristic of the Device Information Service that contains a
boro 0:4beb2ea291ec 403 * UTF8 string representing the serial number of the device.
boro 0:4beb2ea291ec 404 */
boro 0:4beb2ea291ec 405 UUID_SERIAL_NUMBER_STRING_CHAR = 0x2A25,
boro 0:4beb2ea291ec 406
boro 0:4beb2ea291ec 407 /**
boro 0:4beb2ea291ec 408 * Characteristic of the Device Information Service that contains an
boro 0:4beb2ea291ec 409 * UTF8 string representing the software revision of the device.
boro 0:4beb2ea291ec 410 */
boro 0:4beb2ea291ec 411 UUID_SOFTWARE_REVISION_STRING_CHAR = 0x2A28,
boro 0:4beb2ea291ec 412
boro 0:4beb2ea291ec 413 /**
boro 0:4beb2ea291ec 414 * Characteristic of the Alert Notification Service that notifies the
boro 0:4beb2ea291ec 415 * count of new alerts for a given category to a subscribed client.
boro 0:4beb2ea291ec 416 */
boro 0:4beb2ea291ec 417 UUID_SUPPORTED_NEW_ALERT_CATEGORY_CHAR = 0x2A47,
boro 0:4beb2ea291ec 418
boro 0:4beb2ea291ec 419 /**
boro 0:4beb2ea291ec 420 * Characteristic of the Alert Notification service, which exposes
boro 0:4beb2ea291ec 421 * categories of unread alert supported by the server.
boro 0:4beb2ea291ec 422 */
boro 0:4beb2ea291ec 423 UUID_SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR = 0x2A48,
boro 0:4beb2ea291ec 424
boro 0:4beb2ea291ec 425 /**
boro 0:4beb2ea291ec 426 * Characteristic of the Device Information Service that exposes a
boro 0:4beb2ea291ec 427 * structure containing an Organizationally Unique Identifier (OUI)
boro 0:4beb2ea291ec 428 * followed by a manufacturer-defined identifier. The value of the
boro 0:4beb2ea291ec 429 * structure is unique for each individual instance of the product.
boro 0:4beb2ea291ec 430 */
boro 0:4beb2ea291ec 431 UUID_SYSTEM_ID_CHAR = 0x2A23,
boro 0:4beb2ea291ec 432
boro 0:4beb2ea291ec 433 /**
boro 0:4beb2ea291ec 434 * Characteristic of the Environmental Sensing service that exposes the
boro 0:4beb2ea291ec 435 * temperature measurement with a resolution of 0.01 degree Celsius.
boro 0:4beb2ea291ec 436 */
boro 0:4beb2ea291ec 437 UUID_TEMPERATURE_CHAR = 0x2A6E,
boro 0:4beb2ea291ec 438
boro 0:4beb2ea291ec 439 /**
boro 0:4beb2ea291ec 440 * Characteristic of the Health Thermometer service that sends temperature
boro 0:4beb2ea291ec 441 * measurement to clients.
boro 0:4beb2ea291ec 442 */
boro 0:4beb2ea291ec 443 UUID_TEMPERATURE_MEASUREMENT_CHAR = 0x2A1C,
boro 0:4beb2ea291ec 444
boro 0:4beb2ea291ec 445 /**
boro 0:4beb2ea291ec 446 * Characteristic of the Health Thermometer service that describes
boro 0:4beb2ea291ec 447 * where the measurement takes place.
boro 0:4beb2ea291ec 448 */
boro 0:4beb2ea291ec 449 UUID_TEMPERATURE_TYPE_CHAR = 0x2A1D,
boro 0:4beb2ea291ec 450
boro 0:4beb2ea291ec 451 /**
boro 0:4beb2ea291ec 452 * Not used in a service as a characteristic.
boro 0:4beb2ea291ec 453 */
boro 0:4beb2ea291ec 454 UUID_TIME_ACCURACY_CHAR = 0x2A12,
boro 0:4beb2ea291ec 455
boro 0:4beb2ea291ec 456 /**
boro 0:4beb2ea291ec 457 * Not used in a service as a characteristic.
boro 0:4beb2ea291ec 458 */
boro 0:4beb2ea291ec 459 UUID_TIME_SOURCE_CHAR = 0x2A13,
boro 0:4beb2ea291ec 460
boro 0:4beb2ea291ec 461 /**
boro 0:4beb2ea291ec 462 * Characteristic of the Reference Time service that allows clients to
boro 0:4beb2ea291ec 463 * control time update.
boro 0:4beb2ea291ec 464 */
boro 0:4beb2ea291ec 465 UUID_TIME_UPDATE_CONTROL_POINT_CHAR = 0x2A16,
boro 0:4beb2ea291ec 466
boro 0:4beb2ea291ec 467 /**
boro 0:4beb2ea291ec 468 * Characteristic of the Reference Time service that informs clients of
boro 0:4beb2ea291ec 469 * the status of the time update operation.
boro 0:4beb2ea291ec 470 */
boro 0:4beb2ea291ec 471 UUID_TIME_UPDATE_STATE_CHAR = 0x2A17,
boro 0:4beb2ea291ec 472
boro 0:4beb2ea291ec 473 /**
boro 0:4beb2ea291ec 474 * Characteristic of the Next DST Change service that returns to clients
boro 0:4beb2ea291ec 475 * the time with DST.
boro 0:4beb2ea291ec 476 */
boro 0:4beb2ea291ec 477 UUID_TIME_WITH_DST_CHAR = 0x2A11,
boro 0:4beb2ea291ec 478
boro 0:4beb2ea291ec 479 /**
boro 0:4beb2ea291ec 480 * Not used in a service as a characteristic.
boro 0:4beb2ea291ec 481 */
boro 0:4beb2ea291ec 482 UUID_TIME_ZONE_CHAR = 0x2A0E,
boro 0:4beb2ea291ec 483
boro 0:4beb2ea291ec 484 /**
boro 0:4beb2ea291ec 485 * Characteristic of the TX Power service that exposes the current
boro 0:4beb2ea291ec 486 * transmission power in dBm.
boro 0:4beb2ea291ec 487 */
boro 0:4beb2ea291ec 488 UUID_TX_POWER_LEVEL_CHAR = 0x2A07,
boro 0:4beb2ea291ec 489
boro 0:4beb2ea291ec 490 /**
boro 0:4beb2ea291ec 491 * Characteristic of the Cycling Speed and Cadence (CSC) service that
boro 0:4beb2ea291ec 492 * exposes features supported by the server.
boro 0:4beb2ea291ec 493 */
boro 0:4beb2ea291ec 494 UUID_CSC_FEATURE_CHAR = 0x2A5C,
boro 0:4beb2ea291ec 495
boro 0:4beb2ea291ec 496 /**
boro 0:4beb2ea291ec 497 * Characteristic of the Cycling Speed and Cadence (CSC) service that
boro 0:4beb2ea291ec 498 * exposes measurements made by the server.
boro 0:4beb2ea291ec 499 */
boro 0:4beb2ea291ec 500 UUID_CSC_MEASUREMENT_CHAR = 0x2A5B,
boro 0:4beb2ea291ec 501
boro 0:4beb2ea291ec 502 /**
boro 0:4beb2ea291ec 503 * Characteristic of the Running Speed and Cadence (RSC) service that
boro 0:4beb2ea291ec 504 * exposes features supported by the server.
boro 0:4beb2ea291ec 505 */
boro 0:4beb2ea291ec 506 UUID_RSC_FEATURE_CHAR = 0x2A54,
boro 0:4beb2ea291ec 507
boro 0:4beb2ea291ec 508 /**
boro 0:4beb2ea291ec 509 * Characteristic of the Running Speed and Cadence (RSC) service that
boro 0:4beb2ea291ec 510 * exposes measurements made by the server.
boro 0:4beb2ea291ec 511 */
boro 0:4beb2ea291ec 512 UUID_RSC_MEASUREMENT_CHAR = 0x2A53
boro 0:4beb2ea291ec 513 };
boro 0:4beb2ea291ec 514
boro 0:4beb2ea291ec 515 /**
boro 0:4beb2ea291ec 516 * Unit type of a characteristic value.
boro 0:4beb2ea291ec 517 *
boro 0:4beb2ea291ec 518 * These unit types are used to describe what the raw numeric data in a
boro 0:4beb2ea291ec 519 * characteristic actually represents. A server can expose that information
boro 0:4beb2ea291ec 520 * to its clients by adding a Characteristic Presentation Format descriptor
boro 0:4beb2ea291ec 521 * to relevant characteristics.
boro 0:4beb2ea291ec 522 *
boro 0:4beb2ea291ec 523 * @note See https://developer.bluetooth.org/gatt/units/Pages/default.aspx
boro 0:4beb2ea291ec 524 */
boro 0:4beb2ea291ec 525 enum {
boro 0:4beb2ea291ec 526
boro 0:4beb2ea291ec 527 /**
boro 0:4beb2ea291ec 528 * No specified unit type.
boro 0:4beb2ea291ec 529 */
boro 0:4beb2ea291ec 530 BLE_GATT_UNIT_NONE = 0x2700,
boro 0:4beb2ea291ec 531
boro 0:4beb2ea291ec 532 /**
boro 0:4beb2ea291ec 533 * Length, meter.
boro 0:4beb2ea291ec 534 */
boro 0:4beb2ea291ec 535 BLE_GATT_UNIT_LENGTH_METRE = 0x2701,
boro 0:4beb2ea291ec 536
boro 0:4beb2ea291ec 537 /**
boro 0:4beb2ea291ec 538 * Mass, kilogram.
boro 0:4beb2ea291ec 539 */
boro 0:4beb2ea291ec 540 BLE_GATT_UNIT_MASS_KILOGRAM = 0x2702,
boro 0:4beb2ea291ec 541
boro 0:4beb2ea291ec 542 /**
boro 0:4beb2ea291ec 543 * Time, second.
boro 0:4beb2ea291ec 544 */
boro 0:4beb2ea291ec 545 BLE_GATT_UNIT_TIME_SECOND = 0x2703,
boro 0:4beb2ea291ec 546
boro 0:4beb2ea291ec 547 /**
boro 0:4beb2ea291ec 548 * Electric current, ampere.
boro 0:4beb2ea291ec 549 */
boro 0:4beb2ea291ec 550 BLE_GATT_UNIT_ELECTRIC_CURRENT_AMPERE = 0x2704,
boro 0:4beb2ea291ec 551
boro 0:4beb2ea291ec 552 /**
boro 0:4beb2ea291ec 553 * Thermodynamic temperature, kelvin.
boro 0:4beb2ea291ec 554 */
boro 0:4beb2ea291ec 555 BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_KELVIN = 0x2705,
boro 0:4beb2ea291ec 556
boro 0:4beb2ea291ec 557 /** Amount of substance, mole.
boro 0:4beb2ea291ec 558 *
boro 0:4beb2ea291ec 559 */
boro 0:4beb2ea291ec 560 BLE_GATT_UNIT_AMOUNT_OF_SUBSTANCE_MOLE = 0x2706,
boro 0:4beb2ea291ec 561
boro 0:4beb2ea291ec 562 /**
boro 0:4beb2ea291ec 563 * Luminous intensity, candela.
boro 0:4beb2ea291ec 564 */
boro 0:4beb2ea291ec 565 BLE_GATT_UNIT_LUMINOUS_INTENSITY_CANDELA = 0x2707,
boro 0:4beb2ea291ec 566
boro 0:4beb2ea291ec 567 /**
boro 0:4beb2ea291ec 568 * Area, square meters.
boro 0:4beb2ea291ec 569 */
boro 0:4beb2ea291ec 570 BLE_GATT_UNIT_AREA_SQUARE_METRES = 0x2710,
boro 0:4beb2ea291ec 571
boro 0:4beb2ea291ec 572 /**
boro 0:4beb2ea291ec 573 * Volume, cubic meters.
boro 0:4beb2ea291ec 574 */
boro 0:4beb2ea291ec 575 BLE_GATT_UNIT_VOLUME_CUBIC_METRES = 0x2711,
boro 0:4beb2ea291ec 576
boro 0:4beb2ea291ec 577 /**
boro 0:4beb2ea291ec 578 * Velocity, meters per second.
boro 0:4beb2ea291ec 579 */
boro 0:4beb2ea291ec 580 BLE_GATT_UNIT_VELOCITY_METRES_PER_SECOND = 0x2712,
boro 0:4beb2ea291ec 581
boro 0:4beb2ea291ec 582 /**
boro 0:4beb2ea291ec 583 * Acceleration, meters per second squared.
boro 0:4beb2ea291ec 584 */
boro 0:4beb2ea291ec 585 BLE_GATT_UNIT_ACCELERATION_METRES_PER_SECOND_SQUARED = 0x2713,
boro 0:4beb2ea291ec 586
boro 0:4beb2ea291ec 587 /**
boro 0:4beb2ea291ec 588 * Wave number reciprocal, meter.
boro 0:4beb2ea291ec 589 */
boro 0:4beb2ea291ec 590 BLE_GATT_UNIT_WAVENUMBER_RECIPROCAL_METRE = 0x2714,
boro 0:4beb2ea291ec 591
boro 0:4beb2ea291ec 592 /**
boro 0:4beb2ea291ec 593 * Density, kilogram per cubic meter.
boro 0:4beb2ea291ec 594 */
boro 0:4beb2ea291ec 595 BLE_GATT_UNIT_DENSITY_KILOGRAM_PER_CUBIC_METRE = 0x2715,
boro 0:4beb2ea291ec 596
boro 0:4beb2ea291ec 597 /**
boro 0:4beb2ea291ec 598 * Surface density (kilogram per square meter).
boro 0:4beb2ea291ec 599 */
boro 0:4beb2ea291ec 600 BLE_GATT_UNIT_SURFACE_DENSITY_KILOGRAM_PER_SQUARE_METRE = 0x2716,
boro 0:4beb2ea291ec 601
boro 0:4beb2ea291ec 602 /**
boro 0:4beb2ea291ec 603 * Specific volume (cubic meter per kilogram).
boro 0:4beb2ea291ec 604 */
boro 0:4beb2ea291ec 605 BLE_GATT_UNIT_SPECIFIC_VOLUME_CUBIC_METRE_PER_KILOGRAM = 0x2717,
boro 0:4beb2ea291ec 606
boro 0:4beb2ea291ec 607 /**
boro 0:4beb2ea291ec 608 * Current density (ampere per square meter).
boro 0:4beb2ea291ec 609 */
boro 0:4beb2ea291ec 610 BLE_GATT_UNIT_CURRENT_DENSITY_AMPERE_PER_SQUARE_METRE = 0x2718,
boro 0:4beb2ea291ec 611
boro 0:4beb2ea291ec 612 /**
boro 0:4beb2ea291ec 613 * Magnetic field strength, ampere per meter.
boro 0:4beb2ea291ec 614 */
boro 0:4beb2ea291ec 615 BLE_GATT_UNIT_MAGNETIC_FIELD_STRENGTH_AMPERE_PER_METRE = 0x2719,
boro 0:4beb2ea291ec 616
boro 0:4beb2ea291ec 617 /**
boro 0:4beb2ea291ec 618 * Amount concentration (mole per cubic meter).
boro 0:4beb2ea291ec 619 */
boro 0:4beb2ea291ec 620 BLE_GATT_UNIT_AMOUNT_CONCENTRATION_MOLE_PER_CUBIC_METRE = 0x271A,
boro 0:4beb2ea291ec 621
boro 0:4beb2ea291ec 622 /**
boro 0:4beb2ea291ec 623 * Mass concentration (kilogram per cubic meter).
boro 0:4beb2ea291ec 624 */
boro 0:4beb2ea291ec 625 BLE_GATT_UNIT_MASS_CONCENTRATION_KILOGRAM_PER_CUBIC_METRE = 0x271B,
boro 0:4beb2ea291ec 626
boro 0:4beb2ea291ec 627 /**
boro 0:4beb2ea291ec 628 * Luminance (candela per square meter).
boro 0:4beb2ea291ec 629 */
boro 0:4beb2ea291ec 630 BLE_GATT_UNIT_LUMINANCE_CANDELA_PER_SQUARE_METRE = 0x271C,
boro 0:4beb2ea291ec 631
boro 0:4beb2ea291ec 632 /**
boro 0:4beb2ea291ec 633 * Refractive index.
boro 0:4beb2ea291ec 634 */
boro 0:4beb2ea291ec 635 BLE_GATT_UNIT_REFRACTIVE_INDEX = 0x271D,
boro 0:4beb2ea291ec 636
boro 0:4beb2ea291ec 637 /**
boro 0:4beb2ea291ec 638 * Relative permeability.
boro 0:4beb2ea291ec 639 */
boro 0:4beb2ea291ec 640 BLE_GATT_UNIT_RELATIVE_PERMEABILITY = 0x271E,
boro 0:4beb2ea291ec 641
boro 0:4beb2ea291ec 642 /**
boro 0:4beb2ea291ec 643 * Plane angle (radian).
boro 0:4beb2ea291ec 644 */
boro 0:4beb2ea291ec 645 BLE_GATT_UNIT_PLANE_ANGLE_RADIAN = 0x2720,
boro 0:4beb2ea291ec 646
boro 0:4beb2ea291ec 647 /**
boro 0:4beb2ea291ec 648 * Solid angle (steradian).
boro 0:4beb2ea291ec 649 */
boro 0:4beb2ea291ec 650 BLE_GATT_UNIT_SOLID_ANGLE_STERADIAN = 0x2721,
boro 0:4beb2ea291ec 651
boro 0:4beb2ea291ec 652 /**
boro 0:4beb2ea291ec 653 * Frequency, hertz.
boro 0:4beb2ea291ec 654 */
boro 0:4beb2ea291ec 655 BLE_GATT_UNIT_FREQUENCY_HERTZ = 0x2722,
boro 0:4beb2ea291ec 656
boro 0:4beb2ea291ec 657 /**
boro 0:4beb2ea291ec 658 * Force, newton.
boro 0:4beb2ea291ec 659 */
boro 0:4beb2ea291ec 660 BLE_GATT_UNIT_FORCE_NEWTON = 0x2723,
boro 0:4beb2ea291ec 661
boro 0:4beb2ea291ec 662 /**
boro 0:4beb2ea291ec 663 * Pressure, pascal.
boro 0:4beb2ea291ec 664 */
boro 0:4beb2ea291ec 665 BLE_GATT_UNIT_PRESSURE_PASCAL = 0x2724,
boro 0:4beb2ea291ec 666
boro 0:4beb2ea291ec 667 /**
boro 0:4beb2ea291ec 668 * Energy, joule.
boro 0:4beb2ea291ec 669 */
boro 0:4beb2ea291ec 670 BLE_GATT_UNIT_ENERGY_JOULE = 0x2725,
boro 0:4beb2ea291ec 671
boro 0:4beb2ea291ec 672 /**
boro 0:4beb2ea291ec 673 * Power, watt.
boro 0:4beb2ea291ec 674 */
boro 0:4beb2ea291ec 675 BLE_GATT_UNIT_POWER_WATT = 0x2726,
boro 0:4beb2ea291ec 676
boro 0:4beb2ea291ec 677 /**
boro 0:4beb2ea291ec 678 * Electrical charge, coulomb.
boro 0:4beb2ea291ec 679 */
boro 0:4beb2ea291ec 680 BLE_GATT_UNIT_ELECTRIC_CHARGE_COULOMB = 0x2727,
boro 0:4beb2ea291ec 681
boro 0:4beb2ea291ec 682 /**
boro 0:4beb2ea291ec 683 * Electrical potential difference, voltage.
boro 0:4beb2ea291ec 684 */
boro 0:4beb2ea291ec 685 BLE_GATT_UNIT_ELECTRIC_POTENTIAL_DIFFERENCE_VOLT = 0x2728,
boro 0:4beb2ea291ec 686
boro 0:4beb2ea291ec 687 /**
boro 0:4beb2ea291ec 688 * Capacitance, farad.
boro 0:4beb2ea291ec 689 */
boro 0:4beb2ea291ec 690 BLE_GATT_UNIT_CAPACITANCE_FARAD = 0x2729,
boro 0:4beb2ea291ec 691
boro 0:4beb2ea291ec 692 /**
boro 0:4beb2ea291ec 693 * Electric resistance, ohm.
boro 0:4beb2ea291ec 694 */
boro 0:4beb2ea291ec 695 BLE_GATT_UNIT_ELECTRIC_RESISTANCE_OHM = 0x272A,
boro 0:4beb2ea291ec 696
boro 0:4beb2ea291ec 697 /**
boro 0:4beb2ea291ec 698 * Electric conductance, siemens.
boro 0:4beb2ea291ec 699 */
boro 0:4beb2ea291ec 700 BLE_GATT_UNIT_ELECTRIC_CONDUCTANCE_SIEMENS = 0x272B,
boro 0:4beb2ea291ec 701
boro 0:4beb2ea291ec 702 /**
boro 0:4beb2ea291ec 703 * Magnetic flux, weber.
boro 0:4beb2ea291ec 704 */
boro 0:4beb2ea291ec 705 BLE_GATT_UNIT_MAGNETIC_FLEX_WEBER = 0x272C,
boro 0:4beb2ea291ec 706
boro 0:4beb2ea291ec 707 /**
boro 0:4beb2ea291ec 708 * Magnetic flux density, tesla.
boro 0:4beb2ea291ec 709 */
boro 0:4beb2ea291ec 710 BLE_GATT_UNIT_MAGNETIC_FLEX_DENSITY_TESLA = 0x272D,
boro 0:4beb2ea291ec 711
boro 0:4beb2ea291ec 712 /**
boro 0:4beb2ea291ec 713 * Inductance, henry.
boro 0:4beb2ea291ec 714 */
boro 0:4beb2ea291ec 715 BLE_GATT_UNIT_INDUCTANCE_HENRY = 0x272E,
boro 0:4beb2ea291ec 716
boro 0:4beb2ea291ec 717 /**
boro 0:4beb2ea291ec 718 * Celsius temperature, degree Celsius.
boro 0:4beb2ea291ec 719 */
boro 0:4beb2ea291ec 720 BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_CELSIUS = 0x272F,
boro 0:4beb2ea291ec 721
boro 0:4beb2ea291ec 722 /**
boro 0:4beb2ea291ec 723 * Luminous flux, lumen.
boro 0:4beb2ea291ec 724 */
boro 0:4beb2ea291ec 725 BLE_GATT_UNIT_LUMINOUS_FLUX_LUMEN = 0x2730,
boro 0:4beb2ea291ec 726
boro 0:4beb2ea291ec 727 /**
boro 0:4beb2ea291ec 728 * Illuminance, lux.
boro 0:4beb2ea291ec 729 */
boro 0:4beb2ea291ec 730 BLE_GATT_UNIT_ILLUMINANCE_LUX = 0x2731,
boro 0:4beb2ea291ec 731
boro 0:4beb2ea291ec 732 /**
boro 0:4beb2ea291ec 733 * Activity referred to a radionuclide, becquerel.
boro 0:4beb2ea291ec 734 */
boro 0:4beb2ea291ec 735 BLE_GATT_UNIT_ACTIVITY_REFERRED_TO_A_RADIONUCLIDE_BECQUEREL = 0x2732,
boro 0:4beb2ea291ec 736
boro 0:4beb2ea291ec 737 /**
boro 0:4beb2ea291ec 738 * Absorbed dose, gray.
boro 0:4beb2ea291ec 739 */
boro 0:4beb2ea291ec 740 BLE_GATT_UNIT_ABSORBED_DOSE_GRAY = 0x2733,
boro 0:4beb2ea291ec 741
boro 0:4beb2ea291ec 742 /**
boro 0:4beb2ea291ec 743 * Dose equivalent, sievert.
boro 0:4beb2ea291ec 744 */
boro 0:4beb2ea291ec 745 BLE_GATT_UNIT_DOSE_EQUIVALENT_SIEVERT = 0x2734,
boro 0:4beb2ea291ec 746
boro 0:4beb2ea291ec 747 /**
boro 0:4beb2ea291ec 748 * Catalytic activity, katal.
boro 0:4beb2ea291ec 749 */
boro 0:4beb2ea291ec 750 BLE_GATT_UNIT_CATALYTIC_ACTIVITY_KATAL = 0x2735,
boro 0:4beb2ea291ec 751
boro 0:4beb2ea291ec 752 /**
boro 0:4beb2ea291ec 753 * Dynamic viscosity, pascal second.
boro 0:4beb2ea291ec 754 */
boro 0:4beb2ea291ec 755 BLE_GATT_UNIT_DYNAMIC_VISCOSITY_PASCAL_SECOND = 0x2740,
boro 0:4beb2ea291ec 756
boro 0:4beb2ea291ec 757 /**
boro 0:4beb2ea291ec 758 * Moment of force, newton meter.
boro 0:4beb2ea291ec 759 */
boro 0:4beb2ea291ec 760 BLE_GATT_UNIT_MOMENT_OF_FORCE_NEWTON_METRE = 0x2741,
boro 0:4beb2ea291ec 761
boro 0:4beb2ea291ec 762 /**
boro 0:4beb2ea291ec 763 * Surface tension, newton per meter.
boro 0:4beb2ea291ec 764 */
boro 0:4beb2ea291ec 765 BLE_GATT_UNIT_SURFACE_TENSION_NEWTON_PER_METRE = 0x2742,
boro 0:4beb2ea291ec 766
boro 0:4beb2ea291ec 767 /**
boro 0:4beb2ea291ec 768 * Angular velocity, radian per second.
boro 0:4beb2ea291ec 769 */
boro 0:4beb2ea291ec 770 BLE_GATT_UNIT_ANGULAR_VELOCITY_RADIAN_PER_SECOND = 0x2743,
boro 0:4beb2ea291ec 771
boro 0:4beb2ea291ec 772 /**
boro 0:4beb2ea291ec 773 * Angular acceleration, radian per second squared.
boro 0:4beb2ea291ec 774 */
boro 0:4beb2ea291ec 775 BLE_GATT_UNIT_ANGULAR_ACCELERATION_RADIAN_PER_SECOND_SQUARED = 0x2744,
boro 0:4beb2ea291ec 776
boro 0:4beb2ea291ec 777 /**
boro 0:4beb2ea291ec 778 * Heat flux density, watt per square meter.
boro 0:4beb2ea291ec 779 */
boro 0:4beb2ea291ec 780 BLE_GATT_UNIT_HEAT_FLUX_DENSITY_WATT_PER_SQUARE_METRE = 0x2745,
boro 0:4beb2ea291ec 781
boro 0:4beb2ea291ec 782 /**
boro 0:4beb2ea291ec 783 * Heat capacity, joule per kelvin.
boro 0:4beb2ea291ec 784 */
boro 0:4beb2ea291ec 785 BLE_GATT_UNIT_HEAT_CAPACITY_JOULE_PER_KELVIN = 0x2746,
boro 0:4beb2ea291ec 786
boro 0:4beb2ea291ec 787 /**
boro 0:4beb2ea291ec 788 * Specific heat capacity, joule per kilogram kelvin.
boro 0:4beb2ea291ec 789 */
boro 0:4beb2ea291ec 790 BLE_GATT_UNIT_SPECIFIC_HEAT_CAPACITY_JOULE_PER_KILOGRAM_KELVIN = 0x2747,
boro 0:4beb2ea291ec 791
boro 0:4beb2ea291ec 792 /**
boro 0:4beb2ea291ec 793 * Specific energy, joule per kilogram.
boro 0:4beb2ea291ec 794 */
boro 0:4beb2ea291ec 795 BLE_GATT_UNIT_SPECIFIC_ENERGY_JOULE_PER_KILOGRAM = 0x2748,
boro 0:4beb2ea291ec 796
boro 0:4beb2ea291ec 797 /**
boro 0:4beb2ea291ec 798 * Thermal conductivity, watt per meter kelvin.
boro 0:4beb2ea291ec 799 */
boro 0:4beb2ea291ec 800 BLE_GATT_UNIT_THERMAL_CONDUCTIVITY_WATT_PER_METRE_KELVIN = 0x2749,
boro 0:4beb2ea291ec 801
boro 0:4beb2ea291ec 802 /**
boro 0:4beb2ea291ec 803 * Energy density, joule per cubic meter.
boro 0:4beb2ea291ec 804 */
boro 0:4beb2ea291ec 805 BLE_GATT_UNIT_ENERGY_DENSITY_JOULE_PER_CUBIC_METRE = 0x274A,
boro 0:4beb2ea291ec 806
boro 0:4beb2ea291ec 807 /**
boro 0:4beb2ea291ec 808 * Electric field strength, volt per meter.
boro 0:4beb2ea291ec 809 */
boro 0:4beb2ea291ec 810 BLE_GATT_UNIT_ELECTRIC_FIELD_STRENGTH_VOLT_PER_METRE = 0x274B,
boro 0:4beb2ea291ec 811
boro 0:4beb2ea291ec 812 /**
boro 0:4beb2ea291ec 813 * Electric charge density, coulomb per cubic meter.
boro 0:4beb2ea291ec 814 */
boro 0:4beb2ea291ec 815 BLE_GATT_UNIT_ELECTRIC_CHARGE_DENSITY_COULOMB_PER_CUBIC_METRE = 0x274C,
boro 0:4beb2ea291ec 816
boro 0:4beb2ea291ec 817 /**
boro 0:4beb2ea291ec 818 * Surface charge density, coulomb per square meter.
boro 0:4beb2ea291ec 819 */
boro 0:4beb2ea291ec 820 BLE_GATT_UNIT_SURFACE_CHARGE_DENSITY_COULOMB_PER_SQUARE_METRE = 0x274D,
boro 0:4beb2ea291ec 821
boro 0:4beb2ea291ec 822 /**
boro 0:4beb2ea291ec 823 * Electric flux density, coulomb per square meter.
boro 0:4beb2ea291ec 824 */
boro 0:4beb2ea291ec 825 BLE_GATT_UNIT_ELECTRIC_FLUX_DENSITY_COULOMB_PER_SQUARE_METRE = 0x274E,
boro 0:4beb2ea291ec 826
boro 0:4beb2ea291ec 827 /**
boro 0:4beb2ea291ec 828 * Permittivity, farad per meter.
boro 0:4beb2ea291ec 829 */
boro 0:4beb2ea291ec 830 BLE_GATT_UNIT_PERMITTIVITY_FARAD_PER_METRE = 0x274F,
boro 0:4beb2ea291ec 831
boro 0:4beb2ea291ec 832 /**
boro 0:4beb2ea291ec 833 * Permeability, henry per meter.
boro 0:4beb2ea291ec 834 */
boro 0:4beb2ea291ec 835 BLE_GATT_UNIT_PERMEABILITY_HENRY_PER_METRE = 0x2750,
boro 0:4beb2ea291ec 836
boro 0:4beb2ea291ec 837 /**
boro 0:4beb2ea291ec 838 * Molar energy, joule per mole.
boro 0:4beb2ea291ec 839 */
boro 0:4beb2ea291ec 840 BLE_GATT_UNIT_MOLAR_ENERGY_JOULE_PER_MOLE = 0x2751,
boro 0:4beb2ea291ec 841
boro 0:4beb2ea291ec 842 /**
boro 0:4beb2ea291ec 843 * Molar entropy, joule per mole kelvin.
boro 0:4beb2ea291ec 844 */
boro 0:4beb2ea291ec 845 BLE_GATT_UNIT_MOLAR_ENTROPY_JOULE_PER_MOLE_KELVIN = 0x2752,
boro 0:4beb2ea291ec 846
boro 0:4beb2ea291ec 847 /**
boro 0:4beb2ea291ec 848 * Exposure, coulomb per kilogram.
boro 0:4beb2ea291ec 849 */
boro 0:4beb2ea291ec 850 BLE_GATT_UNIT_EXPOSURE_COULOMB_PER_KILOGRAM = 0x2753,
boro 0:4beb2ea291ec 851
boro 0:4beb2ea291ec 852 /**
boro 0:4beb2ea291ec 853 * Absorbed dose rate, gray per second.
boro 0:4beb2ea291ec 854 */
boro 0:4beb2ea291ec 855 BLE_GATT_UNIT_ABSORBED_DOSE_RATE_GRAY_PER_SECOND = 0x2754,
boro 0:4beb2ea291ec 856
boro 0:4beb2ea291ec 857 /**
boro 0:4beb2ea291ec 858 * Radiant intensity, watt per steradian.
boro 0:4beb2ea291ec 859 */
boro 0:4beb2ea291ec 860 BLE_GATT_UNIT_RADIANT_INTENSITY_WATT_PER_STERADIAN = 0x2755,
boro 0:4beb2ea291ec 861
boro 0:4beb2ea291ec 862 /**
boro 0:4beb2ea291ec 863 * Radiance, watt per square meter steradian.
boro 0:4beb2ea291ec 864 */
boro 0:4beb2ea291ec 865 BLE_GATT_UNIT_RADIANCE_WATT_PER_SQUARE_METRE_STERADIAN = 0x2756,
boro 0:4beb2ea291ec 866
boro 0:4beb2ea291ec 867 /**
boro 0:4beb2ea291ec 868 * Catalytic activity concentration, katal per cubic meter.
boro 0:4beb2ea291ec 869 */
boro 0:4beb2ea291ec 870 BLE_GATT_UNIT_CATALYTIC_ACTIVITY_CONCENTRATION_KATAL_PER_CUBIC_METRE = 0x2757,
boro 0:4beb2ea291ec 871
boro 0:4beb2ea291ec 872 /**
boro 0:4beb2ea291ec 873 * Time, minute.
boro 0:4beb2ea291ec 874 */
boro 0:4beb2ea291ec 875 BLE_GATT_UNIT_TIME_MINUTE = 0x2760,
boro 0:4beb2ea291ec 876
boro 0:4beb2ea291ec 877 /**
boro 0:4beb2ea291ec 878 * Time, hour.
boro 0:4beb2ea291ec 879 */
boro 0:4beb2ea291ec 880 BLE_GATT_UNIT_TIME_HOUR = 0x2761,
boro 0:4beb2ea291ec 881
boro 0:4beb2ea291ec 882 /**
boro 0:4beb2ea291ec 883 * Time, day.
boro 0:4beb2ea291ec 884 */
boro 0:4beb2ea291ec 885 BLE_GATT_UNIT_TIME_DAY = 0x2762,
boro 0:4beb2ea291ec 886
boro 0:4beb2ea291ec 887 /**
boro 0:4beb2ea291ec 888 * Plane angle, degree.
boro 0:4beb2ea291ec 889 */
boro 0:4beb2ea291ec 890 BLE_GATT_UNIT_PLANE_ANGLE_DEGREE = 0x2763,
boro 0:4beb2ea291ec 891
boro 0:4beb2ea291ec 892 /**
boro 0:4beb2ea291ec 893 * Plane angle, minute.
boro 0:4beb2ea291ec 894 */
boro 0:4beb2ea291ec 895 BLE_GATT_UNIT_PLANE_ANGLE_MINUTE = 0x2764,
boro 0:4beb2ea291ec 896
boro 0:4beb2ea291ec 897 /**
boro 0:4beb2ea291ec 898 * Plane angle, seconds.
boro 0:4beb2ea291ec 899 */
boro 0:4beb2ea291ec 900 BLE_GATT_UNIT_PLANE_ANGLE_SECOND = 0x2765,
boro 0:4beb2ea291ec 901
boro 0:4beb2ea291ec 902 /**
boro 0:4beb2ea291ec 903 * Area, hectare.
boro 0:4beb2ea291ec 904 */
boro 0:4beb2ea291ec 905 BLE_GATT_UNIT_AREA_HECTARE = 0x2766,
boro 0:4beb2ea291ec 906
boro 0:4beb2ea291ec 907 /**
boro 0:4beb2ea291ec 908 * Volume, liter.
boro 0:4beb2ea291ec 909 */
boro 0:4beb2ea291ec 910 BLE_GATT_UNIT_VOLUME_LITRE = 0x2767,
boro 0:4beb2ea291ec 911
boro 0:4beb2ea291ec 912 /**
boro 0:4beb2ea291ec 913 * Mass, ton.
boro 0:4beb2ea291ec 914 */
boro 0:4beb2ea291ec 915 BLE_GATT_UNIT_MASS_TONNE = 0x2768,
boro 0:4beb2ea291ec 916
boro 0:4beb2ea291ec 917 /**
boro 0:4beb2ea291ec 918 * Pressure, bar.
boro 0:4beb2ea291ec 919 */
boro 0:4beb2ea291ec 920 BLE_GATT_UNIT_PRESSURE_BAR = 0x2780,
boro 0:4beb2ea291ec 921
boro 0:4beb2ea291ec 922 /**
boro 0:4beb2ea291ec 923 * Pressure, millimeter of mercury.
boro 0:4beb2ea291ec 924 */
boro 0:4beb2ea291ec 925 BLE_GATT_UNIT_PRESSURE_MILLIMETRE_OF_MERCURY = 0x2781,
boro 0:4beb2ea291ec 926
boro 0:4beb2ea291ec 927 /**
boro 0:4beb2ea291ec 928 * Length, ngstrm.
boro 0:4beb2ea291ec 929 */
boro 0:4beb2ea291ec 930 BLE_GATT_UNIT_LENGTH_ANGSTROM = 0x2782,
boro 0:4beb2ea291ec 931
boro 0:4beb2ea291ec 932 /**
boro 0:4beb2ea291ec 933 * Length, nautical mile.
boro 0:4beb2ea291ec 934 */
boro 0:4beb2ea291ec 935 BLE_GATT_UNIT_LENGTH_NAUTICAL_MILE = 0x2783,
boro 0:4beb2ea291ec 936
boro 0:4beb2ea291ec 937 /**
boro 0:4beb2ea291ec 938 * Area, barn.
boro 0:4beb2ea291ec 939 */
boro 0:4beb2ea291ec 940 BLE_GATT_UNIT_AREA_BARN = 0x2784,
boro 0:4beb2ea291ec 941
boro 0:4beb2ea291ec 942 /**
boro 0:4beb2ea291ec 943 * Velocity, knot.
boro 0:4beb2ea291ec 944 */
boro 0:4beb2ea291ec 945 BLE_GATT_UNIT_VELOCITY_KNOT = 0x2785,
boro 0:4beb2ea291ec 946
boro 0:4beb2ea291ec 947 /**
boro 0:4beb2ea291ec 948 * Logarithmic radio quantity, neper.
boro 0:4beb2ea291ec 949 */
boro 0:4beb2ea291ec 950 BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_NEPER = 0x2786,
boro 0:4beb2ea291ec 951
boro 0:4beb2ea291ec 952 /**
boro 0:4beb2ea291ec 953 * Logarithmic radio quantity, bel.
boro 0:4beb2ea291ec 954 */
boro 0:4beb2ea291ec 955 BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_BEL = 0x2787,
boro 0:4beb2ea291ec 956
boro 0:4beb2ea291ec 957 /**
boro 0:4beb2ea291ec 958 * Length, yard.
boro 0:4beb2ea291ec 959 */
boro 0:4beb2ea291ec 960 BLE_GATT_UNIT_LENGTH_YARD = 0x27A0,
boro 0:4beb2ea291ec 961
boro 0:4beb2ea291ec 962 /**
boro 0:4beb2ea291ec 963 * Length, parsec.
boro 0:4beb2ea291ec 964 */
boro 0:4beb2ea291ec 965 BLE_GATT_UNIT_LENGTH_PARSEC = 0x27A1,
boro 0:4beb2ea291ec 966
boro 0:4beb2ea291ec 967 /**
boro 0:4beb2ea291ec 968 * Length, inch.
boro 0:4beb2ea291ec 969 */
boro 0:4beb2ea291ec 970 BLE_GATT_UNIT_LENGTH_INCH = 0x27A2,
boro 0:4beb2ea291ec 971
boro 0:4beb2ea291ec 972 /**
boro 0:4beb2ea291ec 973 * Length, foot.
boro 0:4beb2ea291ec 974 */
boro 0:4beb2ea291ec 975 BLE_GATT_UNIT_LENGTH_FOOT = 0x27A3,
boro 0:4beb2ea291ec 976
boro 0:4beb2ea291ec 977 /**
boro 0:4beb2ea291ec 978 * Length, mile.
boro 0:4beb2ea291ec 979 */
boro 0:4beb2ea291ec 980 BLE_GATT_UNIT_LENGTH_MILE = 0x27A4,
boro 0:4beb2ea291ec 981
boro 0:4beb2ea291ec 982 /**
boro 0:4beb2ea291ec 983 * Pressure, pound-force per square inch.
boro 0:4beb2ea291ec 984 */
boro 0:4beb2ea291ec 985 BLE_GATT_UNIT_PRESSURE_POUND_FORCE_PER_SQUARE_INCH = 0x27A5,
boro 0:4beb2ea291ec 986
boro 0:4beb2ea291ec 987 /**
boro 0:4beb2ea291ec 988 * Velocity, kilometer per hour.
boro 0:4beb2ea291ec 989 */
boro 0:4beb2ea291ec 990 BLE_GATT_UNIT_VELOCITY_KILOMETRE_PER_HOUR = 0x27A6,
boro 0:4beb2ea291ec 991
boro 0:4beb2ea291ec 992 /** Velocity, mile per hour.
boro 0:4beb2ea291ec 993 *
boro 0:4beb2ea291ec 994 */
boro 0:4beb2ea291ec 995 BLE_GATT_UNIT_VELOCITY_MILE_PER_HOUR = 0x27A7,
boro 0:4beb2ea291ec 996
boro 0:4beb2ea291ec 997 /**
boro 0:4beb2ea291ec 998 * Angular Velocity, revolution per minute.
boro 0:4beb2ea291ec 999 */
boro 0:4beb2ea291ec 1000 BLE_GATT_UNIT_ANGULAR_VELOCITY_REVOLUTION_PER_MINUTE = 0x27A8,
boro 0:4beb2ea291ec 1001
boro 0:4beb2ea291ec 1002 /**
boro 0:4beb2ea291ec 1003 * Energy, gram calorie.
boro 0:4beb2ea291ec 1004 */
boro 0:4beb2ea291ec 1005 BLE_GATT_UNIT_ENERGY_GRAM_CALORIE = 0x27A9,
boro 0:4beb2ea291ec 1006
boro 0:4beb2ea291ec 1007 /**
boro 0:4beb2ea291ec 1008 * Energy, kilogram calorie.
boro 0:4beb2ea291ec 1009 */
boro 0:4beb2ea291ec 1010 BLE_GATT_UNIT_ENERGY_KILOGRAM_CALORIE = 0x27AA,
boro 0:4beb2ea291ec 1011
boro 0:4beb2ea291ec 1012 /**
boro 0:4beb2ea291ec 1013 * Energy, killowatt hour.
boro 0:4beb2ea291ec 1014 */
boro 0:4beb2ea291ec 1015 BLE_GATT_UNIT_ENERGY_KILOWATT_HOUR = 0x27AB,
boro 0:4beb2ea291ec 1016
boro 0:4beb2ea291ec 1017 /**
boro 0:4beb2ea291ec 1018 * Thermodynamic temperature, degree Fahrenheit.
boro 0:4beb2ea291ec 1019 */
boro 0:4beb2ea291ec 1020 BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_FAHRENHEIT = 0x27AC,
boro 0:4beb2ea291ec 1021
boro 0:4beb2ea291ec 1022 /**
boro 0:4beb2ea291ec 1023 * Percentage.
boro 0:4beb2ea291ec 1024 */
boro 0:4beb2ea291ec 1025 BLE_GATT_UNIT_PERCENTAGE = 0x27AD,
boro 0:4beb2ea291ec 1026
boro 0:4beb2ea291ec 1027 /**
boro 0:4beb2ea291ec 1028 * Per mille.
boro 0:4beb2ea291ec 1029 */
boro 0:4beb2ea291ec 1030 BLE_GATT_UNIT_PER_MILLE = 0x27AE,
boro 0:4beb2ea291ec 1031
boro 0:4beb2ea291ec 1032 /**
boro 0:4beb2ea291ec 1033 * Period, beats per minute.
boro 0:4beb2ea291ec 1034 */
boro 0:4beb2ea291ec 1035 BLE_GATT_UNIT_PERIOD_BEATS_PER_MINUTE = 0x27AF,
boro 0:4beb2ea291ec 1036
boro 0:4beb2ea291ec 1037 /**
boro 0:4beb2ea291ec 1038 * Electric charge, ampere hours.
boro 0:4beb2ea291ec 1039 */
boro 0:4beb2ea291ec 1040 BLE_GATT_UNIT_ELECTRIC_CHARGE_AMPERE_HOURS = 0x27B0,
boro 0:4beb2ea291ec 1041
boro 0:4beb2ea291ec 1042 /**
boro 0:4beb2ea291ec 1043 * Mass density, milligram per deciliter.
boro 0:4beb2ea291ec 1044 */
boro 0:4beb2ea291ec 1045 BLE_GATT_UNIT_MASS_DENSITY_MILLIGRAM_PER_DECILITRE = 0x27B1,
boro 0:4beb2ea291ec 1046
boro 0:4beb2ea291ec 1047 /**
boro 0:4beb2ea291ec 1048 * Mass density, millimole per liter.
boro 0:4beb2ea291ec 1049 */
boro 0:4beb2ea291ec 1050 BLE_GATT_UNIT_MASS_DENSITY_MILLIMOLE_PER_LITRE = 0x27B2,
boro 0:4beb2ea291ec 1051
boro 0:4beb2ea291ec 1052 /**
boro 0:4beb2ea291ec 1053 * Time, year.
boro 0:4beb2ea291ec 1054 */
boro 0:4beb2ea291ec 1055 BLE_GATT_UNIT_TIME_YEAR = 0x27B3,
boro 0:4beb2ea291ec 1056
boro 0:4beb2ea291ec 1057 /**
boro 0:4beb2ea291ec 1058 * Time, month.
boro 0:4beb2ea291ec 1059 */
boro 0:4beb2ea291ec 1060 BLE_GATT_UNIT_TIME_MONTH = 0x27B4,
boro 0:4beb2ea291ec 1061
boro 0:4beb2ea291ec 1062 /**
boro 0:4beb2ea291ec 1063 * Concentration, count per cubic meter.
boro 0:4beb2ea291ec 1064 */
boro 0:4beb2ea291ec 1065 BLE_GATT_UNIT_CONCENTRATION_COUNT_PER_CUBIC_METRE = 0x27B5,
boro 0:4beb2ea291ec 1066
boro 0:4beb2ea291ec 1067 /**
boro 0:4beb2ea291ec 1068 * Irradiance, watt per square meter.
boro 0:4beb2ea291ec 1069 */
boro 0:4beb2ea291ec 1070 BLE_GATT_UNIT_IRRADIANCE_WATT_PER_SQUARE_METRE = 0x27B6
boro 0:4beb2ea291ec 1071 };
boro 0:4beb2ea291ec 1072
boro 0:4beb2ea291ec 1073 /**
boro 0:4beb2ea291ec 1074 * Presentation format of a characteristic.
boro 0:4beb2ea291ec 1075 *
boro 0:4beb2ea291ec 1076 * It determines how the value of a characteristic is formatted. A server
boro 0:4beb2ea291ec 1077 * can expose that information to its clients by adding a Characteristic
boro 0:4beb2ea291ec 1078 * Presentation Format descriptor to relevant characteristics.
boro 0:4beb2ea291ec 1079 *
boro 0:4beb2ea291ec 1080 * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5.2.
boro 0:4beb2ea291ec 1081 */
boro 0:4beb2ea291ec 1082 enum {
boro 0:4beb2ea291ec 1083 /**
boro 0:4beb2ea291ec 1084 * Reserved for future use.
boro 0:4beb2ea291ec 1085 */
boro 0:4beb2ea291ec 1086 BLE_GATT_FORMAT_RFU = 0x00,
boro 0:4beb2ea291ec 1087
boro 0:4beb2ea291ec 1088 /**
boro 0:4beb2ea291ec 1089 * Boolean.
boro 0:4beb2ea291ec 1090 */
boro 0:4beb2ea291ec 1091 BLE_GATT_FORMAT_BOOLEAN = 0x01,
boro 0:4beb2ea291ec 1092
boro 0:4beb2ea291ec 1093 /**
boro 0:4beb2ea291ec 1094 * Unsigned 2-bit integer.
boro 0:4beb2ea291ec 1095 */
boro 0:4beb2ea291ec 1096 BLE_GATT_FORMAT_2BIT = 0x02,
boro 0:4beb2ea291ec 1097
boro 0:4beb2ea291ec 1098 /**
boro 0:4beb2ea291ec 1099 * Unsigned 4-bit integer.
boro 0:4beb2ea291ec 1100 */
boro 0:4beb2ea291ec 1101 BLE_GATT_FORMAT_NIBBLE = 0x03,
boro 0:4beb2ea291ec 1102
boro 0:4beb2ea291ec 1103 /**
boro 0:4beb2ea291ec 1104 * Unsigned 8-bit integer.
boro 0:4beb2ea291ec 1105 */
boro 0:4beb2ea291ec 1106 BLE_GATT_FORMAT_UINT8 = 0x04,
boro 0:4beb2ea291ec 1107
boro 0:4beb2ea291ec 1108 /**
boro 0:4beb2ea291ec 1109 * Unsigned 12-bit integer.
boro 0:4beb2ea291ec 1110 */
boro 0:4beb2ea291ec 1111 BLE_GATT_FORMAT_UINT12 = 0x05,
boro 0:4beb2ea291ec 1112
boro 0:4beb2ea291ec 1113 /**
boro 0:4beb2ea291ec 1114 * Unsigned 16-bit integer.
boro 0:4beb2ea291ec 1115 */
boro 0:4beb2ea291ec 1116 BLE_GATT_FORMAT_UINT16 = 0x06,
boro 0:4beb2ea291ec 1117
boro 0:4beb2ea291ec 1118 /**
boro 0:4beb2ea291ec 1119 * Unsigned 24-bit integer.
boro 0:4beb2ea291ec 1120 */
boro 0:4beb2ea291ec 1121 BLE_GATT_FORMAT_UINT24 = 0x07,
boro 0:4beb2ea291ec 1122
boro 0:4beb2ea291ec 1123 /**
boro 0:4beb2ea291ec 1124 * Unsigned 32-bit integer.
boro 0:4beb2ea291ec 1125 */
boro 0:4beb2ea291ec 1126 BLE_GATT_FORMAT_UINT32 = 0x08,
boro 0:4beb2ea291ec 1127
boro 0:4beb2ea291ec 1128 /**
boro 0:4beb2ea291ec 1129 * Unsigned 48-bit integer.
boro 0:4beb2ea291ec 1130 */
boro 0:4beb2ea291ec 1131 BLE_GATT_FORMAT_UINT48 = 0x09,
boro 0:4beb2ea291ec 1132
boro 0:4beb2ea291ec 1133 /**
boro 0:4beb2ea291ec 1134 * Unsigned 64-bit integer.
boro 0:4beb2ea291ec 1135 */
boro 0:4beb2ea291ec 1136 BLE_GATT_FORMAT_UINT64 = 0x0A,
boro 0:4beb2ea291ec 1137
boro 0:4beb2ea291ec 1138 /**
boro 0:4beb2ea291ec 1139 * Unsigned 128-bit integer.
boro 0:4beb2ea291ec 1140 */
boro 0:4beb2ea291ec 1141 BLE_GATT_FORMAT_UINT128 = 0x0B,
boro 0:4beb2ea291ec 1142
boro 0:4beb2ea291ec 1143 /**
boro 0:4beb2ea291ec 1144 * Signed 8-bit integer.
boro 0:4beb2ea291ec 1145 */
boro 0:4beb2ea291ec 1146 BLE_GATT_FORMAT_SINT8 = 0x0C,
boro 0:4beb2ea291ec 1147
boro 0:4beb2ea291ec 1148 /**
boro 0:4beb2ea291ec 1149 * Signed 12-bit integer.
boro 0:4beb2ea291ec 1150 */
boro 0:4beb2ea291ec 1151 BLE_GATT_FORMAT_SINT12 = 0x0D,
boro 0:4beb2ea291ec 1152
boro 0:4beb2ea291ec 1153 /**
boro 0:4beb2ea291ec 1154 * Signed 16-bit integer.
boro 0:4beb2ea291ec 1155 */
boro 0:4beb2ea291ec 1156 BLE_GATT_FORMAT_SINT16 = 0x0E,
boro 0:4beb2ea291ec 1157
boro 0:4beb2ea291ec 1158 /**
boro 0:4beb2ea291ec 1159 * Signed 24-bit integer.
boro 0:4beb2ea291ec 1160 */
boro 0:4beb2ea291ec 1161 BLE_GATT_FORMAT_SINT24 = 0x0F,
boro 0:4beb2ea291ec 1162
boro 0:4beb2ea291ec 1163 /**
boro 0:4beb2ea291ec 1164 * Signed 32-bit integer.
boro 0:4beb2ea291ec 1165 */
boro 0:4beb2ea291ec 1166 BLE_GATT_FORMAT_SINT32 = 0x10,
boro 0:4beb2ea291ec 1167
boro 0:4beb2ea291ec 1168 /**
boro 0:4beb2ea291ec 1169 * Signed 48-bit integer.
boro 0:4beb2ea291ec 1170 */
boro 0:4beb2ea291ec 1171 BLE_GATT_FORMAT_SINT48 = 0x11,
boro 0:4beb2ea291ec 1172
boro 0:4beb2ea291ec 1173 /**
boro 0:4beb2ea291ec 1174 * Signed 64-bit integer.
boro 0:4beb2ea291ec 1175 */
boro 0:4beb2ea291ec 1176 BLE_GATT_FORMAT_SINT64 = 0x12,
boro 0:4beb2ea291ec 1177
boro 0:4beb2ea291ec 1178 /**
boro 0:4beb2ea291ec 1179 * Signed 128-bit integer.
boro 0:4beb2ea291ec 1180 */
boro 0:4beb2ea291ec 1181 BLE_GATT_FORMAT_SINT128 = 0x13,
boro 0:4beb2ea291ec 1182
boro 0:4beb2ea291ec 1183 /**
boro 0:4beb2ea291ec 1184 * IEEE-754 32-bit floating point.
boro 0:4beb2ea291ec 1185 */
boro 0:4beb2ea291ec 1186 BLE_GATT_FORMAT_FLOAT32 = 0x14,
boro 0:4beb2ea291ec 1187
boro 0:4beb2ea291ec 1188 /**
boro 0:4beb2ea291ec 1189 * IEEE-754 64-bit floating point.
boro 0:4beb2ea291ec 1190 */
boro 0:4beb2ea291ec 1191 BLE_GATT_FORMAT_FLOAT64 = 0x15,
boro 0:4beb2ea291ec 1192
boro 0:4beb2ea291ec 1193 /**
boro 0:4beb2ea291ec 1194 * IEEE-11073 16-bit SFLOAT.
boro 0:4beb2ea291ec 1195 */
boro 0:4beb2ea291ec 1196 BLE_GATT_FORMAT_SFLOAT = 0x16,
boro 0:4beb2ea291ec 1197
boro 0:4beb2ea291ec 1198 /**
boro 0:4beb2ea291ec 1199 * IEEE-11073 32-bit FLOAT.
boro 0:4beb2ea291ec 1200 */
boro 0:4beb2ea291ec 1201 BLE_GATT_FORMAT_FLOAT = 0x17,
boro 0:4beb2ea291ec 1202
boro 0:4beb2ea291ec 1203 /**
boro 0:4beb2ea291ec 1204 * IEEE-20601 format.
boro 0:4beb2ea291ec 1205 */
boro 0:4beb2ea291ec 1206 BLE_GATT_FORMAT_DUINT16 = 0x18,
boro 0:4beb2ea291ec 1207
boro 0:4beb2ea291ec 1208 /**
boro 0:4beb2ea291ec 1209 * UTF8 string.
boro 0:4beb2ea291ec 1210 */
boro 0:4beb2ea291ec 1211 BLE_GATT_FORMAT_UTF8S = 0x19,
boro 0:4beb2ea291ec 1212
boro 0:4beb2ea291ec 1213 /**
boro 0:4beb2ea291ec 1214 * UTF16 string.
boro 0:4beb2ea291ec 1215 */
boro 0:4beb2ea291ec 1216 BLE_GATT_FORMAT_UTF16S = 0x1A,
boro 0:4beb2ea291ec 1217
boro 0:4beb2ea291ec 1218 /**
boro 0:4beb2ea291ec 1219 * Opaque Structure.
boro 0:4beb2ea291ec 1220 */
boro 0:4beb2ea291ec 1221 BLE_GATT_FORMAT_STRUCT = 0x1B
boro 0:4beb2ea291ec 1222 };
boro 0:4beb2ea291ec 1223
boro 0:4beb2ea291ec 1224 /*!
boro 0:4beb2ea291ec 1225 * Characteristic properties.
boro 0:4beb2ea291ec 1226 *
boro 0:4beb2ea291ec 1227 * It is a bitfield that determines how a characteristic value can be used.
boro 0:4beb2ea291ec 1228 *
boro 0:4beb2ea291ec 1229 * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.1.1
boro 0:4beb2ea291ec 1230 * and Section 3.3.3.1 for Extended Properties.
boro 0:4beb2ea291ec 1231 */
boro 0:4beb2ea291ec 1232 enum Properties_t {
boro 0:4beb2ea291ec 1233 /**
boro 0:4beb2ea291ec 1234 * No property defined.
boro 0:4beb2ea291ec 1235 */
boro 0:4beb2ea291ec 1236 BLE_GATT_CHAR_PROPERTIES_NONE = 0x00,
boro 0:4beb2ea291ec 1237
boro 0:4beb2ea291ec 1238 /**
boro 0:4beb2ea291ec 1239 * Permits broadcasts of the characteristic value using the Server
boro 0:4beb2ea291ec 1240 * Characteristic Configuration descriptor.
boro 0:4beb2ea291ec 1241 */
boro 0:4beb2ea291ec 1242 BLE_GATT_CHAR_PROPERTIES_BROADCAST = 0x01,
boro 0:4beb2ea291ec 1243
boro 0:4beb2ea291ec 1244 /**
boro 0:4beb2ea291ec 1245 * Permits reads of the characteristic value.
boro 0:4beb2ea291ec 1246 */
boro 0:4beb2ea291ec 1247 BLE_GATT_CHAR_PROPERTIES_READ = 0x02,
boro 0:4beb2ea291ec 1248
boro 0:4beb2ea291ec 1249 /**
boro 0:4beb2ea291ec 1250 * Permits writes of the characteristic value without response.
boro 0:4beb2ea291ec 1251 */
boro 0:4beb2ea291ec 1252 BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE = 0x04,
boro 0:4beb2ea291ec 1253
boro 0:4beb2ea291ec 1254 /**
boro 0:4beb2ea291ec 1255 * Permits writes of the characteristic value with response.
boro 0:4beb2ea291ec 1256 */
boro 0:4beb2ea291ec 1257 BLE_GATT_CHAR_PROPERTIES_WRITE = 0x08,
boro 0:4beb2ea291ec 1258
boro 0:4beb2ea291ec 1259 /**
boro 0:4beb2ea291ec 1260 * Permits notifications of a characteristic value without acknowledgment.
boro 0:4beb2ea291ec 1261 */
boro 0:4beb2ea291ec 1262 BLE_GATT_CHAR_PROPERTIES_NOTIFY = 0x10,
boro 0:4beb2ea291ec 1263
boro 0:4beb2ea291ec 1264 /**
boro 0:4beb2ea291ec 1265 * Permits indications of a characteristic value with acknowledgment.
boro 0:4beb2ea291ec 1266 */
boro 0:4beb2ea291ec 1267 BLE_GATT_CHAR_PROPERTIES_INDICATE = 0x20,
boro 0:4beb2ea291ec 1268
boro 0:4beb2ea291ec 1269 /**
boro 0:4beb2ea291ec 1270 * Permits signed writes to the characteristic value.
boro 0:4beb2ea291ec 1271 */
boro 0:4beb2ea291ec 1272 BLE_GATT_CHAR_PROPERTIES_AUTHENTICATED_SIGNED_WRITES = 0x40,
boro 0:4beb2ea291ec 1273
boro 0:4beb2ea291ec 1274 /**
boro 0:4beb2ea291ec 1275 * The Characteristic Extended Properties descriptor
boro 0:4beb2ea291ec 1276 * defines additional characteristic properties.
boro 0:4beb2ea291ec 1277 */
boro 0:4beb2ea291ec 1278 BLE_GATT_CHAR_PROPERTIES_EXTENDED_PROPERTIES = 0x80
boro 0:4beb2ea291ec 1279
boro 0:4beb2ea291ec 1280 };
boro 0:4beb2ea291ec 1281
boro 0:4beb2ea291ec 1282 /**
boro 0:4beb2ea291ec 1283 * Value of a Characteristic Presentation Format descriptor.
boro 0:4beb2ea291ec 1284 *
boro 0:4beb2ea291ec 1285 * Characteristic Presentation Format descriptor expresses the format of a
boro 0:4beb2ea291ec 1286 * characteristic value.
boro 0:4beb2ea291ec 1287 *
boro 0:4beb2ea291ec 1288 * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5.
boro 0:4beb2ea291ec 1289 */
boro 0:4beb2ea291ec 1290 struct PresentationFormat_t {
boro 0:4beb2ea291ec 1291 /**
boro 0:4beb2ea291ec 1292 * Format of the value.
boro 0:4beb2ea291ec 1293 */
boro 0:4beb2ea291ec 1294 uint8_t gatt_format;
boro 0:4beb2ea291ec 1295
boro 0:4beb2ea291ec 1296 /**
boro 0:4beb2ea291ec 1297 * Exponent for integer data types.
boro 0:4beb2ea291ec 1298 *
boro 0:4beb2ea291ec 1299 * Example: if Exponent = -3 and the char value is 3892, the actual
boro 0:4beb2ea291ec 1300 * value is 3.892
boro 0:4beb2ea291ec 1301 */
boro 0:4beb2ea291ec 1302 int8_t exponent;
boro 0:4beb2ea291ec 1303
boro 0:4beb2ea291ec 1304 /**
boro 0:4beb2ea291ec 1305 * Unit of the characteristic value.
boro 0:4beb2ea291ec 1306 *
boro 0:4beb2ea291ec 1307 * It is a UUID from Bluetooth Assigned Numbers.
boro 0:4beb2ea291ec 1308 */
boro 0:4beb2ea291ec 1309 uint16_t gatt_unit;
boro 0:4beb2ea291ec 1310
boro 0:4beb2ea291ec 1311 /**
boro 0:4beb2ea291ec 1312 * Namespace of the description field.
boro 0:4beb2ea291ec 1313 *
boro 0:4beb2ea291ec 1314 * This field identifies the organization that is responsible for
boro 0:4beb2ea291ec 1315 * defining the enumerations for the description field.
boro 0:4beb2ea291ec 1316 *
boro 0:4beb2ea291ec 1317 * The namespace of the Bluetooth Body is 0x01.
boro 0:4beb2ea291ec 1318 */
boro 0:4beb2ea291ec 1319 uint8_t gatt_namespace;
boro 0:4beb2ea291ec 1320
boro 0:4beb2ea291ec 1321 /**
boro 0:4beb2ea291ec 1322 * Description.
boro 0:4beb2ea291ec 1323 *
boro 0:4beb2ea291ec 1324 * @note The value 0x0000 means unknown in the Bluetooth namespace.
boro 0:4beb2ea291ec 1325 */
boro 0:4beb2ea291ec 1326 uint16_t gatt_nsdesc;
boro 0:4beb2ea291ec 1327
boro 0:4beb2ea291ec 1328 };
boro 0:4beb2ea291ec 1329
boro 0:4beb2ea291ec 1330 /**
boro 0:4beb2ea291ec 1331 * @brief Constructs a new GattCharacteristic.
boro 0:4beb2ea291ec 1332 *
boro 0:4beb2ea291ec 1333 * @param[in] uuid The UUID of this characteristic.
boro 0:4beb2ea291ec 1334 * @param[in] valuePtr Memory buffer holding the initial value. The value is
boro 0:4beb2ea291ec 1335 * copied into the Bluetooth subsytem when the enclosing service is added.
boro 0:4beb2ea291ec 1336 * Thereafter, the stack maintains it internally.
boro 0:4beb2ea291ec 1337 * @param[in] len The length in bytes of this characteristic's value.
boro 0:4beb2ea291ec 1338 * @param[in] maxLen The capacity in bytes of the characteristic value
boro 0:4beb2ea291ec 1339 * buffer.
boro 0:4beb2ea291ec 1340 * @param[in] props An 8-bit field that contains the characteristic's
boro 0:4beb2ea291ec 1341 * properties.
boro 0:4beb2ea291ec 1342 * @param[in] descriptors A pointer to an array of descriptors to be included
boro 0:4beb2ea291ec 1343 * within this characteristic. The caller owns the memory for the descriptor
boro 0:4beb2ea291ec 1344 * array, which must remain valid at least until the enclosing service is
boro 0:4beb2ea291ec 1345 * added to the GATT table.
boro 0:4beb2ea291ec 1346 * @param[in] numDescriptors The number of descriptors presents in @p
boro 0:4beb2ea291ec 1347 * descriptors array.
boro 0:4beb2ea291ec 1348 * @param[in] hasVariableLen Flag that indicates if the attribute's value
boro 0:4beb2ea291ec 1349 * length can change throughout time.
boro 0:4beb2ea291ec 1350 *
boro 0:4beb2ea291ec 1351 * @note If valuePtr is NULL, length is equal to 0 and the characteristic
boro 0:4beb2ea291ec 1352 * is readable, then that particular characteristic may be considered
boro 0:4beb2ea291ec 1353 * optional and dropped while instantiating the service with the underlying
boro 0:4beb2ea291ec 1354 * BLE stack.
boro 0:4beb2ea291ec 1355 *
boro 0:4beb2ea291ec 1356 * @note A Client Characteristic Configuration Descriptor (CCCD) should not
boro 0:4beb2ea291ec 1357 * be allocated if either the notify or indicate flag in the @p props bit
boro 0:4beb2ea291ec 1358 * field; the underlying BLE stack handles it.
boro 0:4beb2ea291ec 1359 *
boro 0:4beb2ea291ec 1360 * @important GattCharacteristic registered in a GattServer must remain
boro 0:4beb2ea291ec 1361 * valid for the lifetime of the GattServer.
boro 0:4beb2ea291ec 1362 */
boro 0:4beb2ea291ec 1363 GattCharacteristic(
boro 0:4beb2ea291ec 1364 const UUID &uuid,
boro 0:4beb2ea291ec 1365 uint8_t *valuePtr = NULL,
boro 0:4beb2ea291ec 1366 uint16_t len = 0,
boro 0:4beb2ea291ec 1367 uint16_t maxLen = 0,
boro 0:4beb2ea291ec 1368 uint8_t props = BLE_GATT_CHAR_PROPERTIES_NONE,
boro 0:4beb2ea291ec 1369 GattAttribute *descriptors[] = NULL,
boro 0:4beb2ea291ec 1370 unsigned numDescriptors = 0,
boro 0:4beb2ea291ec 1371 bool hasVariableLen = true
boro 0:4beb2ea291ec 1372 ) : _valueAttribute(uuid, valuePtr, len, maxLen, hasVariableLen),
boro 0:4beb2ea291ec 1373 _properties(props),
boro 0:4beb2ea291ec 1374 _requiredSecurity(SecurityManager::SECURITY_MODE_ENCRYPTION_OPEN_LINK),
boro 0:4beb2ea291ec 1375 _descriptors(descriptors),
boro 0:4beb2ea291ec 1376 _descriptorCount(numDescriptors),
boro 0:4beb2ea291ec 1377 enabledReadAuthorization(false),
boro 0:4beb2ea291ec 1378 enabledWriteAuthorization(false),
boro 0:4beb2ea291ec 1379 readAuthorizationCallback(),
boro 0:4beb2ea291ec 1380 writeAuthorizationCallback() {
boro 0:4beb2ea291ec 1381 }
boro 0:4beb2ea291ec 1382
boro 0:4beb2ea291ec 1383 public:
boro 0:4beb2ea291ec 1384 /**
boro 0:4beb2ea291ec 1385 * Set up the minimum security (mode and level) requirements for access to
boro 0:4beb2ea291ec 1386 * the characteristic's value attribute.
boro 0:4beb2ea291ec 1387 *
boro 0:4beb2ea291ec 1388 * @param[in] securityMode Can be one of encryption or signing, with or
boro 0:4beb2ea291ec 1389 * without protection for man in the middle attacks (MITM).
boro 0:4beb2ea291ec 1390 */
boro 0:4beb2ea291ec 1391 void requireSecurity(SecurityManager::SecurityMode_t securityMode)
boro 0:4beb2ea291ec 1392 {
boro 0:4beb2ea291ec 1393 _requiredSecurity = securityMode;
boro 0:4beb2ea291ec 1394 }
boro 0:4beb2ea291ec 1395
boro 0:4beb2ea291ec 1396 public:
boro 0:4beb2ea291ec 1397 /**
boro 0:4beb2ea291ec 1398 * Register a callback handling client's write requests or commands.
boro 0:4beb2ea291ec 1399 *
boro 0:4beb2ea291ec 1400 * The callback registered is invoked when the client attempts to write the
boro 0:4beb2ea291ec 1401 * characteristic value; the event handler can accept or reject the write
boro 0:4beb2ea291ec 1402 * request with the appropriate error code.
boro 0:4beb2ea291ec 1403 *
boro 0:4beb2ea291ec 1404 * @param[in] callback Event handler being registered.
boro 0:4beb2ea291ec 1405 */
boro 0:4beb2ea291ec 1406 void setWriteAuthorizationCallback(
boro 0:4beb2ea291ec 1407 void (*callback)(GattWriteAuthCallbackParams *)
boro 0:4beb2ea291ec 1408 ) {
boro 0:4beb2ea291ec 1409 writeAuthorizationCallback.attach(callback);
boro 0:4beb2ea291ec 1410 enabledWriteAuthorization = true;
boro 0:4beb2ea291ec 1411 }
boro 0:4beb2ea291ec 1412
boro 0:4beb2ea291ec 1413 /**
boro 0:4beb2ea291ec 1414 * Register a callback handling client's write requests or commands.
boro 0:4beb2ea291ec 1415 *
boro 0:4beb2ea291ec 1416 * The callback registered is invoked when the client attempts to write the
boro 0:4beb2ea291ec 1417 * characteristic value; the event handler can accept or reject the write
boro 0:4beb2ea291ec 1418 * request with the appropriate error code.
boro 0:4beb2ea291ec 1419 *
boro 0:4beb2ea291ec 1420 * @param[in] object Pointer to the object of a class defining the event
boro 0:4beb2ea291ec 1421 * handler (@p member). It must remain valid for the lifetime of the
boro 0:4beb2ea291ec 1422 * GattCharacteristic.
boro 0:4beb2ea291ec 1423 * @param[in] member The member function that handles the write event.
boro 0:4beb2ea291ec 1424 */
boro 0:4beb2ea291ec 1425 template <typename T>
boro 0:4beb2ea291ec 1426 void setWriteAuthorizationCallback(
boro 0:4beb2ea291ec 1427 T *object,
boro 0:4beb2ea291ec 1428 void (T::*member)(GattWriteAuthCallbackParams *)
boro 0:4beb2ea291ec 1429 ) {
boro 0:4beb2ea291ec 1430 writeAuthorizationCallback.attach(object, member);
boro 0:4beb2ea291ec 1431 enabledWriteAuthorization = true;
boro 0:4beb2ea291ec 1432 }
boro 0:4beb2ea291ec 1433
boro 0:4beb2ea291ec 1434 /**
boro 0:4beb2ea291ec 1435 * Register the read requests event handler.
boro 0:4beb2ea291ec 1436 *
boro 0:4beb2ea291ec 1437 * The callback registered is invoked when the client attempts to read the
boro 0:4beb2ea291ec 1438 * characteristic value; the event handler can accept or reject the read
boro 0:4beb2ea291ec 1439 * request with the appropriate error code. It can also set specific outgoing
boro 0:4beb2ea291ec 1440 * data.
boro 0:4beb2ea291ec 1441 *
boro 0:4beb2ea291ec 1442 * @param[in] callback Event handler being registered.
boro 0:4beb2ea291ec 1443 */
boro 0:4beb2ea291ec 1444 void setReadAuthorizationCallback(
boro 0:4beb2ea291ec 1445 void (*callback)(GattReadAuthCallbackParams *)
boro 0:4beb2ea291ec 1446 ) {
boro 0:4beb2ea291ec 1447 readAuthorizationCallback.attach(callback);
boro 0:4beb2ea291ec 1448 enabledReadAuthorization = true;
boro 0:4beb2ea291ec 1449 }
boro 0:4beb2ea291ec 1450
boro 0:4beb2ea291ec 1451 /**
boro 0:4beb2ea291ec 1452 * Register the read requests event handler.
boro 0:4beb2ea291ec 1453 *
boro 0:4beb2ea291ec 1454 * The callback registered is invoked when the client attempts to read the
boro 0:4beb2ea291ec 1455 * characteristic value; the event handler can accept or reject the read
boro 0:4beb2ea291ec 1456 * request with the appropriate error code. It can also set specific outgoing
boro 0:4beb2ea291ec 1457 * data.
boro 0:4beb2ea291ec 1458 *
boro 0:4beb2ea291ec 1459 * @param[in] object Pointer to the object of a class defining the event
boro 0:4beb2ea291ec 1460 * handler (@p member). It must remain valid for the lifetime of the
boro 0:4beb2ea291ec 1461 * GattCharacteristic.
boro 0:4beb2ea291ec 1462 * @param[in] member The member function that handles the read event.
boro 0:4beb2ea291ec 1463 */
boro 0:4beb2ea291ec 1464 template <typename T>
boro 0:4beb2ea291ec 1465 void setReadAuthorizationCallback(
boro 0:4beb2ea291ec 1466 T *object,
boro 0:4beb2ea291ec 1467 void (T::*member)(GattReadAuthCallbackParams *)
boro 0:4beb2ea291ec 1468 ) {
boro 0:4beb2ea291ec 1469 readAuthorizationCallback.attach(object, member);
boro 0:4beb2ea291ec 1470 enabledReadAuthorization = true;
boro 0:4beb2ea291ec 1471 }
boro 0:4beb2ea291ec 1472
boro 0:4beb2ea291ec 1473 /**
boro 0:4beb2ea291ec 1474 * Invoke the write authorization callback.
boro 0:4beb2ea291ec 1475 *
boro 0:4beb2ea291ec 1476 * This function is a helper that calls the registered write handler to
boro 0:4beb2ea291ec 1477 * determine the authorization reply for a write request.
boro 0:4beb2ea291ec 1478 *
boro 0:4beb2ea291ec 1479 * @important This function is not meant to be called by user code.
boro 0:4beb2ea291ec 1480 *
boro 0:4beb2ea291ec 1481 * @param[in] params Context of the write-auth request; it contains an
boro 0:4beb2ea291ec 1482 * out-parameter used as a reply.
boro 0:4beb2ea291ec 1483 *
boro 0:4beb2ea291ec 1484 * @return A GattAuthCallbackReply_t value indicating whether authorization
boro 0:4beb2ea291ec 1485 * is granted.
boro 0:4beb2ea291ec 1486 */
boro 0:4beb2ea291ec 1487 GattAuthCallbackReply_t authorizeWrite(GattWriteAuthCallbackParams *params)
boro 0:4beb2ea291ec 1488 {
boro 0:4beb2ea291ec 1489 if (!isWriteAuthorizationEnabled()) {
boro 0:4beb2ea291ec 1490 return AUTH_CALLBACK_REPLY_SUCCESS;
boro 0:4beb2ea291ec 1491 }
boro 0:4beb2ea291ec 1492
boro 0:4beb2ea291ec 1493 /* Initialized to no-error by default. */
boro 0:4beb2ea291ec 1494 params->authorizationReply = AUTH_CALLBACK_REPLY_SUCCESS;
boro 0:4beb2ea291ec 1495 writeAuthorizationCallback.call(params);
boro 0:4beb2ea291ec 1496 return params->authorizationReply;
boro 0:4beb2ea291ec 1497 }
boro 0:4beb2ea291ec 1498
boro 0:4beb2ea291ec 1499 /**
boro 0:4beb2ea291ec 1500 * Invoke the read authorization callback.
boro 0:4beb2ea291ec 1501 *
boro 0:4beb2ea291ec 1502 * This function is a helper that calls the registered read handler to
boro 0:4beb2ea291ec 1503 * determine the authorization reply for a read request.
boro 0:4beb2ea291ec 1504 *
boro 0:4beb2ea291ec 1505 * @important This function is not meant to be called by user code.
boro 0:4beb2ea291ec 1506 *
boro 0:4beb2ea291ec 1507 * @param[in] params Context of the read-auth request; it contains an
boro 0:4beb2ea291ec 1508 * out-parameter used as a reply and the handler can fill it with outgoing
boro 0:4beb2ea291ec 1509 * data.
boro 0:4beb2ea291ec 1510 *
boro 0:4beb2ea291ec 1511 * @return A GattAuthCallbackReply_t value indicating whether authorization
boro 0:4beb2ea291ec 1512 * is granted.
boro 0:4beb2ea291ec 1513 *
boro 0:4beb2ea291ec 1514 * @note If the read request is approved and params->data remains NULL, then
boro 0:4beb2ea291ec 1515 * the current characteristic value is used in the read response payload.
boro 0:4beb2ea291ec 1516 *
boro 0:4beb2ea291ec 1517 * @note If the read is approved, the event handler can specify an outgoing
boro 0:4beb2ea291ec 1518 * value directly with the help of the fields
boro 0:4beb2ea291ec 1519 * GattReadAuthCallbackParams::data and GattReadAuthCallbackParams::len.
boro 0:4beb2ea291ec 1520 */
boro 0:4beb2ea291ec 1521 GattAuthCallbackReply_t authorizeRead(GattReadAuthCallbackParams *params)
boro 0:4beb2ea291ec 1522 {
boro 0:4beb2ea291ec 1523 if (!isReadAuthorizationEnabled()) {
boro 0:4beb2ea291ec 1524 return AUTH_CALLBACK_REPLY_SUCCESS;
boro 0:4beb2ea291ec 1525 }
boro 0:4beb2ea291ec 1526
boro 0:4beb2ea291ec 1527 /* Initialized to no-error by default. */
boro 0:4beb2ea291ec 1528 params->authorizationReply = AUTH_CALLBACK_REPLY_SUCCESS;
boro 0:4beb2ea291ec 1529 readAuthorizationCallback.call(params);
boro 0:4beb2ea291ec 1530 return params->authorizationReply;
boro 0:4beb2ea291ec 1531 }
boro 0:4beb2ea291ec 1532
boro 0:4beb2ea291ec 1533 public:
boro 0:4beb2ea291ec 1534 /**
boro 0:4beb2ea291ec 1535 * Get the characteristic's value attribute.
boro 0:4beb2ea291ec 1536 *
boro 0:4beb2ea291ec 1537 * @return A reference to the characteristic's value attribute.
boro 0:4beb2ea291ec 1538 */
boro 0:4beb2ea291ec 1539 GattAttribute& getValueAttribute()
boro 0:4beb2ea291ec 1540 {
boro 0:4beb2ea291ec 1541 return _valueAttribute;
boro 0:4beb2ea291ec 1542 }
boro 0:4beb2ea291ec 1543
boro 0:4beb2ea291ec 1544 /**
boro 0:4beb2ea291ec 1545 * Get the characteristic's value attribute.
boro 0:4beb2ea291ec 1546 *
boro 0:4beb2ea291ec 1547 * @return A const reference to the characteristic's value attribute.
boro 0:4beb2ea291ec 1548 */
boro 0:4beb2ea291ec 1549 const GattAttribute& getValueAttribute() const
boro 0:4beb2ea291ec 1550 {
boro 0:4beb2ea291ec 1551 return _valueAttribute;
boro 0:4beb2ea291ec 1552 }
boro 0:4beb2ea291ec 1553
boro 0:4beb2ea291ec 1554 /**
boro 0:4beb2ea291ec 1555 * Get the characteristic's value attribute handle in the ATT table.
boro 0:4beb2ea291ec 1556 *
boro 0:4beb2ea291ec 1557 * @return The value attribute handle.
boro 0:4beb2ea291ec 1558 *
boro 0:4beb2ea291ec 1559 * @note The underlying BLE stack assigns the attribute handle when the
boro 0:4beb2ea291ec 1560 * enclosing service is added.
boro 0:4beb2ea291ec 1561 */
boro 0:4beb2ea291ec 1562 GattAttribute::Handle_t getValueHandle(void) const
boro 0:4beb2ea291ec 1563 {
boro 0:4beb2ea291ec 1564 return getValueAttribute().getHandle();
boro 0:4beb2ea291ec 1565 }
boro 0:4beb2ea291ec 1566
boro 0:4beb2ea291ec 1567 /**
boro 0:4beb2ea291ec 1568 * Get the characteristic's properties.
boro 0:4beb2ea291ec 1569 *
boro 0:4beb2ea291ec 1570 * @note Refer to GattCharacteristic::Properties_t.
boro 0:4beb2ea291ec 1571 *
boro 0:4beb2ea291ec 1572 * @return The characteristic's properties.
boro 0:4beb2ea291ec 1573 */
boro 0:4beb2ea291ec 1574 uint8_t getProperties(void) const
boro 0:4beb2ea291ec 1575 {
boro 0:4beb2ea291ec 1576 return _properties;
boro 0:4beb2ea291ec 1577 }
boro 0:4beb2ea291ec 1578
boro 0:4beb2ea291ec 1579 /**
boro 0:4beb2ea291ec 1580 * Get the characteristic's required security.
boro 0:4beb2ea291ec 1581 *
boro 0:4beb2ea291ec 1582 * @return The characteristic's required security.
boro 0:4beb2ea291ec 1583 */
boro 0:4beb2ea291ec 1584 SecurityManager::SecurityMode_t getRequiredSecurity() const
boro 0:4beb2ea291ec 1585 {
boro 0:4beb2ea291ec 1586 return _requiredSecurity;
boro 0:4beb2ea291ec 1587 }
boro 0:4beb2ea291ec 1588
boro 0:4beb2ea291ec 1589 /**
boro 0:4beb2ea291ec 1590 * Get the total number of descriptors within this characteristic.
boro 0:4beb2ea291ec 1591 *
boro 0:4beb2ea291ec 1592 * @return The total number of descriptors.
boro 0:4beb2ea291ec 1593 */
boro 0:4beb2ea291ec 1594 uint8_t getDescriptorCount(void) const
boro 0:4beb2ea291ec 1595 {
boro 0:4beb2ea291ec 1596 return _descriptorCount;
boro 0:4beb2ea291ec 1597 }
boro 0:4beb2ea291ec 1598
boro 0:4beb2ea291ec 1599 /**
boro 0:4beb2ea291ec 1600 * Check whether read authorization is enabled.
boro 0:4beb2ea291ec 1601 *
boro 0:4beb2ea291ec 1602 * Read authorization is enabled when a read authorization event handler is
boro 0:4beb2ea291ec 1603 * set up.
boro 0:4beb2ea291ec 1604 *
boro 0:4beb2ea291ec 1605 * @return true if read authorization is enabled and false otherwise.
boro 0:4beb2ea291ec 1606 */
boro 0:4beb2ea291ec 1607 bool isReadAuthorizationEnabled() const
boro 0:4beb2ea291ec 1608 {
boro 0:4beb2ea291ec 1609 return enabledReadAuthorization;
boro 0:4beb2ea291ec 1610 }
boro 0:4beb2ea291ec 1611
boro 0:4beb2ea291ec 1612 /**
boro 0:4beb2ea291ec 1613 * Check whether write authorization is enabled.
boro 0:4beb2ea291ec 1614 *
boro 0:4beb2ea291ec 1615 * Write authorization is enabled when a write authorization event handler is
boro 0:4beb2ea291ec 1616 * set up.
boro 0:4beb2ea291ec 1617 *
boro 0:4beb2ea291ec 1618 * @return true if write authorization is enabled, false otherwise.
boro 0:4beb2ea291ec 1619 */
boro 0:4beb2ea291ec 1620 bool isWriteAuthorizationEnabled() const
boro 0:4beb2ea291ec 1621 {
boro 0:4beb2ea291ec 1622 return enabledWriteAuthorization;
boro 0:4beb2ea291ec 1623 }
boro 0:4beb2ea291ec 1624
boro 0:4beb2ea291ec 1625 /**
boro 0:4beb2ea291ec 1626 * Get this characteristic's descriptor at a specific index.
boro 0:4beb2ea291ec 1627 *
boro 0:4beb2ea291ec 1628 * @param[in] index The index of the descriptor to get.
boro 0:4beb2ea291ec 1629 *
boro 0:4beb2ea291ec 1630 * @return A pointer the requested descriptor if @p index is within the
boro 0:4beb2ea291ec 1631 * range of the descriptor array or NULL otherwise.
boro 0:4beb2ea291ec 1632 */
boro 0:4beb2ea291ec 1633 GattAttribute *getDescriptor(uint8_t index)
boro 0:4beb2ea291ec 1634 {
boro 0:4beb2ea291ec 1635 if (index = _descriptorCount) {
boro 0:4beb2ea291ec 1636 return NULL;
boro 0:4beb2ea291ec 1637 }
boro 0:4beb2ea291ec 1638
boro 0:4beb2ea291ec 1639 return _descriptors[index];
boro 0:4beb2ea291ec 1640 }
boro 0:4beb2ea291ec 1641
boro 0:4beb2ea291ec 1642 private:
boro 0:4beb2ea291ec 1643 /**
boro 0:4beb2ea291ec 1644 * Attribute that contains the actual value of this characteristic.
boro 0:4beb2ea291ec 1645 */
boro 0:4beb2ea291ec 1646 GattAttribute _valueAttribute;
boro 0:4beb2ea291ec 1647
boro 0:4beb2ea291ec 1648 /**
boro 0:4beb2ea291ec 1649 * The characteristic's properties. Refer to
boro 0:4beb2ea291ec 1650 * GattCharacteristic::Properties_t.
boro 0:4beb2ea291ec 1651 */
boro 0:4beb2ea291ec 1652 uint8_t _properties;
boro 0:4beb2ea291ec 1653
boro 0:4beb2ea291ec 1654 /**
boro 0:4beb2ea291ec 1655 * The characteristic's required security.
boro 0:4beb2ea291ec 1656 */
boro 0:4beb2ea291ec 1657 SecurityManager::SecurityMode_t _requiredSecurity;
boro 0:4beb2ea291ec 1658
boro 0:4beb2ea291ec 1659 /**
boro 0:4beb2ea291ec 1660 * The characteristic's descriptor attributes.
boro 0:4beb2ea291ec 1661 */
boro 0:4beb2ea291ec 1662 GattAttribute **_descriptors;
boro 0:4beb2ea291ec 1663
boro 0:4beb2ea291ec 1664 /**
boro 0:4beb2ea291ec 1665 * The number of descriptors in this characteristic.
boro 0:4beb2ea291ec 1666 */
boro 0:4beb2ea291ec 1667 uint8_t _descriptorCount;
boro 0:4beb2ea291ec 1668
boro 0:4beb2ea291ec 1669 /**
boro 0:4beb2ea291ec 1670 * Whether read authorization is enabled.
boro 0:4beb2ea291ec 1671 */
boro 0:4beb2ea291ec 1672 bool enabledReadAuthorization;
boro 0:4beb2ea291ec 1673
boro 0:4beb2ea291ec 1674 /**
boro 0:4beb2ea291ec 1675 * Whether write authorization is enabled.
boro 0:4beb2ea291ec 1676 */
boro 0:4beb2ea291ec 1677 bool enabledWriteAuthorization;
boro 0:4beb2ea291ec 1678
boro 0:4beb2ea291ec 1679 /**
boro 0:4beb2ea291ec 1680 * The registered callback handler for read authorization reply.
boro 0:4beb2ea291ec 1681 */
boro 0:4beb2ea291ec 1682 FunctionPointerWithContext<GattReadAuthCallbackParams *>
boro 0:4beb2ea291ec 1683 readAuthorizationCallback;
boro 0:4beb2ea291ec 1684
boro 0:4beb2ea291ec 1685 /**
boro 0:4beb2ea291ec 1686 * The registered callback handler for write authorization reply.
boro 0:4beb2ea291ec 1687 */
boro 0:4beb2ea291ec 1688 FunctionPointerWithContext<GattWriteAuthCallbackParams *>
boro 0:4beb2ea291ec 1689 writeAuthorizationCallback;
boro 0:4beb2ea291ec 1690
boro 0:4beb2ea291ec 1691 private:
boro 0:4beb2ea291ec 1692 /* Disallow copy and assignment. */
boro 0:4beb2ea291ec 1693 GattCharacteristic(const GattCharacteristic &);
boro 0:4beb2ea291ec 1694 GattCharacteristic& operator=(const GattCharacteristic &);
boro 0:4beb2ea291ec 1695 };
boro 0:4beb2ea291ec 1696
boro 0:4beb2ea291ec 1697 /**
boro 0:4beb2ea291ec 1698 * Helper class that represents a read only GattCharacteristic.
boro 0:4beb2ea291ec 1699 */
boro 0:4beb2ea291ec 1700 template <typename T>
boro 0:4beb2ea291ec 1701 class ReadOnlyGattCharacteristic : public GattCharacteristic {
boro 0:4beb2ea291ec 1702 public:
boro 0:4beb2ea291ec 1703 /**
boro 0:4beb2ea291ec 1704 * Construct a ReadOnlyGattCharacteristic.
boro 0:4beb2ea291ec 1705 *
boro 0:4beb2ea291ec 1706 * @param[in] uuid The characteristic's UUID.
boro 0:4beb2ea291ec 1707 * @param[in] valuePtr Pointer to the characteristic's initial value. The
boro 0:4beb2ea291ec 1708 * pointer is reinterpreted as a pointer to an uint8_t buffer.
boro 0:4beb2ea291ec 1709 * @param[in] additionalProperties Additional characteristic properties. By
boro 0:4beb2ea291ec 1710 * default, the properties are set to
boro 0:4beb2ea291ec 1711 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
boro 0:4beb2ea291ec 1712 * @param[in] descriptors An array of pointers to descriptors to be added
boro 0:4beb2ea291ec 1713 * to the new characteristic.
boro 0:4beb2ea291ec 1714 * @param[in] numDescriptors The total number of descriptors in @p
boro 0:4beb2ea291ec 1715 * descriptors.
boro 0:4beb2ea291ec 1716 *
boro 0:4beb2ea291ec 1717 * @note Instances of ReadOnlyGattCharacteristic have a fixed length
boro 0:4beb2ea291ec 1718 * attribute value that equals sizeof(T). For a variable length alternative,
boro 0:4beb2ea291ec 1719 * use GattCharacteristic directly.
boro 0:4beb2ea291ec 1720 */
boro 0:4beb2ea291ec 1721 ReadOnlyGattCharacteristic<T>(
boro 0:4beb2ea291ec 1722 const UUID &uuid,
boro 0:4beb2ea291ec 1723 T *valuePtr,
boro 0:4beb2ea291ec 1724 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
boro 0:4beb2ea291ec 1725 GattAttribute *descriptors[] = NULL,
boro 0:4beb2ea291ec 1726 unsigned numDescriptors = 0
boro 0:4beb2ea291ec 1727 ) : GattCharacteristic(
boro 0:4beb2ea291ec 1728 uuid,
boro 0:4beb2ea291ec 1729 reinterpret_cast<uint8_t *>(valuePtr),
boro 0:4beb2ea291ec 1730 sizeof(T),
boro 0:4beb2ea291ec 1731 sizeof(T),
boro 0:4beb2ea291ec 1732 BLE_GATT_CHAR_PROPERTIES_READ | additionalProperties,
boro 0:4beb2ea291ec 1733 descriptors,
boro 0:4beb2ea291ec 1734 numDescriptors,
boro 0:4beb2ea291ec 1735 false
boro 0:4beb2ea291ec 1736 ) {
boro 0:4beb2ea291ec 1737 }
boro 0:4beb2ea291ec 1738 };
boro 0:4beb2ea291ec 1739
boro 0:4beb2ea291ec 1740 /**
boro 0:4beb2ea291ec 1741 * Helper class that represents a write only GattCharacteristic.
boro 0:4beb2ea291ec 1742 */
boro 0:4beb2ea291ec 1743 template <typename T>
boro 0:4beb2ea291ec 1744 class WriteOnlyGattCharacteristic : public GattCharacteristic {
boro 0:4beb2ea291ec 1745 public:
boro 0:4beb2ea291ec 1746 /**
boro 0:4beb2ea291ec 1747 * Construct a WriteOnlyGattCharacteristic.
boro 0:4beb2ea291ec 1748 *
boro 0:4beb2ea291ec 1749 * @param[in] uuid The characteristic's UUID.
boro 0:4beb2ea291ec 1750 * @param[in] valuePtr Pointer to the characteristic's initial value. The
boro 0:4beb2ea291ec 1751 * pointer is reinterpreted as a pointer to an uint8_t buffer.
boro 0:4beb2ea291ec 1752 * @param[in] additionalProperties Additional characteristic properties. By
boro 0:4beb2ea291ec 1753 * default, the properties are set to
boro 0:4beb2ea291ec 1754 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE.
boro 0:4beb2ea291ec 1755 * @param[in] descriptors An array of pointers to descriptors to be added to
boro 0:4beb2ea291ec 1756 * the new characteristic.
boro 0:4beb2ea291ec 1757 * @param[in] numDescriptors The total number of descriptors in @p
boro 0:4beb2ea291ec 1758 * descriptors.
boro 0:4beb2ea291ec 1759 *
boro 0:4beb2ea291ec 1760 * @note Instances of WriteOnlyGattCharacteristic have variable length
boro 0:4beb2ea291ec 1761 * attribute value with maximum size equal to sizeof(T). For a fixed length
boro 0:4beb2ea291ec 1762 * alternative, use GattCharacteristic directly.
boro 0:4beb2ea291ec 1763 */
boro 0:4beb2ea291ec 1764 WriteOnlyGattCharacteristic<T>(
boro 0:4beb2ea291ec 1765 const UUID &uuid,
boro 0:4beb2ea291ec 1766 T *valuePtr,
boro 0:4beb2ea291ec 1767 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
boro 0:4beb2ea291ec 1768 GattAttribute *descriptors[] = NULL,
boro 0:4beb2ea291ec 1769 unsigned numDescriptors = 0
boro 0:4beb2ea291ec 1770 ) : GattCharacteristic(
boro 0:4beb2ea291ec 1771 uuid,
boro 0:4beb2ea291ec 1772 reinterpret_cast<uint8_t *>(valuePtr),
boro 0:4beb2ea291ec 1773 sizeof(T),
boro 0:4beb2ea291ec 1774 sizeof(T),
boro 0:4beb2ea291ec 1775 BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
boro 0:4beb2ea291ec 1776 descriptors,
boro 0:4beb2ea291ec 1777 numDescriptors
boro 0:4beb2ea291ec 1778 ) {
boro 0:4beb2ea291ec 1779 }
boro 0:4beb2ea291ec 1780 };
boro 0:4beb2ea291ec 1781
boro 0:4beb2ea291ec 1782 /**
boro 0:4beb2ea291ec 1783 * Helper class that represents a readable and writable GattCharacteristic.
boro 0:4beb2ea291ec 1784 */
boro 0:4beb2ea291ec 1785 template <typename T>
boro 0:4beb2ea291ec 1786 class ReadWriteGattCharacteristic : public GattCharacteristic {
boro 0:4beb2ea291ec 1787 public:
boro 0:4beb2ea291ec 1788 /**
boro 0:4beb2ea291ec 1789 * Construct a ReadWriteGattCharacteristic.
boro 0:4beb2ea291ec 1790 *
boro 0:4beb2ea291ec 1791 * @param[in] uuid The characteristic's UUID.
boro 0:4beb2ea291ec 1792 * @param[in] valuePtr Pointer to the characteristic's initial value. The
boro 0:4beb2ea291ec 1793 * pointer is reinterpreted as a pointer to an uint8_t buffer.
boro 0:4beb2ea291ec 1794 * @param[in] additionalProperties Additional characteristic properties. By
boro 0:4beb2ea291ec 1795 * default, the properties are set to
boro 0:4beb2ea291ec 1796 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE and
boro 0:4beb2ea291ec 1797 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
boro 0:4beb2ea291ec 1798 * @param[in] descriptors An array of pointers to descriptors to be added to
boro 0:4beb2ea291ec 1799 * the new characteristic.
boro 0:4beb2ea291ec 1800 * @param[in] numDescriptors The total number of descriptors in @p descriptors.
boro 0:4beb2ea291ec 1801 *
boro 0:4beb2ea291ec 1802 * @note Instances of ReadWriteGattCharacteristic have variable length
boro 0:4beb2ea291ec 1803 * attribute value with maximum size equal to sizeof(T). For a fixed length
boro 0:4beb2ea291ec 1804 * alternative, use GattCharacteristic directly.
boro 0:4beb2ea291ec 1805 */
boro 0:4beb2ea291ec 1806 ReadWriteGattCharacteristic<T>(
boro 0:4beb2ea291ec 1807 const UUID &uuid,
boro 0:4beb2ea291ec 1808 T *valuePtr,
boro 0:4beb2ea291ec 1809 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
boro 0:4beb2ea291ec 1810 GattAttribute *descriptors[] = NULL,
boro 0:4beb2ea291ec 1811 unsigned numDescriptors = 0
boro 0:4beb2ea291ec 1812 ) : GattCharacteristic(
boro 0:4beb2ea291ec 1813 uuid,
boro 0:4beb2ea291ec 1814 reinterpret_cast<uint8_t *>(valuePtr),
boro 0:4beb2ea291ec 1815 sizeof(T),
boro 0:4beb2ea291ec 1816 sizeof(T),
boro 0:4beb2ea291ec 1817 BLE_GATT_CHAR_PROPERTIES_READ | BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
boro 0:4beb2ea291ec 1818 descriptors,
boro 0:4beb2ea291ec 1819 numDescriptors
boro 0:4beb2ea291ec 1820 ) {
boro 0:4beb2ea291ec 1821 }
boro 0:4beb2ea291ec 1822 };
boro 0:4beb2ea291ec 1823
boro 0:4beb2ea291ec 1824 /**
boro 0:4beb2ea291ec 1825 * Helper class that represents a write-only GattCharacteristic with an array
boro 0:4beb2ea291ec 1826 * value.
boro 0:4beb2ea291ec 1827 */
boro 0:4beb2ea291ec 1828 template <typename T, unsigned NUM_ELEMENTS>
boro 0:4beb2ea291ec 1829 class WriteOnlyArrayGattCharacteristic : public GattCharacteristic {
boro 0:4beb2ea291ec 1830 public:
boro 0:4beb2ea291ec 1831 /**
boro 0:4beb2ea291ec 1832 * Construct a WriteOnlyGattCharacteristic.
boro 0:4beb2ea291ec 1833 *
boro 0:4beb2ea291ec 1834 * @param[in] uuid The characteristic's UUID.
boro 0:4beb2ea291ec 1835 * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
boro 0:4beb2ea291ec 1836 * the characteristic's initial value. The pointer is reinterpreted as a
boro 0:4beb2ea291ec 1837 * pointer to an uint8_t buffer.
boro 0:4beb2ea291ec 1838 * @param[in] additionalProperties Additional characteristic properties. By
boro 0:4beb2ea291ec 1839 * default, the properties are set to
boro 0:4beb2ea291ec 1840 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE.
boro 0:4beb2ea291ec 1841 * @param[in] descriptors An array of pointers to descriptors to be added to
boro 0:4beb2ea291ec 1842 * the new characteristic.
boro 0:4beb2ea291ec 1843 * @param[in] numDescriptors The total number of descriptors in @p descriptors.
boro 0:4beb2ea291ec 1844 *
boro 0:4beb2ea291ec 1845 * @note Instances of WriteOnlyGattCharacteristic have variable length
boro 0:4beb2ea291ec 1846 * attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
boro 0:4beb2ea291ec 1847 * For a fixed length alternative, use GattCharacteristic directly.
boro 0:4beb2ea291ec 1848 */
boro 0:4beb2ea291ec 1849 WriteOnlyArrayGattCharacteristic<T, NUM_ELEMENTS>(
boro 0:4beb2ea291ec 1850 const UUID &uuid,
boro 0:4beb2ea291ec 1851 T valuePtr[NUM_ELEMENTS],
boro 0:4beb2ea291ec 1852 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
boro 0:4beb2ea291ec 1853 GattAttribute *descriptors[] = NULL,
boro 0:4beb2ea291ec 1854 unsigned numDescriptors = 0
boro 0:4beb2ea291ec 1855 ) : GattCharacteristic(
boro 0:4beb2ea291ec 1856 uuid,
boro 0:4beb2ea291ec 1857 reinterpret_cast<uint8_t *>(valuePtr),
boro 0:4beb2ea291ec 1858 sizeof(T) * NUM_ELEMENTS,
boro 0:4beb2ea291ec 1859 sizeof(T) * NUM_ELEMENTS,
boro 0:4beb2ea291ec 1860 BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
boro 0:4beb2ea291ec 1861 descriptors,
boro 0:4beb2ea291ec 1862 numDescriptors
boro 0:4beb2ea291ec 1863 ) {
boro 0:4beb2ea291ec 1864 }
boro 0:4beb2ea291ec 1865 };
boro 0:4beb2ea291ec 1866
boro 0:4beb2ea291ec 1867 /**
boro 0:4beb2ea291ec 1868 * Helper class that represents a read-only GattCharacteristic with an array
boro 0:4beb2ea291ec 1869 * value.
boro 0:4beb2ea291ec 1870 */
boro 0:4beb2ea291ec 1871 template <typename T, unsigned NUM_ELEMENTS>
boro 0:4beb2ea291ec 1872 class ReadOnlyArrayGattCharacteristic : public GattCharacteristic {
boro 0:4beb2ea291ec 1873 public:
boro 0:4beb2ea291ec 1874 /**
boro 0:4beb2ea291ec 1875 * Construct a ReadOnlyGattCharacteristic.
boro 0:4beb2ea291ec 1876 *
boro 0:4beb2ea291ec 1877 * @param[in] uuid The characteristic's UUID.
boro 0:4beb2ea291ec 1878 * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
boro 0:4beb2ea291ec 1879 * the characteristic's initial value. The pointer is reinterpreted as a
boro 0:4beb2ea291ec 1880 * pointer to an uint8_t buffer.
boro 0:4beb2ea291ec 1881 * @param[in] additionalProperties Additional characteristic properties. By
boro 0:4beb2ea291ec 1882 * default, the properties are set to
boro 0:4beb2ea291ec 1883 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
boro 0:4beb2ea291ec 1884 * @param[in] descriptors An array of pointers to descriptors to be added to
boro 0:4beb2ea291ec 1885 * the new characteristic.
boro 0:4beb2ea291ec 1886 * @param[in] numDescriptors The total number of descriptors in @p
boro 0:4beb2ea291ec 1887 * descriptors.
boro 0:4beb2ea291ec 1888 *
boro 0:4beb2ea291ec 1889 * @note Instances of ReadOnlyGattCharacteristic have fixed length
boro 0:4beb2ea291ec 1890 * attribute value that equals sizeof(T) * NUM_ELEMENTS. For a variable
boro 0:4beb2ea291ec 1891 * length alternative, use GattCharacteristic directly.
boro 0:4beb2ea291ec 1892 */
boro 0:4beb2ea291ec 1893 ReadOnlyArrayGattCharacteristic<T, NUM_ELEMENTS>(
boro 0:4beb2ea291ec 1894 const UUID &uuid,
boro 0:4beb2ea291ec 1895 T valuePtr[NUM_ELEMENTS],
boro 0:4beb2ea291ec 1896 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
boro 0:4beb2ea291ec 1897 GattAttribute *descriptors[] = NULL,
boro 0:4beb2ea291ec 1898 unsigned numDescriptors = 0
boro 0:4beb2ea291ec 1899 ) : GattCharacteristic(
boro 0:4beb2ea291ec 1900 uuid,
boro 0:4beb2ea291ec 1901 reinterpret_cast<uint8_t *>(valuePtr),
boro 0:4beb2ea291ec 1902 sizeof(T) * NUM_ELEMENTS,
boro 0:4beb2ea291ec 1903 sizeof(T) * NUM_ELEMENTS,
boro 0:4beb2ea291ec 1904 BLE_GATT_CHAR_PROPERTIES_READ | additionalProperties,
boro 0:4beb2ea291ec 1905 descriptors,
boro 0:4beb2ea291ec 1906 numDescriptors,
boro 0:4beb2ea291ec 1907 false
boro 0:4beb2ea291ec 1908 ) {
boro 0:4beb2ea291ec 1909 }
boro 0:4beb2ea291ec 1910 };
boro 0:4beb2ea291ec 1911
boro 0:4beb2ea291ec 1912 /**
boro 0:4beb2ea291ec 1913 * Helper class that represents a readable and writable GattCharacteristic with
boro 0:4beb2ea291ec 1914 * an array value.
boro 0:4beb2ea291ec 1915 */
boro 0:4beb2ea291ec 1916 template <typename T, unsigned NUM_ELEMENTS>
boro 0:4beb2ea291ec 1917 class ReadWriteArrayGattCharacteristic : public GattCharacteristic {
boro 0:4beb2ea291ec 1918 public:
boro 0:4beb2ea291ec 1919 /**
boro 0:4beb2ea291ec 1920 * Construct a ReadWriteGattCharacteristic.
boro 0:4beb2ea291ec 1921 *
boro 0:4beb2ea291ec 1922 * @param[in] uuid The characteristic's UUID.
boro 0:4beb2ea291ec 1923 * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
boro 0:4beb2ea291ec 1924 * the characteristic's initial value. The pointer is reinterpreted as a
boro 0:4beb2ea291ec 1925 * pointer to an uint8_t buffer.
boro 0:4beb2ea291ec 1926 * @param[in] additionalProperties Additional characteristic properties. By
boro 0:4beb2ea291ec 1927 * default, the properties are set to
boro 0:4beb2ea291ec 1928 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE |
boro 0:4beb2ea291ec 1929 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
boro 0:4beb2ea291ec 1930 * @param[in] descriptors An array of pointers to descriptors to be added to
boro 0:4beb2ea291ec 1931 * the new characteristic.
boro 0:4beb2ea291ec 1932 * @param[in] numDescriptors The total number of descriptors in @p descriptors.
boro 0:4beb2ea291ec 1933 *
boro 0:4beb2ea291ec 1934 * @note Instances of ReadWriteGattCharacteristic have variable length
boro 0:4beb2ea291ec 1935 * attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
boro 0:4beb2ea291ec 1936 * For a fixed length alternative, use GattCharacteristic directly.
boro 0:4beb2ea291ec 1937 */
boro 0:4beb2ea291ec 1938 ReadWriteArrayGattCharacteristic<T, NUM_ELEMENTS>(
boro 0:4beb2ea291ec 1939 const UUID &uuid,
boro 0:4beb2ea291ec 1940 T valuePtr[NUM_ELEMENTS],
boro 0:4beb2ea291ec 1941 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
boro 0:4beb2ea291ec 1942 GattAttribute *descriptors[] = NULL,
boro 0:4beb2ea291ec 1943 unsigned numDescriptors = 0
boro 0:4beb2ea291ec 1944 ) : GattCharacteristic(
boro 0:4beb2ea291ec 1945 uuid,
boro 0:4beb2ea291ec 1946 reinterpret_cast<uint8_t *>(valuePtr),
boro 0:4beb2ea291ec 1947 sizeof(T) * NUM_ELEMENTS,
boro 0:4beb2ea291ec 1948 sizeof(T) * NUM_ELEMENTS,
boro 0:4beb2ea291ec 1949 BLE_GATT_CHAR_PROPERTIES_READ | BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
boro 0:4beb2ea291ec 1950 descriptors,
boro 0:4beb2ea291ec 1951 numDescriptors
boro 0:4beb2ea291ec 1952 ) {
boro 0:4beb2ea291ec 1953 }
boro 0:4beb2ea291ec 1954 };
boro 0:4beb2ea291ec 1955
boro 0:4beb2ea291ec 1956 /**
boro 0:4beb2ea291ec 1957 * @}
boro 0:4beb2ea291ec 1958 * @}
boro 0:4beb2ea291ec 1959 * @}
boro 0:4beb2ea291ec 1960 */
boro 0:4beb2ea291ec 1961
boro 0:4beb2ea291ec 1962 #endif /* ifndef __GATT_CHARACTERISTIC_H__ */