Mbed OS Reference
Loading...
Searching...
No Matches
gatt/GattCharacteristic.h
1/* mbed Microcontroller Library
2 * Copyright (c) 2006-2020 ARM Limited
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef __GATT_CHARACTERISTIC_H__
20#define __GATT_CHARACTERISTIC_H__
21
23
24#include "ble/gatt/GattAttribute.h"
25#include "ble/gatt/GattCallbackParamTypes.h"
26
27// Forward declare ble::impl::GattServer
28namespace ble {
29
30#if !defined(DOXYGEN_ONLY)
31namespace impl {
32class GattServer;
33}
34#endif // !defined(DOXYGEN_ONLY)
35}
36
37/**
38 * @addtogroup ble
39 * @{
40 * @addtogroup gatt
41 * @{
42 * @addtogroup server
43 * @{
44 */
45
46/**
47 * Representation of a GattServer characteristic.
48 *
49 * A characteristic is a typed value enclosed in a GATT service (GattService).
50 *
51 * @par Type
52 *
53 * The type of the value defines the purpose of the characteristic, and a
54 * UUID represents it. Standard characteristic types may be consulted at
55 * https://www.bluetooth.com/specifications/gatt/characteristics
56 *
57 * @par Supported operations
58 * A set of properties define what client operations the characteristic
59 * supports. See GattServer::Properties_t
60 *
61 * @par Descriptors
62 *
63 * Additional information, such as the unit of the characteristic value, a
64 * description string or a client control point, can be added to the
65 * characteristic.
66 *
67 * See BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] - 3.3.1.1
68 *
69 * One of the most important types of descriptor is the Client Characteristic
70 * Configuration Descriptor (CCCD) that must be present if the characteristic
71 * properties allow a client to subscribe to updates of the characteristic
72 * value.
73 *
74 * @par Characteristic breakdown
75 *
76 * A characteristic is composed of several GATT attributes (GattAttribute):
77 * - Characteristic declaration: It contains the properties of the
78 * characteristic, its type and the handle of its value.
79 * - Characteristic value: The value of the characteristic.
80 * - Descriptors: A single GATT attribute stores each descriptor.
81 *
82 * When the GattService containing the characteristic is registered in the
83 * GattServer, a unique attribute handle is assigned to the various attributes
84 * of the characteristic. Clients use this handle to interact with the
85 * characteristic. This handle is used locally in GattServer APIs.
86 *
87 * @par Security requirements
88 *
89 * Verification of security requirements happens whenever a client request to
90 * read the characteristic; write it or even register to its updates. Different
91 * requirements may be defined for these three type of operation. As an example:
92 * it is possible to define a characteristic that do not require security to be
93 * read and require an authenticated link to be written.
94 *
95 * By default all security requirements are set to att_security_requirement_t::NONE
96 * except if the characteristic supports signed write; in such case the security
97 * requirement for write operations is set to att_security_requirement_t::UNAUTHENTICATED.
98 *
99 * @note If a peer uses an operation that is not set in the characteristic
100 * properties then the request request is discarded regardless of the security
101 * requirements and current security level. The only exception being signed
102 * write: signed write are converted into regular write without response if
103 * the link is encrypted.
104 */
106public:
107
108 /*
109 * Enumeration of characteristic UUID defined by the Bluetooth body.
110 */
111 enum {
112 /**
113 * Not used in actual BLE service.
114 */
116
117 /**
118 * Not used in actual BLE service.
119 */
121
122 /**
123 * Not used in actual BLE service.
124 */
126
127 /**
128 * Not used in actual BLE service.
129 */
131
132 /**
133 * Not used as a characteristic UUID.
134 */
136
137 /**
138 * Not used as a characteristic UUID.
139 */
141
142 /**
143 * Control point of the Immediate Alert service that allows the client to
144 * command the server to alert to a given level.
145 */
147
148 /**
149 * Control point of the Alert Notification service that allows the client
150 * finely tune the notification configuration.
151 */
153
154 /**
155 * Part of the Alert Notification service, which exposes the count of
156 * unread alert events existing in the server.
157 */
159
160 /**
161 * Characteristic of the Battery service, which exposes the current
162 * battery level as a percentage.
163 */
165
166 /**
167 * Describe the features supported by the blood pressure sensor exposed
168 * by the Blood Pressure service.
169 */
171
172 /**
173 * Characteristic of the Blood Pressure service that exposes the
174 * measurement of the blood sensor.
175 */
177
178 /**
179 * Characteristic of the Heart Rate service that indicate the intended
180 * location of the heart rate monitor.
181 */
183
184 /**
185 * Part of the Human Interface Device service.
186 */
188
189 /**
190 * Part of the Human Interface Device service.
191 */
193
194 /**
195 * Part of the Human Interface Device service.
196 */
198
199 /**
200 * Characteristic of the Current Time service that contains the current
201 * time.
202 */
204
205 /**
206 * Not used in a service as a characteristic.
207 */
209
210 /**
211 * Not used in a service as a characteristic.
212 */
214
215 /**
216 * Not used in a service as a characteristic.
217 */
219
220 /**
221 * Not used in a service as a characteristic.
222 */
224
225 /**
226 * Not used in a service as a characteristic.
227 */
229
230 /**
231 * Characteristic of the Device Information Service that contains a
232 * UTF8 string representing the firmware revision for the firmware within
233 * the device.
234 */
236
237 /**
238 * Characteristic of the Glucose service that exposes features supported
239 * by the server.
240 */
242
243 /**
244 * Characteristic of the Glucose service that exposes glucose
245 * measurements.
246 */
248
249 /**
250 * Characteristic of the Glucose service that sends additional
251 * information related to the glucose measurements.
252 */
254
255 /**
256 * Characteristic of the Device Information Service that contains a
257 * UTF8 string representing the hardware revision of the device.
258 */
260
261 /**
262 * Characteristic of the Heart Rate service used by the client to control
263 * the service behavior.
264 */
266
267 /**
268 * Characteristic of the Heart Rate that sends heart rate measurements to
269 * registered clients.
270 */
272
273 /**
274 * Part of the Human Interface Device service.
275 */
277
278 /**
279 * Part of the Human Interface Device service.
280 */
282
283 /**
284 * Characteristic of the Environmental Sensing service, which exposes
285 * humidity measurements.
286 */
288
289 /**
290 * Characteristic of the Device Information Service, which exposes
291 * various regulatory or certification compliance items to which the
292 * device claims adherence.
293 */
295
296 /**
297 * Characteristic of the Blood Pressure service, which exposes intermediate
298 * cuff pressure measurements.
299 */
301
302 /**
303 * Characteristic of the Health Thermometer service that sends intermediate
304 * temperature values while the measurement is in progress.
305 */
307
308 /**
309 * Characteristic of the current Time service that exposes information
310 * about the local time.
311 */
313
314 /**
315 * Characteristic of the Device Information Service that contains a
316 * UTF8 string representing the manufacturer name of the device.
317 */
319
320 /**
321 * Characteristic of the Health Thermometer service that exposes the
322 * interval time between two measurements.
323 */
325
326 /**
327 * Characteristic of the Device Information Service that contains a
328 * UTF8 string representing the model number of the device assigned by
329 * the vendor.
330 */
332
333 /**
334 * Characteristic of the Alert Notification Service that shows how many
335 * numbers of unread alerts exist in the specific category in the device.
336 */
338
339 /**
340 * Characteristic of the Alert Notification Service that defines the
341 * category of the alert and how many new alerts of that category have
342 * occurred in the server.
343 */
345
346 /**
347 * Characteristic of the Device Information Service; it is a set of
348 * values used to create a device ID that is unique for this device.
349 */
351
352 /**
353 * Characteristic of the Environmental Sensing Service that exposes the
354 * pressure measured.
355 */
357
358 /**
359 * Part of the Human Interface Device service.
360 */
362
363 /**
364 * Pulse Oxymeter, Glucose and Continuous Glucose Monitoring services
365 * use this control point to provide basic management of the patient
366 * record database.
367 */
369
370 /**
371 * Characteristic of the Current Time service that exposes information
372 * related to the current time served (accuracy, source, hours since
373 * update and so on).
374 */
376
377 /**
378 * Part of the Human Interface Device service.
379 */
381
382 /**
383 * Part of the Human Interface Device service.
384 */
386
387 /**
388 * Characteristic of the Phone Alert Status service that allows a client
389 * to configure operating mode.
390 */
392
393 /**
394 * Characteristic of the Phone Alert Status service that returns the
395 * ringer setting when read.
396 */
398
399 /**
400 * Characteristic of the Scan Parameter service that stores the client's
401 * scan parameters (scan interval and scan window).
402 */
404
405 /**
406 * Characteristic of the Scan Parameter service that sends a notification
407 * to a client when the server requires its latest scan parameters.
408 */
410
411 /**
412 * Characteristic of the Device Information Service that contains a
413 * UTF8 string representing the serial number of the device.
414 */
416
417 /**
418 * Characteristic of the Device Information Service that contains an
419 * UTF8 string representing the software revision of the device.
420 */
422
423 /**
424 * Characteristic of the Alert Notification Service that notifies the
425 * count of new alerts for a given category to a subscribed client.
426 */
428
429 /**
430 * Characteristic of the Alert Notification service, which exposes
431 * categories of unread alert supported by the server.
432 */
434
435 /**
436 * Characteristic of the Device Information Service that exposes a
437 * structure containing an Organizationally Unique Identifier (OUI)
438 * followed by a manufacturer-defined identifier. The value of the
439 * structure is unique for each individual instance of the product.
440 */
442
443 /**
444 * Characteristic of the Environmental Sensing service that exposes the
445 * temperature measurement with a resolution of 0.01 degree Celsius.
446 */
448
449 /**
450 * Characteristic of the Health Thermometer service that sends temperature
451 * measurement to clients.
452 */
454
455 /**
456 * Characteristic of the Health Thermometer service that describes
457 * where the measurement takes place.
458 */
460
461 /**
462 * Not used in a service as a characteristic.
463 */
465
466 /**
467 * Not used in a service as a characteristic.
468 */
470
471 /**
472 * Characteristic of the Reference Time service that allows clients to
473 * control time update.
474 */
476
477 /**
478 * Characteristic of the Reference Time service that informs clients of
479 * the status of the time update operation.
480 */
482
483 /**
484 * Characteristic of the Next DST Change service that returns to clients
485 * the time with DST.
486 */
488
489 /**
490 * Not used in a service as a characteristic.
491 */
493
494 /**
495 * Characteristic of the TX Power service that exposes the current
496 * transmission power in dBm.
497 */
499
500 /**
501 * Characteristic of the Cycling Speed and Cadence (CSC) service that
502 * exposes features supported by the server.
503 */
505
506 /**
507 * Characteristic of the Cycling Speed and Cadence (CSC) service that
508 * exposes measurements made by the server.
509 */
511
512 /**
513 * Characteristic of the Running Speed and Cadence (RSC) service that
514 * exposes features supported by the server.
515 */
517
518 /**
519 * Characteristic of the Running Speed and Cadence (RSC) service that
520 * exposes measurements made by the server.
521 */
523 };
524
525 /**
526 * Unit type of a characteristic value.
527 *
528 * These unit types are used to describe what the raw numeric data in a
529 * characteristic actually represents. A server can expose that information
530 * to its clients by adding a Characteristic Presentation Format descriptor
531 * to relevant characteristics.
532 *
533 * @note See https://developer.bluetooth.org/gatt/units/Pages/default.aspx
534 */
535 enum {
536
537 /**
538 * No specified unit type.
539 */
541
542 /**
543 * Length, meter.
544 */
546
547 /**
548 * Mass, kilogram.
549 */
551
552 /**
553 * Time, second.
554 */
556
557 /**
558 * Electric current, ampere.
559 */
561
562 /**
563 * Thermodynamic temperature, kelvin.
564 */
566
567 /** Amount of substance, mole.
568 *
569 */
571
572 /**
573 * Luminous intensity, candela.
574 */
576
577 /**
578 * Area, square meters.
579 */
581
582 /**
583 * Volume, cubic meters.
584 */
586
587 /**
588 * Velocity, meters per second.
589 */
591
592 /**
593 * Acceleration, meters per second squared.
594 */
596
597 /**
598 * Wave number reciprocal, meter.
599 */
601
602 /**
603 * Density, kilogram per cubic meter.
604 */
606
607 /**
608 * Surface density (kilogram per square meter).
609 */
611
612 /**
613 * Specific volume (cubic meter per kilogram).
614 */
616
617 /**
618 * Current density (ampere per square meter).
619 */
621
622 /**
623 * Magnetic field strength, ampere per meter.
624 */
626
627 /**
628 * Amount concentration (mole per cubic meter).
629 */
631
632 /**
633 * Mass concentration (kilogram per cubic meter).
634 */
636
637 /**
638 * Luminance (candela per square meter).
639 */
641
642 /**
643 * Refractive index.
644 */
646
647 /**
648 * Relative permeability.
649 */
651
652 /**
653 * Plane angle (radian).
654 */
656
657 /**
658 * Solid angle (steradian).
659 */
661
662 /**
663 * Frequency, hertz.
664 */
666
667 /**
668 * Force, newton.
669 */
671
672 /**
673 * Pressure, pascal.
674 */
676
677 /**
678 * Energy, joule.
679 */
681
682 /**
683 * Power, watt.
684 */
686
687 /**
688 * Electrical charge, coulomb.
689 */
691
692 /**
693 * Electrical potential difference, voltage.
694 */
696
697 /**
698 * Capacitance, farad.
699 */
701
702 /**
703 * Electric resistance, ohm.
704 */
706
707 /**
708 * Electric conductance, siemens.
709 */
711
712 /**
713 * Magnetic flux, weber.
714 */
716
717 /**
718 * Magnetic flux density, tesla.
719 */
721
722 /**
723 * Inductance, henry.
724 */
726
727 /**
728 * Celsius temperature, degree Celsius.
729 */
731
732 /**
733 * Luminous flux, lumen.
734 */
736
737 /**
738 * Illuminance, lux.
739 */
741
742 /**
743 * Activity referred to a radionuclide, becquerel.
744 */
746
747 /**
748 * Absorbed dose, gray.
749 */
751
752 /**
753 * Dose equivalent, sievert.
754 */
756
757 /**
758 * Catalytic activity, katal.
759 */
761
762 /**
763 * Dynamic viscosity, pascal second.
764 */
766
767 /**
768 * Moment of force, newton meter.
769 */
771
772 /**
773 * Surface tension, newton per meter.
774 */
776
777 /**
778 * Angular velocity, radian per second.
779 */
781
782 /**
783 * Angular acceleration, radian per second squared.
784 */
786
787 /**
788 * Heat flux density, watt per square meter.
789 */
791
792 /**
793 * Heat capacity, joule per kelvin.
794 */
796
797 /**
798 * Specific heat capacity, joule per kilogram kelvin.
799 */
801
802 /**
803 * Specific energy, joule per kilogram.
804 */
806
807 /**
808 * Thermal conductivity, watt per meter kelvin.
809 */
811
812 /**
813 * Energy density, joule per cubic meter.
814 */
816
817 /**
818 * Electric field strength, volt per meter.
819 */
821
822 /**
823 * Electric charge density, coulomb per cubic meter.
824 */
826
827 /**
828 * Surface charge density, coulomb per square meter.
829 */
831
832 /**
833 * Electric flux density, coulomb per square meter.
834 */
836
837 /**
838 * Permittivity, farad per meter.
839 */
841
842 /**
843 * Permeability, henry per meter.
844 */
846
847 /**
848 * Molar energy, joule per mole.
849 */
851
852 /**
853 * Molar entropy, joule per mole kelvin.
854 */
856
857 /**
858 * Exposure, coulomb per kilogram.
859 */
861
862 /**
863 * Absorbed dose rate, gray per second.
864 */
866
867 /**
868 * Radiant intensity, watt per steradian.
869 */
871
872 /**
873 * Radiance, watt per square meter steradian.
874 */
876
877 /**
878 * Catalytic activity concentration, katal per cubic meter.
879 */
881
882 /**
883 * Time, minute.
884 */
886
887 /**
888 * Time, hour.
889 */
891
892 /**
893 * Time, day.
894 */
896
897 /**
898 * Plane angle, degree.
899 */
901
902 /**
903 * Plane angle, minute.
904 */
906
907 /**
908 * Plane angle, seconds.
909 */
911
912 /**
913 * Area, hectare.
914 */
916
917 /**
918 * Volume, liter.
919 */
921
922 /**
923 * Mass, ton.
924 */
926
927 /**
928 * Pressure, bar.
929 */
931
932 /**
933 * Pressure, millimeter of mercury.
934 */
936
937 /**
938 * Length, ngstrm.
939 */
941
942 /**
943 * Length, nautical mile.
944 */
946
947 /**
948 * Area, barn.
949 */
951
952 /**
953 * Velocity, knot.
954 */
956
957 /**
958 * Logarithmic radio quantity, neper.
959 */
961
962 /**
963 * Logarithmic radio quantity, bel.
964 */
966
967 /**
968 * Length, yard.
969 */
971
972 /**
973 * Length, parsec.
974 */
976
977 /**
978 * Length, inch.
979 */
981
982 /**
983 * Length, foot.
984 */
986
987 /**
988 * Length, mile.
989 */
991
992 /**
993 * Pressure, pound-force per square inch.
994 */
996
997 /**
998 * Velocity, kilometer per hour.
999 */
1001
1002 /** Velocity, mile per hour.
1003 *
1004 */
1006
1007 /**
1008 * Angular Velocity, revolution per minute.
1009 */
1011
1012 /**
1013 * Energy, gram calorie.
1014 */
1016
1017 /**
1018 * Energy, kilogram calorie.
1019 */
1021
1022 /**
1023 * Energy, killowatt hour.
1024 */
1026
1027 /**
1028 * Thermodynamic temperature, degree Fahrenheit.
1029 */
1031
1032 /**
1033 * Percentage.
1034 */
1036
1037 /**
1038 * Per mille.
1039 */
1041
1042 /**
1043 * Period, beats per minute.
1044 */
1046
1047 /**
1048 * Electric charge, ampere hours.
1049 */
1051
1052 /**
1053 * Mass density, milligram per deciliter.
1054 */
1056
1057 /**
1058 * Mass density, millimole per liter.
1059 */
1061
1062 /**
1063 * Time, year.
1064 */
1066
1067 /**
1068 * Time, month.
1069 */
1071
1072 /**
1073 * Concentration, count per cubic meter.
1074 */
1076
1077 /**
1078 * Irradiance, watt per square meter.
1079 */
1082
1083 /**
1084 * Presentation format of a characteristic.
1085 *
1086 * It determines how the value of a characteristic is formatted. A server
1087 * can expose that information to its clients by adding a Characteristic
1088 * Presentation Format descriptor to relevant characteristics.
1089 *
1090 * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5.2.
1091 */
1092 enum {
1093 /**
1094 * Reserved for future use.
1095 */
1097
1098 /**
1099 * Boolean.
1100 */
1102
1103 /**
1104 * Unsigned 2-bit integer.
1105 */
1107
1108 /**
1109 * Unsigned 4-bit integer.
1110 */
1112
1113 /**
1114 * Unsigned 8-bit integer.
1115 */
1117
1118 /**
1119 * Unsigned 12-bit integer.
1120 */
1122
1123 /**
1124 * Unsigned 16-bit integer.
1125 */
1127
1128 /**
1129 * Unsigned 24-bit integer.
1130 */
1132
1133 /**
1134 * Unsigned 32-bit integer.
1135 */
1137
1138 /**
1139 * Unsigned 48-bit integer.
1140 */
1142
1143 /**
1144 * Unsigned 64-bit integer.
1145 */
1147
1148 /**
1149 * Unsigned 128-bit integer.
1150 */
1152
1153 /**
1154 * Signed 8-bit integer.
1155 */
1157
1158 /**
1159 * Signed 12-bit integer.
1160 */
1162
1163 /**
1164 * Signed 16-bit integer.
1165 */
1167
1168 /**
1169 * Signed 24-bit integer.
1170 */
1172
1173 /**
1174 * Signed 32-bit integer.
1175 */
1177
1178 /**
1179 * Signed 48-bit integer.
1180 */
1182
1183 /**
1184 * Signed 64-bit integer.
1185 */
1187
1188 /**
1189 * Signed 128-bit integer.
1190 */
1192
1193 /**
1194 * IEEE-754 32-bit floating point.
1195 */
1197
1198 /**
1199 * IEEE-754 64-bit floating point.
1200 */
1202
1203 /**
1204 * IEEE-11073 16-bit SFLOAT.
1205 */
1207
1208 /**
1209 * IEEE-11073 32-bit FLOAT.
1210 */
1212
1213 /**
1214 * IEEE-20601 format.
1215 */
1217
1218 /**
1219 * UTF8 string.
1220 */
1222
1223 /**
1224 * UTF16 string.
1225 */
1227
1228 /**
1229 * Opaque Structure.
1230 */
1233
1234 /*!
1235 * Characteristic properties.
1236 *
1237 * It is a bitfield that determines how a characteristic value can be used.
1238 *
1239 * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.1.1
1240 * and Section 3.3.3.1 for Extended Properties.
1241 */
1243 /**
1244 * No property defined.
1245 */
1247
1248 /**
1249 * Permits broadcasts of the characteristic value using the Server
1250 * Characteristic Configuration descriptor.
1251 */
1253
1254 /**
1255 * Permits reads of the characteristic value.
1256 */
1258
1259 /**
1260 * Permits writes of the characteristic value without response.
1261 */
1263
1264 /**
1265 * Permits writes of the characteristic value with response.
1266 */
1268
1269 /**
1270 * Permits notifications of a characteristic value without acknowledgment.
1271 */
1273
1274 /**
1275 * Permits indications of a characteristic value with acknowledgment.
1276 */
1278
1279 /**
1280 * Permits signed writes to the characteristic value.
1281 */
1283
1284 /**
1285 * The Characteristic Extended Properties descriptor
1286 * defines additional characteristic properties.
1287 */
1290
1291 /**
1292 * Indicates if the properties has at least one of the writable flags.
1293 *
1294 * @param[in] properties The properties to inspect.
1295 *
1296 * @return True if the properties set at least one of the writable flags and
1297 * false otherwise.
1298 */
1299 static bool isWritable(uint8_t properties)
1300 {
1301 const uint8_t writable =
1305
1306 return properties & writable;
1307 }
1308
1309 /**
1310 * Indicates if the properties is readable.
1311 *
1312 * @param[in] properties The properties to inspect.
1313 *
1314 * @return True if the properties has its readable flag set and false
1315 * otherwise.
1316 */
1317 static bool isReadable(uint8_t properties)
1318 {
1319 const uint8_t readable = BLE_GATT_CHAR_PROPERTIES_READ;
1320 return properties & readable;
1321 }
1322
1323 /**
1324 * Value of a Characteristic Presentation Format descriptor.
1325 *
1326 * Characteristic Presentation Format descriptor expresses the format of a
1327 * characteristic value.
1328 *
1329 * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5.
1330 */
1332 /**
1333 * Format of the value.
1334 */
1336
1337 /**
1338 * Exponent for integer data types.
1339 *
1340 * Example: if Exponent = -3 and the char value is 3892, the actual
1341 * value is 3.892
1342 */
1343 int8_t exponent;
1344
1345 /**
1346 * Unit of the characteristic value.
1347 *
1348 * It is a UUID from Bluetooth Assigned Numbers.
1349 */
1350 uint16_t gatt_unit;
1351
1352 /**
1353 * Namespace of the description field.
1354 *
1355 * This field identifies the organization that is responsible for
1356 * defining the enumerations for the description field.
1357 *
1358 * The namespace of the Bluetooth Body is 0x01.
1359 */
1361
1362 /**
1363 * Description.
1364 *
1365 * @note The value 0x0000 means unknown in the Bluetooth namespace.
1366 */
1367 uint16_t gatt_nsdesc;
1368
1369 };
1370
1371 /**
1372 * Security level applied to GATT operations.
1373 */
1375
1376 /**
1377 * @brief Constructs a new GattCharacteristic.
1378 *
1379 * @param[in] uuid The UUID of this characteristic.
1380 * @param[in] valuePtr Memory buffer holding the initial value. The value is
1381 * copied into the Bluetooth subsytem when the enclosing service is added.
1382 * Thereafter, the stack maintains it internally.
1383 * @param[in] len The length in bytes of this characteristic's value.
1384 * @param[in] maxLen The capacity in bytes of the characteristic value
1385 * buffer.
1386 * @param[in] props An 8-bit field that contains the characteristic's
1387 * properties.
1388 * @param[in] descriptors A pointer to an array of descriptors to be included
1389 * within this characteristic. The caller owns the memory for the descriptor
1390 * array, which must remain valid at least until the enclosing service is
1391 * added to the GATT table.
1392 * @param[in] numDescriptors The number of descriptors presents in @p
1393 * descriptors array.
1394 * @param[in] hasVariableLen Flag that indicates if the attribute's value
1395 * length can change throughout time.
1396 *
1397 * @note If valuePtr is nullptr, length is equal to 0 and the characteristic
1398 * is readable, then that particular characteristic may be considered
1399 * optional and dropped while instantiating the service with the underlying
1400 * BLE stack.
1401 *
1402 * @note A Client Characteristic Configuration Descriptor (CCCD) should not
1403 * be allocated if either the notify or indicate flag in the @p props bit
1404 * field; the underlying BLE stack handles it.
1405 *
1406 * @attention GattCharacteristic registered in a GattServer must remain
1407 * valid for the lifetime of the GattServer.
1408 */
1410 const UUID &uuid,
1411 uint8_t *valuePtr = nullptr,
1412 uint16_t len = 0,
1413 uint16_t maxLen = 0,
1414 uint8_t props = BLE_GATT_CHAR_PROPERTIES_NONE,
1415 GattAttribute *descriptors[] = nullptr,
1416 unsigned numDescriptors = 0,
1417 bool hasVariableLen = true
1418 ) : _valueAttribute(uuid, valuePtr, len, maxLen, hasVariableLen),
1419 _properties(props),
1420 _descriptors(descriptors),
1421 _descriptorCount(numDescriptors),
1422 readAuthorizationCallback(),
1423 writeAuthorizationCallback(),
1424 _update_security(SecurityRequirement_t::NONE) {
1425 _valueAttribute.allowWrite(isWritable(_properties));
1426 _valueAttribute.allowRead(isReadable(_properties));
1427
1428#if BLE_FEATURE_SECURITY
1429 // signed writes requires at least an unauthenticated CSRK or an
1430 // unauthenticated ltk if the link is encrypted.
1432 _valueAttribute.setWriteSecurityRequirement(
1434 );
1435 }
1436#endif // BLE_FEATURE_SECURITY
1437 }
1438
1439 GattCharacteristic(const GattCharacteristic &) = delete;
1440 GattCharacteristic& operator=(const GattCharacteristic &) = delete;
1441
1443 delete _implicit_cccd;
1444 _implicit_cccd = nullptr;
1445 }
1446
1447public:
1448
1449 /**
1450 * Set all security requirements of the characteristic.
1451 *
1452 * @param read_security The security requirement of the read operations.
1453 * @param write_security The security requirement of write operations.
1454 * @param update_security The security requirement of update operations.
1455 */
1457 SecurityRequirement_t read_security,
1458 SecurityRequirement_t write_security,
1459 SecurityRequirement_t update_security
1460 ) {
1461 setReadSecurityRequirement(read_security);
1462 setWriteSecurityRequirement(write_security);
1463 setUpdateSecurityRequirement(update_security);
1464 }
1465
1466 /**
1467 * Set the security of the read operation.
1468 *
1469 * @param[in] security The security requirement of the read operation.
1470 */
1472 {
1473 _valueAttribute.setReadSecurityRequirement(security);
1474 }
1475
1476 /**
1477 * Get the security requirement of the read operation.
1478 *
1479 * @return The security requirement of the read operation.
1480 */
1482 {
1483 return _valueAttribute.getReadSecurityRequirement();
1484 }
1485
1486 /**
1487 * Set the security requirement of the write operations.
1488 *
1489 * @note If the signed write flag is set in the characteristic properties
1490 * then the security requirement applied to write operation must be either
1491 * AUTHENTICATED or UNAUTHENTICATED. Security requirements NONE and
1492 * SC_AUTHENTICATED are not applicable to signing operation.
1493 *
1494 * @param[in] security The security requirement of write operations.
1495 */
1497 {
1498#if BLE_FEATURE_SECURITY
1501 ((security == SecurityRequirement_t::NONE) ||
1502 (security == SecurityRequirement_t::SC_AUTHENTICATED))) == false
1503 );
1504#endif // BLE_FEATURE_SECURITY
1505 _valueAttribute.setWriteSecurityRequirement(security);
1506 }
1507
1508 /**
1509 * Get the security requirement of write operations.
1510 *
1511 * @return The security requirement of write operations.
1512 */
1514 {
1515 return _valueAttribute.getWriteSecurityRequirement();
1516 }
1517
1518 /**
1519 * Set the security requirement of update operations.
1520 *
1521 * @note This security requirement is also applied to the write operation of
1522 * the Client Characteristic Configuration Descriptor.
1523 *
1524 * @param[in] security The security requirement that must be met to send
1525 * updates and accept write of the CCCD.
1526 */
1528 {
1529 _update_security = security.value();
1530 }
1531
1532 /**
1533 * Get the security requirement of update operations.
1534 *
1535 * @note This security requirement is also applied to the write operation of
1536 * the Client Characteristic Configuration Descriptor.
1537 *
1538 * @return The security requirement that must be met to send updates and
1539 * accept write of the CCCD.
1540 */
1542 {
1543 return static_cast<SecurityRequirement_t::type>(_update_security);
1544 }
1545
1546public:
1547 /**
1548 * Register a callback handling client's write requests or commands.
1549 *
1550 * The callback registered is invoked when the client attempts to write the
1551 * characteristic value; the event handler can accept or reject the write
1552 * request with the appropriate error code.
1553 *
1554 * @param[in] callback Event handler being registered.
1555 */
1557 void (*callback)(GattWriteAuthCallbackParams *)
1558 ) {
1559 writeAuthorizationCallback.attach(callback);
1560 }
1561
1562 /**
1563 * Register a callback handling client's write requests or commands.
1564 *
1565 * The callback registered is invoked when the client attempts to write the
1566 * characteristic value; the event handler can accept or reject the write
1567 * request with the appropriate error code.
1568 *
1569 * @param[in] object Pointer to the object of a class defining the event
1570 * handler (@p member). It must remain valid for the lifetime of the
1571 * GattCharacteristic.
1572 * @param[in] member The member function that handles the write event.
1573 */
1574 template <typename T>
1576 T *object,
1577 void (T::*member)(GattWriteAuthCallbackParams *)
1578 ) {
1579 writeAuthorizationCallback.attach(object, member);
1580 }
1581
1582 /**
1583 * Return the callback registered to handle client's write.
1584 *
1585 * @return the callback that handles client's write requests.
1586 */
1589 {
1590 return writeAuthorizationCallback;
1591 }
1592
1593 /**
1594 * Register the read requests event handler.
1595 *
1596 * The callback registered is invoked when the client attempts to read the
1597 * characteristic value; the event handler can accept or reject the read
1598 * request with the appropriate error code. It can also set specific outgoing
1599 * data.
1600 *
1601 * @param[in] callback Event handler being registered.
1602 */
1604 void (*callback)(GattReadAuthCallbackParams *)
1605 ) {
1606 readAuthorizationCallback.attach(callback);
1607 }
1608
1609 /**
1610 * Register the read requests event handler.
1611 *
1612 * The callback registered is invoked when the client attempts to read the
1613 * characteristic value; the event handler can accept or reject the read
1614 * request with the appropriate error code. It can also set specific outgoing
1615 * data.
1616 *
1617 * @param[in] object Pointer to the object of a class defining the event
1618 * handler (@p member). It must remain valid for the lifetime of the
1619 * GattCharacteristic.
1620 * @param[in] member The member function that handles the read event.
1621 */
1622 template <typename T>
1624 T *object,
1625 void (T::*member)(GattReadAuthCallbackParams *)
1626 ) {
1627 readAuthorizationCallback.attach(object, member);
1628 }
1629
1630 /**
1631 * Return the callback registered to handle client's read.
1632 *
1633 * @return the callback that handles client's read requests.
1634 */
1637 {
1638 return readAuthorizationCallback;
1639 }
1640
1641 /**
1642 * Invoke the write authorization callback.
1643 *
1644 * This function is a helper that calls the registered write handler to
1645 * determine the authorization reply for a write request.
1646 *
1647 * @attention This function is not meant to be called by user code.
1648 *
1649 * @param[in] params Context of the write-auth request; it contains an
1650 * out-parameter used as a reply.
1651 *
1652 * @return A GattAuthCallbackReply_t value indicating whether authorization
1653 * is granted.
1654 */
1656 {
1659 }
1660
1661 /* Initialized to no-error by default. */
1663 writeAuthorizationCallback.call(params);
1664 return params->authorizationReply;
1665 }
1666
1667 /**
1668 * Invoke the read authorization callback.
1669 *
1670 * This function is a helper that calls the registered read handler to
1671 * determine the authorization reply for a read request.
1672 *
1673 * @attention This function is not meant to be called by user code.
1674 *
1675 * @param[in,out] params Context of the read-auth request; it contains an
1676 * out-parameter used as a reply and the handler can fill it with outgoing
1677 * data. The params->data provides a pointer to the data and params->len
1678 * provides the length of this data. params->len is also used to pass the
1679 * maximum size of data that the params->data can contain. If you set the
1680 * params->len to a value larger than the passed in value the read operation
1681 * will fail.
1682 *
1683 * @return A GattAuthCallbackReply_t value indicating whether authorization
1684 * is granted.
1685 *
1686 * @note If the read is approved, the event handler can specify an outgoing
1687 * value directly with the help of the fields params->data and params->len.
1688 *
1689 * @note If the read request is approved and params->data remains nullptr, then
1690 * the current characteristic value is used in the read response payload.
1691 *
1692 * @note The params->len parameter initially contains the maximum length of
1693 * data that can be returned. Set it to the length of your data but it must
1694 * not be larger than the original value.
1695 *
1696 * @note You must also take into account the offset provided in params->offset.
1697 * The params->len you provide must be larger then the offset as the read operation
1698 * will attempt to read at that offset.
1699 */
1701 {
1704 }
1705
1706 /* Initialized to no-error by default. */
1708 readAuthorizationCallback.call(params);
1709 return params->authorizationReply;
1710 }
1711
1712public:
1713 /**
1714 * Get the characteristic's value attribute.
1715 *
1716 * @return A reference to the characteristic's value attribute.
1717 */
1719 {
1720 return _valueAttribute;
1721 }
1722
1723 /**
1724 * Get the characteristic's value attribute.
1725 *
1726 * @return A const reference to the characteristic's value attribute.
1727 */
1729 {
1730 return _valueAttribute;
1731 }
1732
1733 /**
1734 * Get the characteristic's value attribute handle in the ATT table.
1735 *
1736 * @return The value attribute handle.
1737 *
1738 * @note The underlying BLE stack assigns the attribute handle when the
1739 * enclosing service is added.
1740 */
1742 {
1743 return getValueAttribute().getHandle();
1744 }
1745
1746 /**
1747 * Get the characteristic's properties.
1748 *
1749 * @note Refer to GattCharacteristic::Properties_t.
1750 *
1751 * @return The characteristic's properties.
1752 */
1753 uint8_t getProperties() const
1754 {
1755 return _properties;
1756 }
1757
1758 /**
1759 * Get the total number of descriptors within this characteristic.
1760 *
1761 * @return The total number of descriptors.
1762 */
1763 uint8_t getDescriptorCount() const
1764 {
1765 return (_implicit_cccd == nullptr? _descriptorCount : _descriptorCount+1);
1766 }
1767
1768 /**
1769 * Check whether read authorization is enabled.
1770 *
1771 * Read authorization is enabled when a read authorization event handler is
1772 * set up.
1773 *
1774 * @return true if read authorization is enabled and false otherwise.
1775 */
1777 {
1778 return readAuthorizationCallback;
1779 }
1780
1781 /**
1782 * Check whether write authorization is enabled.
1783 *
1784 * Write authorization is enabled when a write authorization event handler is
1785 * set up.
1786 *
1787 * @return true if write authorization is enabled, false otherwise.
1788 */
1790 {
1791 return writeAuthorizationCallback;
1792 }
1793
1794 /**
1795 * Get this characteristic's descriptor at a specific index.
1796 *
1797 * @param[in] index The index of the descriptor to get.
1798 *
1799 * @return A pointer the requested descriptor if @p index is within the
1800 * range of the descriptor array or nullptr otherwise.
1801 *
1802 * @note if this characteristic has an implicitly-created CCCD this
1803 * descriptor will be available at the highest index
1804 * (ie: return of getDescriptorCount() - 1)
1805 */
1807 {
1808
1809 if(index == _descriptorCount) {
1810 // If _implicit_cccd is nullptr, we want to return that anyway
1811 return _implicit_cccd;
1812 }
1813 else if (index > _descriptorCount) {
1814 return nullptr;
1815 }
1816
1817 return _descriptors[index];
1818 }
1819
1820
1821private:
1822
1823 friend ble::impl::GattServer;
1824
1825#if !defined(DOXYGEN_ONLY)
1826 /**
1827 * Sets this GattCharacteristic's implicitly-created CCCD, if
1828 * applicable.
1829 *
1830 * @note once this is called, the pointed-to GattAttribute
1831 * is owned by this GattCharacteristic and will be deleted
1832 * during this object's destructor
1833 */
1834 void setImplicitCCCD(GattAttribute *implicit_cccd) {
1835 _implicit_cccd = implicit_cccd;
1836 }
1837#endif // !defined(DOXYGEN_ONLY)
1838
1839
1840private:
1841
1842 /**
1843 * Attribute that contains the actual value of this characteristic.
1844 */
1845 GattAttribute _valueAttribute;
1846
1847 /**
1848 * The characteristic's properties. Refer to
1849 * GattCharacteristic::Properties_t.
1850 */
1851 uint8_t _properties;
1852
1853 /**
1854 * The characteristic's descriptor attributes.
1855 */
1856 GattAttribute **_descriptors;
1857
1858 /**
1859 * The number of descriptors in this characteristic.
1860 */
1861 uint8_t _descriptorCount;
1862
1863 /**
1864 * Pointer to characteristic's implicit CCCD, if applicable
1865 *
1866 * @note this is only populated if the stack creates an implicit CCCD
1867 * for this GattCharacteristic. If the descriptors array passed into
1868 * the constructor includes a CCCD this field is left as nullptr to
1869 * indicate the CCCD was explicitly created.
1870 */
1871 GattAttribute* _implicit_cccd = nullptr;
1872
1873 /**
1874 * The registered callback handler for read authorization reply.
1875 */
1877 readAuthorizationCallback;
1878
1879 /**
1880 * The registered callback handler for write authorization reply.
1881 */
1883 writeAuthorizationCallback;
1884
1885 /**
1886 * Security requirements of update operations.
1887 *
1888 * The peer must meet the security requirement to enable, disable and
1889 * receive updates
1890 */
1891 uint8_t _update_security: SecurityRequirement_t::size;
1892};
1893
1894/**
1895 * Helper class that represents a read only GattCharacteristic.
1896 */
1897template <typename T>
1899public:
1900 /**
1901 * Construct a ReadOnlyGattCharacteristic.
1902 *
1903 * @param[in] uuid The characteristic's UUID.
1904 * @param[in] valuePtr Pointer to the characteristic's initial value. The
1905 * pointer is reinterpreted as a pointer to an uint8_t buffer.
1906 * @param[in] additionalProperties Additional characteristic properties. By
1907 * default, the properties are set to
1908 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
1909 * @param[in] descriptors An array of pointers to descriptors to be added
1910 * to the new characteristic.
1911 * @param[in] numDescriptors The total number of descriptors in @p
1912 * descriptors.
1913 *
1914 * @note Instances of ReadOnlyGattCharacteristic have a fixed length
1915 * attribute value that equals sizeof(T). For a variable length alternative,
1916 * use GattCharacteristic directly.
1917 */
1919 const UUID &uuid,
1920 T *valuePtr,
1921 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
1922 GattAttribute *descriptors[] = nullptr,
1923 unsigned numDescriptors = 0
1925 uuid,
1926 reinterpret_cast<uint8_t *>(valuePtr),
1927 sizeof(T),
1928 sizeof(T),
1929 BLE_GATT_CHAR_PROPERTIES_READ | additionalProperties,
1930 descriptors,
1931 numDescriptors,
1932 false
1933 ) {
1934 }
1935};
1936
1937/**
1938 * Helper class that represents a write only GattCharacteristic.
1939 */
1940template <typename T>
1942public:
1943 /**
1944 * Construct a WriteOnlyGattCharacteristic.
1945 *
1946 * @param[in] uuid The characteristic's UUID.
1947 * @param[in] valuePtr Pointer to the characteristic's initial value. The
1948 * pointer is reinterpreted as a pointer to an uint8_t buffer.
1949 * @param[in] additionalProperties Additional characteristic properties. By
1950 * default, the properties are set to
1951 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE.
1952 * @param[in] descriptors An array of pointers to descriptors to be added to
1953 * the new characteristic.
1954 * @param[in] numDescriptors The total number of descriptors in @p
1955 * descriptors.
1956 *
1957 * @note Instances of WriteOnlyGattCharacteristic have variable length
1958 * attribute value with maximum size equal to sizeof(T). For a fixed length
1959 * alternative, use GattCharacteristic directly.
1960 */
1962 const UUID &uuid,
1963 T *valuePtr,
1964 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
1965 GattAttribute *descriptors[] = nullptr,
1966 unsigned numDescriptors = 0
1968 uuid,
1969 reinterpret_cast<uint8_t *>(valuePtr),
1970 sizeof(T),
1971 sizeof(T),
1972 BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
1973 descriptors,
1974 numDescriptors
1975 ) {
1976 }
1977};
1978
1979/**
1980 * Helper class that represents a readable and writable GattCharacteristic.
1981 */
1982template <typename T>
1984public:
1985 /**
1986 * Construct a ReadWriteGattCharacteristic.
1987 *
1988 * @param[in] uuid The characteristic's UUID.
1989 * @param[in] valuePtr Pointer to the characteristic's initial value. The
1990 * pointer is reinterpreted as a pointer to an uint8_t buffer.
1991 * @param[in] additionalProperties Additional characteristic properties. By
1992 * default, the properties are set to
1993 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE and
1994 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
1995 * @param[in] descriptors An array of pointers to descriptors to be added to
1996 * the new characteristic.
1997 * @param[in] numDescriptors The total number of descriptors in @p descriptors.
1998 *
1999 * @note Instances of ReadWriteGattCharacteristic have variable length
2000 * attribute value with maximum size equal to sizeof(T). For a fixed length
2001 * alternative, use GattCharacteristic directly.
2002 */
2004 const UUID &uuid,
2005 T *valuePtr,
2006 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
2007 GattAttribute *descriptors[] = nullptr,
2008 unsigned numDescriptors = 0
2010 uuid,
2011 reinterpret_cast<uint8_t *>(valuePtr),
2012 sizeof(T),
2013 sizeof(T),
2015 descriptors,
2016 numDescriptors
2017 ) {
2018 }
2019};
2020
2021/**
2022 * Helper class that represents a write-only GattCharacteristic with an array
2023 * value.
2024 */
2025template <typename T, unsigned NUM_ELEMENTS>
2027public:
2028 /**
2029 * Construct a WriteOnlyGattCharacteristic.
2030 *
2031 * @param[in] uuid The characteristic's UUID.
2032 * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
2033 * the characteristic's initial value. The pointer is reinterpreted as a
2034 * pointer to an uint8_t buffer.
2035 * @param[in] additionalProperties Additional characteristic properties. By
2036 * default, the properties are set to
2037 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE.
2038 * @param[in] descriptors An array of pointers to descriptors to be added to
2039 * the new characteristic.
2040 * @param[in] numDescriptors The total number of descriptors in @p descriptors.
2041 *
2042 * @note Instances of WriteOnlyGattCharacteristic have variable length
2043 * attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
2044 * For a fixed length alternative, use GattCharacteristic directly.
2045 */
2047 const UUID &uuid,
2048 T valuePtr[NUM_ELEMENTS],
2049 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
2050 GattAttribute *descriptors[] = nullptr,
2051 unsigned numDescriptors = 0
2053 uuid,
2054 reinterpret_cast<uint8_t *>(valuePtr),
2055 sizeof(T) * NUM_ELEMENTS,
2056 sizeof(T) * NUM_ELEMENTS,
2057 BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
2058 descriptors,
2059 numDescriptors
2060 ) {
2061 }
2062};
2063
2064/**
2065 * Helper class that represents a read-only GattCharacteristic with an array
2066 * value.
2067 */
2068template <typename T, unsigned NUM_ELEMENTS>
2070public:
2071 /**
2072 * Construct a ReadOnlyGattCharacteristic.
2073 *
2074 * @param[in] uuid The characteristic's UUID.
2075 * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
2076 * the characteristic's initial value. The pointer is reinterpreted as a
2077 * pointer to an uint8_t buffer.
2078 * @param[in] additionalProperties Additional characteristic properties. By
2079 * default, the properties are set to
2080 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
2081 * @param[in] descriptors An array of pointers to descriptors to be added to
2082 * the new characteristic.
2083 * @param[in] numDescriptors The total number of descriptors in @p
2084 * descriptors.
2085 *
2086 * @note Instances of ReadOnlyGattCharacteristic have fixed length
2087 * attribute value that equals sizeof(T) * NUM_ELEMENTS. For a variable
2088 * length alternative, use GattCharacteristic directly.
2089 */
2091 const UUID &uuid,
2092 T valuePtr[NUM_ELEMENTS],
2093 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
2094 GattAttribute *descriptors[] = nullptr,
2095 unsigned numDescriptors = 0
2097 uuid,
2098 reinterpret_cast<uint8_t *>(valuePtr),
2099 sizeof(T) * NUM_ELEMENTS,
2100 sizeof(T) * NUM_ELEMENTS,
2101 BLE_GATT_CHAR_PROPERTIES_READ | additionalProperties,
2102 descriptors,
2103 numDescriptors,
2104 false
2105 ) {
2106 }
2107};
2108
2109/**
2110 * Helper class that represents a readable and writable GattCharacteristic with
2111 * an array value.
2112 */
2113template <typename T, unsigned NUM_ELEMENTS>
2115public:
2116 /**
2117 * Construct a ReadWriteGattCharacteristic.
2118 *
2119 * @param[in] uuid The characteristic's UUID.
2120 * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
2121 * the characteristic's initial value. The pointer is reinterpreted as a
2122 * pointer to an uint8_t buffer.
2123 * @param[in] additionalProperties Additional characteristic properties. By
2124 * default, the properties are set to
2125 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE |
2126 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
2127 * @param[in] descriptors An array of pointers to descriptors to be added to
2128 * the new characteristic.
2129 * @param[in] numDescriptors The total number of descriptors in @p descriptors.
2130 *
2131 * @note Instances of ReadWriteGattCharacteristic have variable length
2132 * attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
2133 * For a fixed length alternative, use GattCharacteristic directly.
2134 */
2136 const UUID &uuid,
2137 T valuePtr[NUM_ELEMENTS],
2138 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
2139 GattAttribute *descriptors[] = nullptr,
2140 unsigned numDescriptors = 0
2142 uuid,
2143 reinterpret_cast<uint8_t *>(valuePtr),
2144 sizeof(T) * NUM_ELEMENTS,
2145 sizeof(T) * NUM_ELEMENTS,
2147 descriptors,
2148 numDescriptors
2149 ) {
2150 }
2151};
2152
2153/**
2154 * @}
2155 * @}
2156 * @}
2157 */
2158
2159#endif /* ifndef __GATT_CHARACTERISTIC_H__ */
Function like object adapter over freestanding and member functions.
void attach(void(*function)(ContextType context)=NULL)
Adapt a freestanding function.
void call(ContextType context) const
Call the adapted function and functions chained to the instance.
Representation of a GattServer attribute.
ble::attribute_handle_t Handle_t
Representation of an attribute handle.
void allowWrite(bool allow_write)
Allow or disallow write operation from a client.
Handle_t getHandle() const
Get the attribute's handle in the ATT table.
Security_t getWriteSecurityRequirement() const
Return the security level required by write operations.
void setWriteSecurityRequirement(Security_t requirement)
Set the security requirements of the write operations.
Security_t getReadSecurityRequirement() const
Return the security level required by read operations.
void setReadSecurityRequirement(Security_t requirement)
Set the security requirements of the read operations.
void allowRead(bool allow_read)
Allow or disallow read operation from a client.
Representation of a GattServer characteristic.
GattCharacteristic(const UUID &uuid, uint8_t *valuePtr=nullptr, uint16_t len=0, uint16_t maxLen=0, uint8_t props=BLE_GATT_CHAR_PROPERTIES_NONE, GattAttribute *descriptors[]=nullptr, unsigned numDescriptors=0, bool hasVariableLen=true)
Constructs a new GattCharacteristic.
GattAttribute::Handle_t getValueHandle() const
Get the characteristic's value attribute handle in the ATT table.
uint8_t getDescriptorCount() const
Get the total number of descriptors within this characteristic.
bool isWriteAuthorizationEnabled() const
Check whether write authorization is enabled.
static bool isWritable(uint8_t properties)
Indicates if the properties has at least one of the writable flags.
@ BLE_GATT_CHAR_PROPERTIES_WRITE
Permits writes of the characteristic value with response.
@ BLE_GATT_CHAR_PROPERTIES_NONE
No property defined.
@ BLE_GATT_CHAR_PROPERTIES_BROADCAST
Permits broadcasts of the characteristic value using the Server Characteristic Configuration descript...
@ BLE_GATT_CHAR_PROPERTIES_READ
Permits reads of the characteristic value.
@ BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE
Permits writes of the characteristic value without response.
@ BLE_GATT_CHAR_PROPERTIES_AUTHENTICATED_SIGNED_WRITES
Permits signed writes to the characteristic value.
@ BLE_GATT_CHAR_PROPERTIES_NOTIFY
Permits notifications of a characteristic value without acknowledgment.
@ BLE_GATT_CHAR_PROPERTIES_INDICATE
Permits indications of a characteristic value with acknowledgment.
@ BLE_GATT_CHAR_PROPERTIES_EXTENDED_PROPERTIES
The Characteristic Extended Properties descriptor defines additional characteristic properties.
const FunctionPointerWithContext< GattWriteAuthCallbackParams * > & getWriteAuthorizationCallback() const
Return the callback registered to handle client's write.
void setReadAuthorizationCallback(void(*callback)(GattReadAuthCallbackParams *))
Register the read requests event handler.
uint8_t getProperties() const
Get the characteristic's properties.
void setSecurityRequirements(SecurityRequirement_t read_security, SecurityRequirement_t write_security, SecurityRequirement_t update_security)
Set all security requirements of the characteristic.
SecurityRequirement_t getReadSecurityRequirement() const
Get the security requirement of the read operation.
static bool isReadable(uint8_t properties)
Indicates if the properties is readable.
GattAuthCallbackReply_t authorizeRead(GattReadAuthCallbackParams *params)
Invoke the read authorization callback.
@ BLE_GATT_UNIT_LENGTH_FOOT
Length, foot.
@ BLE_GATT_UNIT_RADIANT_INTENSITY_WATT_PER_STERADIAN
Radiant intensity, watt per steradian.
@ BLE_GATT_UNIT_VELOCITY_KNOT
Velocity, knot.
@ BLE_GATT_UNIT_PRESSURE_POUND_FORCE_PER_SQUARE_INCH
Pressure, pound-force per square inch.
@ BLE_GATT_UNIT_ENERGY_DENSITY_JOULE_PER_CUBIC_METRE
Energy density, joule per cubic meter.
@ BLE_GATT_UNIT_ENERGY_JOULE
Energy, joule.
@ BLE_GATT_UNIT_ACCELERATION_METRES_PER_SECOND_SQUARED
Acceleration, meters per second squared.
@ BLE_GATT_UNIT_PERMEABILITY_HENRY_PER_METRE
Permeability, henry per meter.
@ BLE_GATT_UNIT_MAGNETIC_FLUX_DENSITY_TESLA
Magnetic flux density, tesla.
@ BLE_GATT_UNIT_AREA_HECTARE
Area, hectare.
@ BLE_GATT_UNIT_NONE
No specified unit type.
@ BLE_GATT_UNIT_LUMINOUS_FLUX_LUMEN
Luminous flux, lumen.
@ BLE_GATT_UNIT_PRESSURE_PASCAL
Pressure, pascal.
@ BLE_GATT_UNIT_REFRACTIVE_INDEX
Refractive index.
@ BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_KELVIN
Thermodynamic temperature, kelvin.
@ BLE_GATT_UNIT_ELECTRIC_CONDUCTANCE_SIEMENS
Electric conductance, siemens.
@ BLE_GATT_UNIT_TIME_SECOND
Time, second.
@ BLE_GATT_UNIT_MASS_DENSITY_MILLIGRAM_PER_DECILITRE
Mass density, milligram per deciliter.
@ BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_BEL
Logarithmic radio quantity, bel.
@ BLE_GATT_UNIT_INDUCTANCE_HENRY
Inductance, henry.
@ BLE_GATT_UNIT_CURRENT_DENSITY_AMPERE_PER_SQUARE_METRE
Current density (ampere per square meter).
@ BLE_GATT_UNIT_LENGTH_METRE
Length, meter.
@ BLE_GATT_UNIT_ELECTRIC_CHARGE_AMPERE_HOURS
Electric charge, ampere hours.
@ BLE_GATT_UNIT_SPECIFIC_ENERGY_JOULE_PER_KILOGRAM
Specific energy, joule per kilogram.
@ BLE_GATT_UNIT_DOSE_EQUIVALENT_SIEVERT
Dose equivalent, sievert.
@ BLE_GATT_UNIT_LENGTH_NAUTICAL_MILE
Length, nautical mile.
@ BLE_GATT_UNIT_ELECTRIC_FLUX_DENSITY_COULOMB_PER_SQUARE_METRE
Electric flux density, coulomb per square meter.
@ BLE_GATT_UNIT_DENSITY_KILOGRAM_PER_CUBIC_METRE
Density, kilogram per cubic meter.
@ BLE_GATT_UNIT_ELECTRIC_CHARGE_COULOMB
Electrical charge, coulomb.
@ BLE_GATT_UNIT_ABSORBED_DOSE_GRAY
Absorbed dose, gray.
@ BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_FAHRENHEIT
Thermodynamic temperature, degree Fahrenheit.
@ BLE_GATT_UNIT_PLANE_ANGLE_DEGREE
Plane angle, degree.
@ BLE_GATT_UNIT_ELECTRIC_CHARGE_DENSITY_COULOMB_PER_CUBIC_METRE
Electric charge density, coulomb per cubic meter.
@ BLE_GATT_UNIT_VOLUME_CUBIC_METRES
Volume, cubic meters.
@ BLE_GATT_UNIT_MAGNETIC_FLUX_WEBER
Magnetic flux, weber.
@ BLE_GATT_UNIT_FORCE_NEWTON
Force, newton.
@ BLE_GATT_UNIT_CATALYTIC_ACTIVITY_CONCENTRATION_KATAL_PER_CUBIC_METRE
Catalytic activity concentration, katal per cubic meter.
@ BLE_GATT_UNIT_LUMINANCE_CANDELA_PER_SQUARE_METRE
Luminance (candela per square meter).
@ BLE_GATT_UNIT_MOMENT_OF_FORCE_NEWTON_METRE
Moment of force, newton meter.
@ BLE_GATT_UNIT_CATALYTIC_ACTIVITY_KATAL
Catalytic activity, katal.
@ BLE_GATT_UNIT_HEAT_FLUX_DENSITY_WATT_PER_SQUARE_METRE
Heat flux density, watt per square meter.
@ BLE_GATT_UNIT_DYNAMIC_VISCOSITY_PASCAL_SECOND
Dynamic viscosity, pascal second.
@ BLE_GATT_UNIT_VELOCITY_KILOMETRE_PER_HOUR
Velocity, kilometer per hour.
@ BLE_GATT_UNIT_MOLAR_ENTROPY_JOULE_PER_MOLE_KELVIN
Molar entropy, joule per mole kelvin.
@ BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_NEPER
Logarithmic radio quantity, neper.
@ BLE_GATT_UNIT_HEAT_CAPACITY_JOULE_PER_KELVIN
Heat capacity, joule per kelvin.
@ BLE_GATT_UNIT_LENGTH_MILE
Length, mile.
@ BLE_GATT_UNIT_SURFACE_DENSITY_KILOGRAM_PER_SQUARE_METRE
Surface density (kilogram per square meter).
@ BLE_GATT_UNIT_LENGTH_PARSEC
Length, parsec.
@ BLE_GATT_UNIT_TIME_MONTH
Time, month.
@ BLE_GATT_UNIT_VELOCITY_MILE_PER_HOUR
Velocity, mile per hour.
@ BLE_GATT_UNIT_ACTIVITY_REFERRED_TO_A_RADIONUCLIDE_BECQUEREL
Activity referred to a radionuclide, becquerel.
@ BLE_GATT_UNIT_SPECIFIC_HEAT_CAPACITY_JOULE_PER_KILOGRAM_KELVIN
Specific heat capacity, joule per kilogram kelvin.
@ BLE_GATT_UNIT_MASS_CONCENTRATION_KILOGRAM_PER_CUBIC_METRE
Mass concentration (kilogram per cubic meter).
@ BLE_GATT_UNIT_LUMINOUS_INTENSITY_CANDELA
Luminous intensity, candela.
@ BLE_GATT_UNIT_SOLID_ANGLE_STERADIAN
Solid angle (steradian).
@ BLE_GATT_UNIT_LENGTH_YARD
Length, yard.
@ BLE_GATT_UNIT_LENGTH_INCH
Length, inch.
@ BLE_GATT_UNIT_VOLUME_LITRE
Volume, liter.
@ BLE_GATT_UNIT_PLANE_ANGLE_MINUTE
Plane angle, minute.
@ BLE_GATT_UNIT_ILLUMINANCE_LUX
Illuminance, lux.
@ BLE_GATT_UNIT_AMOUNT_CONCENTRATION_MOLE_PER_CUBIC_METRE
Amount concentration (mole per cubic meter).
@ BLE_GATT_UNIT_FREQUENCY_HERTZ
Frequency, hertz.
@ BLE_GATT_UNIT_TIME_MINUTE
Time, minute.
@ BLE_GATT_UNIT_ELECTRIC_POTENTIAL_DIFFERENCE_VOLT
Electrical potential difference, voltage.
@ BLE_GATT_UNIT_ENERGY_GRAM_CALORIE
Energy, gram calorie.
@ BLE_GATT_UNIT_AREA_SQUARE_METRES
Area, square meters.
@ BLE_GATT_UNIT_ELECTRIC_CURRENT_AMPERE
Electric current, ampere.
@ BLE_GATT_UNIT_VELOCITY_METRES_PER_SECOND
Velocity, meters per second.
@ BLE_GATT_UNIT_ENERGY_KILOWATT_HOUR
Energy, killowatt hour.
@ BLE_GATT_UNIT_MOLAR_ENERGY_JOULE_PER_MOLE
Molar energy, joule per mole.
@ BLE_GATT_UNIT_ABSORBED_DOSE_RATE_GRAY_PER_SECOND
Absorbed dose rate, gray per second.
@ BLE_GATT_UNIT_CAPACITANCE_FARAD
Capacitance, farad.
@ BLE_GATT_UNIT_AREA_BARN
Area, barn.
@ BLE_GATT_UNIT_MASS_DENSITY_MILLIMOLE_PER_LITRE
Mass density, millimole per liter.
@ BLE_GATT_UNIT_PLANE_ANGLE_SECOND
Plane angle, seconds.
@ BLE_GATT_UNIT_LENGTH_ANGSTROM
Length, ngstrm.
@ BLE_GATT_UNIT_ANGULAR_ACCELERATION_RADIAN_PER_SECOND_SQUARED
Angular acceleration, radian per second squared.
@ BLE_GATT_UNIT_SURFACE_TENSION_NEWTON_PER_METRE
Surface tension, newton per meter.
@ BLE_GATT_UNIT_WAVENUMBER_RECIPROCAL_METRE
Wave number reciprocal, meter.
@ BLE_GATT_UNIT_PRESSURE_BAR
Pressure, bar.
@ BLE_GATT_UNIT_ANGULAR_VELOCITY_RADIAN_PER_SECOND
Angular velocity, radian per second.
@ BLE_GATT_UNIT_AMOUNT_OF_SUBSTANCE_MOLE
Amount of substance, mole.
@ BLE_GATT_UNIT_ELECTRIC_RESISTANCE_OHM
Electric resistance, ohm.
@ BLE_GATT_UNIT_POWER_WATT
Power, watt.
@ BLE_GATT_UNIT_CONCENTRATION_COUNT_PER_CUBIC_METRE
Concentration, count per cubic meter.
@ BLE_GATT_UNIT_PLANE_ANGLE_RADIAN
Plane angle (radian).
@ BLE_GATT_UNIT_ANGULAR_VELOCITY_REVOLUTION_PER_MINUTE
Angular Velocity, revolution per minute.
@ BLE_GATT_UNIT_MAGNETIC_FIELD_STRENGTH_AMPERE_PER_METRE
Magnetic field strength, ampere per meter.
@ BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_CELSIUS
Celsius temperature, degree Celsius.
@ BLE_GATT_UNIT_ELECTRIC_FIELD_STRENGTH_VOLT_PER_METRE
Electric field strength, volt per meter.
@ BLE_GATT_UNIT_PERIOD_BEATS_PER_MINUTE
Period, beats per minute.
@ BLE_GATT_UNIT_RADIANCE_WATT_PER_SQUARE_METRE_STERADIAN
Radiance, watt per square meter steradian.
@ BLE_GATT_UNIT_PRESSURE_MILLIMETRE_OF_MERCURY
Pressure, millimeter of mercury.
@ BLE_GATT_UNIT_SURFACE_CHARGE_DENSITY_COULOMB_PER_SQUARE_METRE
Surface charge density, coulomb per square meter.
@ BLE_GATT_UNIT_THERMAL_CONDUCTIVITY_WATT_PER_METRE_KELVIN
Thermal conductivity, watt per meter kelvin.
@ BLE_GATT_UNIT_RELATIVE_PERMEABILITY
Relative permeability.
@ BLE_GATT_UNIT_MASS_KILOGRAM
Mass, kilogram.
@ BLE_GATT_UNIT_SPECIFIC_VOLUME_CUBIC_METRE_PER_KILOGRAM
Specific volume (cubic meter per kilogram).
@ BLE_GATT_UNIT_ENERGY_KILOGRAM_CALORIE
Energy, kilogram calorie.
@ BLE_GATT_UNIT_TIME_HOUR
Time, hour.
@ BLE_GATT_UNIT_PERMITTIVITY_FARAD_PER_METRE
Permittivity, farad per meter.
@ BLE_GATT_UNIT_IRRADIANCE_WATT_PER_SQUARE_METRE
Irradiance, watt per square meter.
@ BLE_GATT_UNIT_EXPOSURE_COULOMB_PER_KILOGRAM
Exposure, coulomb per kilogram.
const FunctionPointerWithContext< GattReadAuthCallbackParams * > & getReadAuthorizationCallback() const
Return the callback registered to handle client's read.
void setReadAuthorizationCallback(T *object, void(T::*member)(GattReadAuthCallbackParams *))
Register the read requests event handler.
GattAttribute * getDescriptor(uint8_t index)
Get this characteristic's descriptor at a specific index.
GattAuthCallbackReply_t authorizeWrite(GattWriteAuthCallbackParams *params)
Invoke the write authorization callback.
ble::att_security_requirement_t SecurityRequirement_t
Security level applied to GATT operations.
void setUpdateSecurityRequirement(SecurityRequirement_t security)
Set the security requirement of update operations.
const GattAttribute & getValueAttribute() const
Get the characteristic's value attribute.
bool isReadAuthorizationEnabled() const
Check whether read authorization is enabled.
void setReadSecurityRequirement(SecurityRequirement_t security)
Set the security of the read operation.
void setWriteAuthorizationCallback(T *object, void(T::*member)(GattWriteAuthCallbackParams *))
Register a callback handling client's write requests or commands.
void setWriteSecurityRequirement(SecurityRequirement_t security)
Set the security requirement of the write operations.
SecurityRequirement_t getWriteSecurityRequirement() const
Get the security requirement of write operations.
GattAttribute & getValueAttribute()
Get the characteristic's value attribute.
@ BLE_GATT_FORMAT_STRUCT
Opaque Structure.
@ BLE_GATT_FORMAT_UINT64
Unsigned 64-bit integer.
@ BLE_GATT_FORMAT_UINT12
Unsigned 12-bit integer.
@ BLE_GATT_FORMAT_SINT48
Signed 48-bit integer.
@ BLE_GATT_FORMAT_SINT24
Signed 24-bit integer.
@ BLE_GATT_FORMAT_UINT32
Unsigned 32-bit integer.
@ BLE_GATT_FORMAT_UINT16
Unsigned 16-bit integer.
@ BLE_GATT_FORMAT_NIBBLE
Unsigned 4-bit integer.
@ BLE_GATT_FORMAT_UINT128
Unsigned 128-bit integer.
@ BLE_GATT_FORMAT_SINT8
Signed 8-bit integer.
@ BLE_GATT_FORMAT_SINT16
Signed 16-bit integer.
@ BLE_GATT_FORMAT_DUINT16
IEEE-20601 format.
@ BLE_GATT_FORMAT_SFLOAT
IEEE-11073 16-bit SFLOAT.
@ BLE_GATT_FORMAT_FLOAT64
IEEE-754 64-bit floating point.
@ BLE_GATT_FORMAT_UINT48
Unsigned 48-bit integer.
@ BLE_GATT_FORMAT_2BIT
Unsigned 2-bit integer.
@ BLE_GATT_FORMAT_FLOAT32
IEEE-754 32-bit floating point.
@ BLE_GATT_FORMAT_RFU
Reserved for future use.
@ BLE_GATT_FORMAT_FLOAT
IEEE-11073 32-bit FLOAT.
@ BLE_GATT_FORMAT_UTF16S
UTF16 string.
@ BLE_GATT_FORMAT_SINT128
Signed 128-bit integer.
@ BLE_GATT_FORMAT_SINT32
Signed 32-bit integer.
@ BLE_GATT_FORMAT_SINT12
Signed 12-bit integer.
@ BLE_GATT_FORMAT_SINT64
Signed 64-bit integer.
@ BLE_GATT_FORMAT_UINT24
Unsigned 24-bit integer.
@ BLE_GATT_FORMAT_UINT8
Unsigned 8-bit integer.
void setWriteAuthorizationCallback(void(*callback)(GattWriteAuthCallbackParams *))
Register a callback handling client's write requests or commands.
SecurityRequirement_t getUpdateSecurityRequirement() const
Get the security requirement of update operations.
@ UUID_RSC_FEATURE_CHAR
Characteristic of the Running Speed and Cadence (RSC) service that exposes features supported by the ...
@ UUID_BATTERY_LEVEL_CHAR
Characteristic of the Battery service, which exposes the current battery level as a percentage.
@ UUID_MANUFACTURER_NAME_STRING_CHAR
Characteristic of the Device Information Service that contains a UTF8 string representing the manufac...
@ UUID_PNP_ID_CHAR
Characteristic of the Device Information Service; it is a set of values used to create a device ID th...
@ UUID_NEW_ALERT_CHAR
Characteristic of the Alert Notification Service that defines the category of the alert and how many ...
@ UUID_DAY_DATE_TIME_CHAR
Not used in a service as a characteristic.
@ UUID_REFERENCE_TIME_INFORMATION_CHAR
Characteristic of the Current Time service that exposes information related to the current time serve...
@ UUID_DATE_TIME_CHAR
Not used in a service as a characteristic.
@ UUID_HEART_RATE_CONTROL_POINT_CHAR
Characteristic of the Heart Rate service used by the client to control the service behavior.
@ UUID_CSC_FEATURE_CHAR
Characteristic of the Cycling Speed and Cadence (CSC) service that exposes features supported by the ...
@ UUID_EXACT_TIME_256_CHAR
Not used in a service as a characteristic.
@ UUID_REPORT_CHAR
Part of the Human Interface Device service.
@ UUID_SCAN_INTERVAL_WINDOW_CHAR
Characteristic of the Scan Parameter service that stores the client's scan parameters (scan interval ...
@ UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR
Part of the Human Interface Device service.
@ UUID_HID_CONTROL_POINT_CHAR
Part of the Human Interface Device service.
@ UUID_INTERMEDIATE_TEMPERATURE_CHAR
Characteristic of the Health Thermometer service that sends intermediate temperature values while the...
@ UUID_TIME_UPDATE_STATE_CHAR
Characteristic of the Reference Time service that informs clients of the status of the time update op...
@ UUID_TIME_WITH_DST_CHAR
Characteristic of the Next DST Change service that returns to clients the time with DST.
@ UUID_GLUCOSE_FEATURE_CHAR
Characteristic of the Glucose service that exposes features supported by the server.
@ UUID_ALERT_LEVEL_CHAR
Control point of the Immediate Alert service that allows the client to command the server to alert to...
@ UUID_REMOVABLE_CHAR
Not used in actual BLE service.
@ UUID_BODY_SENSOR_LOCATION_CHAR
Characteristic of the Heart Rate service that indicate the intended location of the heart rate monito...
@ UUID_TEMPERATURE_CHAR
Characteristic of the Environmental Sensing service that exposes the temperature measurement with a r...
@ UUID_RINGER_SETTING_CHAR
Characteristic of the Phone Alert Status service that returns the ringer setting when read.
@ UUID_GLUCOSE_MEASUREMENT_CONTEXT_CHAR
Characteristic of the Glucose service that sends additional information related to the glucose measur...
@ UUID_BATTERY_LEVEL_STATE_CHAR
Not used in actual BLE service.
@ UUID_HARDWARE_REVISION_STRING_CHAR
Characteristic of the Device Information Service that contains a UTF8 string representing the hardwar...
@ UUID_PROTOCOL_MODE_CHAR
Part of the Human Interface Device service.
@ UUID_SUPPORTED_NEW_ALERT_CATEGORY_CHAR
Characteristic of the Alert Notification Service that notifies the count of new alerts for a given ca...
@ UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR
Part of the Human Interface Device service.
@ UUID_SCAN_REFRESH_CHAR
Characteristic of the Scan Parameter service that sends a notification to a client when the server re...
@ UUID_MODEL_NUMBER_STRING_CHAR
Characteristic of the Device Information Service that contains a UTF8 string representing the model n...
@ UUID_BLOOD_PRESSURE_FEATURE_CHAR
Describe the features supported by the blood pressure sensor exposed by the Blood Pressure service.
@ UUID_REPORT_MAP_CHAR
Part of the Human Interface Device service.
@ UUID_PRESSURE_CHAR
Characteristic of the Environmental Sensing Service that exposes the pressure measured.
@ UUID_ALERT_STATUS_CHAR
Part of the Alert Notification service, which exposes the count of unread alert events existing in th...
@ UUID_TX_POWER_LEVEL_CHAR
Characteristic of the TX Power service that exposes the current transmission power in dBm.
@ UUID_TEMPERATURE_MEASUREMENT_CHAR
Characteristic of the Health Thermometer service that sends temperature measurement to clients.
@ UUID_SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR
Characteristic of the Alert Notification service, which exposes categories of unread alert supported ...
@ UUID_MEASUREMENT_INTERVAL_CHAR
Characteristic of the Health Thermometer service that exposes the interval time between two measureme...
@ UUID_CSC_MEASUREMENT_CHAR
Characteristic of the Cycling Speed and Cadence (CSC) service that exposes measurements made by the s...
@ UUID_UNREAD_ALERT_CHAR
Characteristic of the Alert Notification Service that shows how many numbers of unread alerts exist i...
@ UUID_RINGER_CONTROL_POINT_CHAR
Characteristic of the Phone Alert Status service that allows a client to configure operating mode.
@ UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR
Characteristic of the Device Information Service, which exposes various regulatory or certification c...
@ UUID_DST_OFFSET_CHAR
Not used in a service as a characteristic.
@ UUID_SOFTWARE_REVISION_STRING_CHAR
Characteristic of the Device Information Service that contains an UTF8 string representing the softwa...
@ UUID_HUMIDITY_CHAR
Characteristic of the Environmental Sensing service, which exposes humidity measurements.
@ UUID_SYSTEM_ID_CHAR
Characteristic of the Device Information Service that exposes a structure containing an Organizationa...
@ UUID_HID_INFORMATION_CHAR
Part of the Human Interface Device service.
@ UUID_RSC_MEASUREMENT_CHAR
Characteristic of the Running Speed and Cadence (RSC) service that exposes measurements made by the s...
@ UUID_TEMPERATURE_TYPE_CHAR
Characteristic of the Health Thermometer service that describes where the measurement takes place.
@ UUID_BATTERY_POWER_STATE_CHAR
Not used in actual BLE service.
@ UUID_HEART_RATE_MEASUREMENT_CHAR
Characteristic of the Heart Rate that sends heart rate measurements to registered clients.
@ UUID_GLUCOSE_MEASUREMENT_CHAR
Characteristic of the Glucose service that exposes glucose measurements.
@ UUID_SERVICE_REQUIRED_CHAR
Not used in actual BLE service.
@ UUID_TIME_SOURCE_CHAR
Not used in a service as a characteristic.
@ UUID_TIME_UPDATE_CONTROL_POINT_CHAR
Characteristic of the Reference Time service that allows clients to control time update.
@ UUID_SERIAL_NUMBER_STRING_CHAR
Characteristic of the Device Information Service that contains a UTF8 string representing the serial ...
@ UUID_BLOOD_PRESSURE_MEASUREMENT_CHAR
Characteristic of the Blood Pressure service that exposes the measurement of the blood sensor.
@ UUID_DAY_OF_WEEK_CHAR
Not used in a service as a characteristic.
@ UUID_LOCAL_TIME_INFORMATION_CHAR
Characteristic of the current Time service that exposes information about the local time.
@ UUID_INTERMEDIATE_CUFF_PRESSURE_CHAR
Characteristic of the Blood Pressure service, which exposes intermediate cuff pressure measurements.
@ UUID_TIME_ACCURACY_CHAR
Not used in a service as a characteristic.
@ UUID_ALERT_NOTIFICATION_CONTROL_POINT_CHAR
Control point of the Alert Notification service that allows the client finely tune the notification c...
@ UUID_ALERT_CATEGORY_ID_BIT_MASK_CHAR
Not used as a characteristic UUID.
@ UUID_TIME_ZONE_CHAR
Not used in a service as a characteristic.
@ UUID_ALERT_CATEGORY_ID_CHAR
Not used as a characteristic UUID.
@ UUID_CURRENT_TIME_CHAR
Characteristic of the Current Time service that contains the current time.
@ UUID_FIRMWARE_REVISION_STRING_CHAR
Characteristic of the Device Information Service that contains a UTF8 string representing the firmwar...
@ UUID_RECORD_ACCESS_CONTROL_POINT_CHAR
Pulse Oxymeter, Glucose and Continuous Glucose Monitoring services use this control point to provide ...
@ UUID_BOOT_MOUSE_INPUT_REPORT_CHAR
Part of the Human Interface Device service.
Helper class that represents a read-only GattCharacteristic with an array value.
ReadOnlyArrayGattCharacteristic(const UUID &uuid, T valuePtr[NUM_ELEMENTS], uint8_t additionalProperties=BLE_GATT_CHAR_PROPERTIES_NONE, GattAttribute *descriptors[]=nullptr, unsigned numDescriptors=0)
Construct a ReadOnlyGattCharacteristic.
Helper class that represents a read only GattCharacteristic.
ReadOnlyGattCharacteristic(const UUID &uuid, T *valuePtr, uint8_t additionalProperties=BLE_GATT_CHAR_PROPERTIES_NONE, GattAttribute *descriptors[]=nullptr, unsigned numDescriptors=0)
Construct a ReadOnlyGattCharacteristic.
Helper class that represents a readable and writable GattCharacteristic with an array value.
ReadWriteArrayGattCharacteristic(const UUID &uuid, T valuePtr[NUM_ELEMENTS], uint8_t additionalProperties=BLE_GATT_CHAR_PROPERTIES_NONE, GattAttribute *descriptors[]=nullptr, unsigned numDescriptors=0)
Construct a ReadWriteGattCharacteristic.
Helper class that represents a readable and writable GattCharacteristic.
ReadWriteGattCharacteristic(const UUID &uuid, T *valuePtr, uint8_t additionalProperties=BLE_GATT_CHAR_PROPERTIES_NONE, GattAttribute *descriptors[]=nullptr, unsigned numDescriptors=0)
Construct a ReadWriteGattCharacteristic.
Representation of a Universally Unique Identifier (UUID).
Definition: common/UUID.h:76
Helper class that represents a write-only GattCharacteristic with an array value.
WriteOnlyArrayGattCharacteristic(const UUID &uuid, T valuePtr[NUM_ELEMENTS], uint8_t additionalProperties=BLE_GATT_CHAR_PROPERTIES_NONE, GattAttribute *descriptors[]=nullptr, unsigned numDescriptors=0)
Construct a WriteOnlyGattCharacteristic.
Helper class that represents a write only GattCharacteristic.
WriteOnlyGattCharacteristic(const UUID &uuid, T *valuePtr, uint8_t additionalProperties=BLE_GATT_CHAR_PROPERTIES_NONE, GattAttribute *descriptors[]=nullptr, unsigned numDescriptors=0)
Construct a WriteOnlyGattCharacteristic.
#define MBED_ASSERT(expr)
MBED_ASSERT Declare runtime assertions: results in runtime error if condition is false.
Definition: mbed_assert.h:66
GattAuthCallbackReply_t
Enumeration of allowed values returned by read or write authorization process.
@ AUTH_CALLBACK_REPLY_SUCCESS
Success.
Entry namespace for all BLE API definitions.
Value of a Characteristic Presentation Format descriptor.
uint8_t gatt_namespace
Namespace of the description field.
uint16_t gatt_unit
Unit of the characteristic value.
int8_t exponent
Exponent for integer data types.
GATT read authorization request event.
GattAuthCallbackReply_t authorizationReply
Authorization result.
GATT write authorization request event.
GattAuthCallbackReply_t authorizationReply
Authorization result.
LayoutType value() const
Explicit access to the inner value of the SafeEnum instance.
Security requirement that can be attached to an attribute operation.
static const uint8_t size
Number of bits required to store the value.
type
struct scoped enum wrapped by the class
@ SC_AUTHENTICATED
The operation require encryption with an authenticated peer that paired using secure connection pairi...
@ UNAUTHENTICATED
The operation requires security and there's no requirement towards peer authentication.
@ NONE
The operation does not have security requirements.