Mistake on this page?
Report an issue in GitHub or email us
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 /**
28  * @addtogroup ble
29  * @{
30  * @addtogroup gatt
31  * @{
32  * @addtogroup server
33  * @{
34  */
35 
36 /**
37  * Representation of a GattServer characteristic.
38  *
39  * A characteristic is a typed value enclosed in a GATT service (GattService).
40  *
41  * @par Type
42  *
43  * The type of the value defines the purpose of the characteristic, and a
44  * UUID represents it. Standard characteristic types may be consulted at
45  * https://www.bluetooth.com/specifications/gatt/characteristics
46  *
47  * @par Supported operations
48  * A set of properties define what client operations the characteristic
49  * supports. See GattServer::Properties_t
50  *
51  * @par Descriptors
52  *
53  * Additional information, such as the unit of the characteristic value, a
54  * description string or a client control point, can be added to the
55  * characteristic.
56  *
57  * See BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] - 3.3.1.1
58  *
59  * One of the most important types of descriptor is the Client Characteristic
60  * Configuration Descriptor (CCCD) that must be present if the characteristic
61  * properties allow a client to subscribe to updates of the characteristic
62  * value.
63  *
64  * @par Characteristic breakdown
65  *
66  * A characteristic is composed of several GATT attributes (GattAttribute):
67  * - Characteristic declaration: It contains the properties of the
68  * characteristic, its type and the handle of its value.
69  * - Characteristic value: The value of the characteristic.
70  * - Descriptors: A single GATT attribute stores each descriptor.
71  *
72  * When the GattService containing the characteristic is registered in the
73  * GattServer, a unique attribute handle is assigned to the various attributes
74  * of the characteristic. Clients use this handle to interact with the
75  * characteristic. This handle is used locally in GattServer APIs.
76  *
77  * @par Security requirements
78  *
79  * Verification of security requirements happens whenever a client request to
80  * read the characteristic; write it or even register to its updates. Different
81  * requirements may be defined for these three type of operation. As an example:
82  * it is possible to define a characteristic that do not require security to be
83  * read and require an authenticated link to be written.
84  *
85  * By default all security requirements are set to att_security_requirement_t::NONE
86  * except if the characteristic supports signed write; in such case the security
87  * requirement for write operations is set to att_security_requirement_t::UNAUTHENTICATED.
88  *
89  * @note If a peer uses an operation that is not set in the characteristic
90  * properties then the request request is discarded regardless of the security
91  * requirements and current security level. The only exception being signed
92  * write: signed write are converted into regular write without response if
93  * the link is encrypted.
94  */
96 public:
97 
98  /*
99  * Enumeration of characteristic UUID defined by the Bluetooth body.
100  */
101  enum {
102  /**
103  * Not used in actual BLE service.
104  */
106 
107  /**
108  * Not used in actual BLE service.
109  */
111 
112  /**
113  * Not used in actual BLE service.
114  */
116 
117  /**
118  * Not used in actual BLE service.
119  */
121 
122  /**
123  * Not used as a characteristic UUID.
124  */
126 
127  /**
128  * Not used as a characteristic UUID.
129  */
131 
132  /**
133  * Control point of the Immediate Alert service that allows the client to
134  * command the server to alert to a given level.
135  */
137 
138  /**
139  * Control point of the Alert Notification service that allows the client
140  * finely tune the notification configuration.
141  */
143 
144  /**
145  * Part of the Alert Notification service, which exposes the count of
146  * unread alert events existing in the server.
147  */
149 
150  /**
151  * Characteristic of the Battery service, which exposes the current
152  * battery level as a percentage.
153  */
155 
156  /**
157  * Describe the features supported by the blood pressure sensor exposed
158  * by the Blood Pressure service.
159  */
161 
162  /**
163  * Characteristic of the Blood Pressure service that exposes the
164  * measurement of the blood sensor.
165  */
167 
168  /**
169  * Characteristic of the Heart Rate service that indicate the intended
170  * location of the heart rate monitor.
171  */
173 
174  /**
175  * Part of the Human Interface Device service.
176  */
178 
179  /**
180  * Part of the Human Interface Device service.
181  */
183 
184  /**
185  * Part of the Human Interface Device service.
186  */
188 
189  /**
190  * Characteristic of the Current Time service that contains the current
191  * time.
192  */
194 
195  /**
196  * Not used in a service as a characteristic.
197  */
199 
200  /**
201  * Not used in a service as a characteristic.
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  * Characteristic of the Device Information Service that contains a
222  * UTF8 string representing the firmware revision for the firmware within
223  * the device.
224  */
226 
227  /**
228  * Characteristic of the Glucose service that exposes features supported
229  * by the server.
230  */
232 
233  /**
234  * Characteristic of the Glucose service that exposes glucose
235  * measurements.
236  */
238 
239  /**
240  * Characteristic of the Glucose service that sends additional
241  * information related to the glucose measurements.
242  */
244 
245  /**
246  * Characteristic of the Device Information Service that contains a
247  * UTF8 string representing the hardware revision of the device.
248  */
250 
251  /**
252  * Characteristic of the Heart Rate service used by the client to control
253  * the service behavior.
254  */
256 
257  /**
258  * Characteristic of the Heart Rate that sends heart rate measurements to
259  * registered clients.
260  */
262 
263  /**
264  * Part of the Human Interface Device service.
265  */
267 
268  /**
269  * Part of the Human Interface Device service.
270  */
272 
273  /**
274  * Characteristic of the Environmental Sensing service, which exposes
275  * humidity measurements.
276  */
278 
279  /**
280  * Characteristic of the Device Information Service, which exposes
281  * various regulatory or certification compliance items to which the
282  * device claims adherence.
283  */
285 
286  /**
287  * Characteristic of the Blood Pressure service, which exposes intermediate
288  * cuff pressure measurements.
289  */
291 
292  /**
293  * Characteristic of the Health Thermometer service that sends intermediate
294  * temperature values while the measurement is in progress.
295  */
297 
298  /**
299  * Characteristic of the current Time service that exposes information
300  * about the local time.
301  */
303 
304  /**
305  * Characteristic of the Device Information Service that contains a
306  * UTF8 string representing the manufacturer name of the device.
307  */
309 
310  /**
311  * Characteristic of the Health Thermometer service that exposes the
312  * interval time between two measurements.
313  */
315 
316  /**
317  * Characteristic of the Device Information Service that contains a
318  * UTF8 string representing the model number of the device assigned by
319  * the vendor.
320  */
322 
323  /**
324  * Characteristic of the Alert Notification Service that shows how many
325  * numbers of unread alerts exist in the specific category in the device.
326  */
328 
329  /**
330  * Characteristic of the Alert Notification Service that defines the
331  * category of the alert and how many new alerts of that category have
332  * occurred in the server.
333  */
335 
336  /**
337  * Characteristic of the Device Information Service; it is a set of
338  * values used to create a device ID that is unique for this device.
339  */
341 
342  /**
343  * Characteristic of the Environmental Sensing Service that exposes the
344  * pressure measured.
345  */
347 
348  /**
349  * Part of the Human Interface Device service.
350  */
352 
353  /**
354  * Pulse Oxymeter, Glucose and Continuous Glucose Monitoring services
355  * use this control point to provide basic management of the patient
356  * record database.
357  */
359 
360  /**
361  * Characteristic of the Current Time service that exposes information
362  * related to the current time served (accuracy, source, hours since
363  * update and so on).
364  */
366 
367  /**
368  * Part of the Human Interface Device service.
369  */
371 
372  /**
373  * Part of the Human Interface Device service.
374  */
376 
377  /**
378  * Characteristic of the Phone Alert Status service that allows a client
379  * to configure operating mode.
380  */
382 
383  /**
384  * Characteristic of the Phone Alert Status service that returns the
385  * ringer setting when read.
386  */
388 
389  /**
390  * Characteristic of the Scan Parameter service that stores the client's
391  * scan parameters (scan interval and scan window).
392  */
394 
395  /**
396  * Characteristic of the Scan Parameter service that sends a notification
397  * to a client when the server requires its latest scan parameters.
398  */
400 
401  /**
402  * Characteristic of the Device Information Service that contains a
403  * UTF8 string representing the serial number of the device.
404  */
406 
407  /**
408  * Characteristic of the Device Information Service that contains an
409  * UTF8 string representing the software revision of the device.
410  */
412 
413  /**
414  * Characteristic of the Alert Notification Service that notifies the
415  * count of new alerts for a given category to a subscribed client.
416  */
418 
419  /**
420  * Characteristic of the Alert Notification service, which exposes
421  * categories of unread alert supported by the server.
422  */
424 
425  /**
426  * Characteristic of the Device Information Service that exposes a
427  * structure containing an Organizationally Unique Identifier (OUI)
428  * followed by a manufacturer-defined identifier. The value of the
429  * structure is unique for each individual instance of the product.
430  */
432 
433  /**
434  * Characteristic of the Environmental Sensing service that exposes the
435  * temperature measurement with a resolution of 0.01 degree Celsius.
436  */
438 
439  /**
440  * Characteristic of the Health Thermometer service that sends temperature
441  * measurement to clients.
442  */
444 
445  /**
446  * Characteristic of the Health Thermometer service that describes
447  * where the measurement takes place.
448  */
450 
451  /**
452  * Not used in a service as a characteristic.
453  */
455 
456  /**
457  * Not used in a service as a characteristic.
458  */
460 
461  /**
462  * Characteristic of the Reference Time service that allows clients to
463  * control time update.
464  */
466 
467  /**
468  * Characteristic of the Reference Time service that informs clients of
469  * the status of the time update operation.
470  */
472 
473  /**
474  * Characteristic of the Next DST Change service that returns to clients
475  * the time with DST.
476  */
478 
479  /**
480  * Not used in a service as a characteristic.
481  */
483 
484  /**
485  * Characteristic of the TX Power service that exposes the current
486  * transmission power in dBm.
487  */
489 
490  /**
491  * Characteristic of the Cycling Speed and Cadence (CSC) service that
492  * exposes features supported by the server.
493  */
495 
496  /**
497  * Characteristic of the Cycling Speed and Cadence (CSC) service that
498  * exposes measurements made by the server.
499  */
501 
502  /**
503  * Characteristic of the Running Speed and Cadence (RSC) service that
504  * exposes features supported by the server.
505  */
507 
508  /**
509  * Characteristic of the Running Speed and Cadence (RSC) service that
510  * exposes measurements made by the server.
511  */
513  };
514 
515  /**
516  * Unit type of a characteristic value.
517  *
518  * These unit types are used to describe what the raw numeric data in a
519  * characteristic actually represents. A server can expose that information
520  * to its clients by adding a Characteristic Presentation Format descriptor
521  * to relevant characteristics.
522  *
523  * @note See https://developer.bluetooth.org/gatt/units/Pages/default.aspx
524  */
525  enum {
526 
527  /**
528  * No specified unit type.
529  */
531 
532  /**
533  * Length, meter.
534  */
536 
537  /**
538  * Mass, kilogram.
539  */
541 
542  /**
543  * Time, second.
544  */
546 
547  /**
548  * Electric current, ampere.
549  */
551 
552  /**
553  * Thermodynamic temperature, kelvin.
554  */
556 
557  /** Amount of substance, mole.
558  *
559  */
561 
562  /**
563  * Luminous intensity, candela.
564  */
566 
567  /**
568  * Area, square meters.
569  */
571 
572  /**
573  * Volume, cubic meters.
574  */
576 
577  /**
578  * Velocity, meters per second.
579  */
581 
582  /**
583  * Acceleration, meters per second squared.
584  */
586 
587  /**
588  * Wave number reciprocal, meter.
589  */
591 
592  /**
593  * Density, kilogram per cubic meter.
594  */
596 
597  /**
598  * Surface density (kilogram per square meter).
599  */
601 
602  /**
603  * Specific volume (cubic meter per kilogram).
604  */
606 
607  /**
608  * Current density (ampere per square meter).
609  */
611 
612  /**
613  * Magnetic field strength, ampere per meter.
614  */
616 
617  /**
618  * Amount concentration (mole per cubic meter).
619  */
621 
622  /**
623  * Mass concentration (kilogram per cubic meter).
624  */
626 
627  /**
628  * Luminance (candela per square meter).
629  */
631 
632  /**
633  * Refractive index.
634  */
636 
637  /**
638  * Relative permeability.
639  */
641 
642  /**
643  * Plane angle (radian).
644  */
646 
647  /**
648  * Solid angle (steradian).
649  */
651 
652  /**
653  * Frequency, hertz.
654  */
656 
657  /**
658  * Force, newton.
659  */
661 
662  /**
663  * Pressure, pascal.
664  */
666 
667  /**
668  * Energy, joule.
669  */
671 
672  /**
673  * Power, watt.
674  */
676 
677  /**
678  * Electrical charge, coulomb.
679  */
681 
682  /**
683  * Electrical potential difference, voltage.
684  */
686 
687  /**
688  * Capacitance, farad.
689  */
691 
692  /**
693  * Electric resistance, ohm.
694  */
696 
697  /**
698  * Electric conductance, siemens.
699  */
701 
702  /**
703  * Magnetic flux, weber.
704  */
706 
707  /**
708  * Magnetic flux density, tesla.
709  */
711 
712  /**
713  * Inductance, henry.
714  */
716 
717  /**
718  * Celsius temperature, degree Celsius.
719  */
721 
722  /**
723  * Luminous flux, lumen.
724  */
726 
727  /**
728  * Illuminance, lux.
729  */
731 
732  /**
733  * Activity referred to a radionuclide, becquerel.
734  */
736 
737  /**
738  * Absorbed dose, gray.
739  */
741 
742  /**
743  * Dose equivalent, sievert.
744  */
746 
747  /**
748  * Catalytic activity, katal.
749  */
751 
752  /**
753  * Dynamic viscosity, pascal second.
754  */
756 
757  /**
758  * Moment of force, newton meter.
759  */
761 
762  /**
763  * Surface tension, newton per meter.
764  */
766 
767  /**
768  * Angular velocity, radian per second.
769  */
771 
772  /**
773  * Angular acceleration, radian per second squared.
774  */
776 
777  /**
778  * Heat flux density, watt per square meter.
779  */
781 
782  /**
783  * Heat capacity, joule per kelvin.
784  */
786 
787  /**
788  * Specific heat capacity, joule per kilogram kelvin.
789  */
791 
792  /**
793  * Specific energy, joule per kilogram.
794  */
796 
797  /**
798  * Thermal conductivity, watt per meter kelvin.
799  */
801 
802  /**
803  * Energy density, joule per cubic meter.
804  */
806 
807  /**
808  * Electric field strength, volt per meter.
809  */
811 
812  /**
813  * Electric charge density, coulomb per cubic meter.
814  */
816 
817  /**
818  * Surface charge density, coulomb per square meter.
819  */
821 
822  /**
823  * Electric flux density, coulomb per square meter.
824  */
826 
827  /**
828  * Permittivity, farad per meter.
829  */
831 
832  /**
833  * Permeability, henry per meter.
834  */
836 
837  /**
838  * Molar energy, joule per mole.
839  */
841 
842  /**
843  * Molar entropy, joule per mole kelvin.
844  */
846 
847  /**
848  * Exposure, coulomb per kilogram.
849  */
851 
852  /**
853  * Absorbed dose rate, gray per second.
854  */
856 
857  /**
858  * Radiant intensity, watt per steradian.
859  */
861 
862  /**
863  * Radiance, watt per square meter steradian.
864  */
866 
867  /**
868  * Catalytic activity concentration, katal per cubic meter.
869  */
871 
872  /**
873  * Time, minute.
874  */
876 
877  /**
878  * Time, hour.
879  */
881 
882  /**
883  * Time, day.
884  */
886 
887  /**
888  * Plane angle, degree.
889  */
891 
892  /**
893  * Plane angle, minute.
894  */
896 
897  /**
898  * Plane angle, seconds.
899  */
901 
902  /**
903  * Area, hectare.
904  */
906 
907  /**
908  * Volume, liter.
909  */
911 
912  /**
913  * Mass, ton.
914  */
916 
917  /**
918  * Pressure, bar.
919  */
921 
922  /**
923  * Pressure, millimeter of mercury.
924  */
926 
927  /**
928  * Length, ngstrm.
929  */
931 
932  /**
933  * Length, nautical mile.
934  */
936 
937  /**
938  * Area, barn.
939  */
941 
942  /**
943  * Velocity, knot.
944  */
946 
947  /**
948  * Logarithmic radio quantity, neper.
949  */
951 
952  /**
953  * Logarithmic radio quantity, bel.
954  */
956 
957  /**
958  * Length, yard.
959  */
961 
962  /**
963  * Length, parsec.
964  */
966 
967  /**
968  * Length, inch.
969  */
971 
972  /**
973  * Length, foot.
974  */
976 
977  /**
978  * Length, mile.
979  */
981 
982  /**
983  * Pressure, pound-force per square inch.
984  */
986 
987  /**
988  * Velocity, kilometer per hour.
989  */
991 
992  /** Velocity, mile per hour.
993  *
994  */
996 
997  /**
998  * Angular Velocity, revolution per minute.
999  */
1001 
1002  /**
1003  * Energy, gram calorie.
1004  */
1006 
1007  /**
1008  * Energy, kilogram calorie.
1009  */
1011 
1012  /**
1013  * Energy, killowatt hour.
1014  */
1016 
1017  /**
1018  * Thermodynamic temperature, degree Fahrenheit.
1019  */
1021 
1022  /**
1023  * Percentage.
1024  */
1026 
1027  /**
1028  * Per mille.
1029  */
1031 
1032  /**
1033  * Period, beats per minute.
1034  */
1036 
1037  /**
1038  * Electric charge, ampere hours.
1039  */
1041 
1042  /**
1043  * Mass density, milligram per deciliter.
1044  */
1046 
1047  /**
1048  * Mass density, millimole per liter.
1049  */
1051 
1052  /**
1053  * Time, year.
1054  */
1056 
1057  /**
1058  * Time, month.
1059  */
1061 
1062  /**
1063  * Concentration, count per cubic meter.
1064  */
1066 
1067  /**
1068  * Irradiance, watt per square meter.
1069  */
1071  };
1072 
1073  /**
1074  * Presentation format of a characteristic.
1075  *
1076  * It determines how the value of a characteristic is formatted. A server
1077  * can expose that information to its clients by adding a Characteristic
1078  * Presentation Format descriptor to relevant characteristics.
1079  *
1080  * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5.2.
1081  */
1082  enum {
1083  /**
1084  * Reserved for future use.
1085  */
1087 
1088  /**
1089  * Boolean.
1090  */
1092 
1093  /**
1094  * Unsigned 2-bit integer.
1095  */
1097 
1098  /**
1099  * Unsigned 4-bit integer.
1100  */
1102 
1103  /**
1104  * Unsigned 8-bit integer.
1105  */
1107 
1108  /**
1109  * Unsigned 12-bit integer.
1110  */
1112 
1113  /**
1114  * Unsigned 16-bit integer.
1115  */
1117 
1118  /**
1119  * Unsigned 24-bit integer.
1120  */
1122 
1123  /**
1124  * Unsigned 32-bit integer.
1125  */
1127 
1128  /**
1129  * Unsigned 48-bit integer.
1130  */
1132 
1133  /**
1134  * Unsigned 64-bit integer.
1135  */
1137 
1138  /**
1139  * Unsigned 128-bit integer.
1140  */
1142 
1143  /**
1144  * Signed 8-bit integer.
1145  */
1147 
1148  /**
1149  * Signed 12-bit integer.
1150  */
1152 
1153  /**
1154  * Signed 16-bit integer.
1155  */
1157 
1158  /**
1159  * Signed 24-bit integer.
1160  */
1162 
1163  /**
1164  * Signed 32-bit integer.
1165  */
1167 
1168  /**
1169  * Signed 48-bit integer.
1170  */
1172 
1173  /**
1174  * Signed 64-bit integer.
1175  */
1177 
1178  /**
1179  * Signed 128-bit integer.
1180  */
1182 
1183  /**
1184  * IEEE-754 32-bit floating point.
1185  */
1187 
1188  /**
1189  * IEEE-754 64-bit floating point.
1190  */
1192 
1193  /**
1194  * IEEE-11073 16-bit SFLOAT.
1195  */
1197 
1198  /**
1199  * IEEE-11073 32-bit FLOAT.
1200  */
1202 
1203  /**
1204  * IEEE-20601 format.
1205  */
1207 
1208  /**
1209  * UTF8 string.
1210  */
1212 
1213  /**
1214  * UTF16 string.
1215  */
1217 
1218  /**
1219  * Opaque Structure.
1220  */
1222  };
1223 
1224  /*!
1225  * Characteristic properties.
1226  *
1227  * It is a bitfield that determines how a characteristic value can be used.
1228  *
1229  * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.1.1
1230  * and Section 3.3.3.1 for Extended Properties.
1231  */
1233  /**
1234  * No property defined.
1235  */
1237 
1238  /**
1239  * Permits broadcasts of the characteristic value using the Server
1240  * Characteristic Configuration descriptor.
1241  */
1243 
1244  /**
1245  * Permits reads of the characteristic value.
1246  */
1248 
1249  /**
1250  * Permits writes of the characteristic value without response.
1251  */
1253 
1254  /**
1255  * Permits writes of the characteristic value with response.
1256  */
1258 
1259  /**
1260  * Permits notifications of a characteristic value without acknowledgment.
1261  */
1263 
1264  /**
1265  * Permits indications of a characteristic value with acknowledgment.
1266  */
1268 
1269  /**
1270  * Permits signed writes to the characteristic value.
1271  */
1273 
1274  /**
1275  * The Characteristic Extended Properties descriptor
1276  * defines additional characteristic properties.
1277  */
1279  };
1280 
1281  /**
1282  * Indicates if the properties has at least one of the writable flags.
1283  *
1284  * @param[in] properties The properties to inspect.
1285  *
1286  * @return True if the properties set at least one of the writable flags and
1287  * false otherwise.
1288  */
1289  static bool isWritable(uint8_t properties)
1290  {
1291  const uint8_t writable =
1295 
1296  return properties & writable;
1297  }
1298 
1299  /**
1300  * Indicates if the properties is readable.
1301  *
1302  * @param[in] properties The properties to inspect.
1303  *
1304  * @return True if the properties has its readable flag set and false
1305  * otherwise.
1306  */
1307  static bool isReadable(uint8_t properties)
1308  {
1309  const uint8_t readable = BLE_GATT_CHAR_PROPERTIES_READ;
1310  return properties & readable;
1311  }
1312 
1313  /**
1314  * Value of a Characteristic Presentation Format descriptor.
1315  *
1316  * Characteristic Presentation Format descriptor expresses the format of a
1317  * characteristic value.
1318  *
1319  * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5.
1320  */
1322  /**
1323  * Format of the value.
1324  */
1325  uint8_t gatt_format;
1326 
1327  /**
1328  * Exponent for integer data types.
1329  *
1330  * Example: if Exponent = -3 and the char value is 3892, the actual
1331  * value is 3.892
1332  */
1333  int8_t exponent;
1334 
1335  /**
1336  * Unit of the characteristic value.
1337  *
1338  * It is a UUID from Bluetooth Assigned Numbers.
1339  */
1340  uint16_t gatt_unit;
1341 
1342  /**
1343  * Namespace of the description field.
1344  *
1345  * This field identifies the organization that is responsible for
1346  * defining the enumerations for the description field.
1347  *
1348  * The namespace of the Bluetooth Body is 0x01.
1349  */
1351 
1352  /**
1353  * Description.
1354  *
1355  * @note The value 0x0000 means unknown in the Bluetooth namespace.
1356  */
1357  uint16_t gatt_nsdesc;
1358 
1359  };
1360 
1361  /**
1362  * Security level applied to GATT operations.
1363  */
1365 
1366  /**
1367  * @brief Constructs a new GattCharacteristic.
1368  *
1369  * @param[in] uuid The UUID of this characteristic.
1370  * @param[in] valuePtr Memory buffer holding the initial value. The value is
1371  * copied into the Bluetooth subsytem when the enclosing service is added.
1372  * Thereafter, the stack maintains it internally.
1373  * @param[in] len The length in bytes of this characteristic's value.
1374  * @param[in] maxLen The capacity in bytes of the characteristic value
1375  * buffer.
1376  * @param[in] props An 8-bit field that contains the characteristic's
1377  * properties.
1378  * @param[in] descriptors A pointer to an array of descriptors to be included
1379  * within this characteristic. The caller owns the memory for the descriptor
1380  * array, which must remain valid at least until the enclosing service is
1381  * added to the GATT table.
1382  * @param[in] numDescriptors The number of descriptors presents in @p
1383  * descriptors array.
1384  * @param[in] hasVariableLen Flag that indicates if the attribute's value
1385  * length can change throughout time.
1386  *
1387  * @note If valuePtr is nullptr, length is equal to 0 and the characteristic
1388  * is readable, then that particular characteristic may be considered
1389  * optional and dropped while instantiating the service with the underlying
1390  * BLE stack.
1391  *
1392  * @note A Client Characteristic Configuration Descriptor (CCCD) should not
1393  * be allocated if either the notify or indicate flag in the @p props bit
1394  * field; the underlying BLE stack handles it.
1395  *
1396  * @attention GattCharacteristic registered in a GattServer must remain
1397  * valid for the lifetime of the GattServer.
1398  */
1400  const UUID &uuid,
1401  uint8_t *valuePtr = nullptr,
1402  uint16_t len = 0,
1403  uint16_t maxLen = 0,
1404  uint8_t props = BLE_GATT_CHAR_PROPERTIES_NONE,
1405  GattAttribute *descriptors[] = nullptr,
1406  unsigned numDescriptors = 0,
1407  bool hasVariableLen = true
1408  ) : _valueAttribute(uuid, valuePtr, len, maxLen, hasVariableLen),
1409  _properties(props),
1410  _descriptors(descriptors),
1411  _descriptorCount(numDescriptors),
1412  readAuthorizationCallback(),
1413  writeAuthorizationCallback(),
1414  _update_security(SecurityRequirement_t::NONE) {
1415  _valueAttribute.allowWrite(isWritable(_properties));
1416  _valueAttribute.allowRead(isReadable(_properties));
1417 
1418 #if BLE_FEATURE_SECURITY
1419  // signed writes requires at least an unauthenticated CSRK or an
1420  // unauthenticated ltk if the link is encrypted.
1422  _valueAttribute.setWriteSecurityRequirement(
1424  );
1425  }
1426 #endif // BLE_FEATURE_SECURITY
1427  }
1428 
1429  GattCharacteristic(const GattCharacteristic &) = delete;
1430  GattCharacteristic& operator=(const GattCharacteristic &) = delete;
1431 
1432 public:
1433 
1434  /**
1435  * Set all security requirements of the characteristic.
1436  *
1437  * @param read_security The security requirement of the read operations.
1438  * @param write_security The security requirement of write operations.
1439  * @param update_security The security requirement of update operations.
1440  */
1442  SecurityRequirement_t read_security,
1443  SecurityRequirement_t write_security,
1444  SecurityRequirement_t update_security
1445  ) {
1446  setReadSecurityRequirement(read_security);
1447  setWriteSecurityRequirement(write_security);
1448  setUpdateSecurityRequirement(update_security);
1449  }
1450 
1451  /**
1452  * Set the security of the read operation.
1453  *
1454  * @param[in] security The security requirement of the read operation.
1455  */
1456  void setReadSecurityRequirement(SecurityRequirement_t security)
1457  {
1458  _valueAttribute.setReadSecurityRequirement(security);
1459  }
1460 
1461  /**
1462  * Get the security requirement of the read operation.
1463  *
1464  * @return The security requirement of the read operation.
1465  */
1466  SecurityRequirement_t getReadSecurityRequirement() const
1467  {
1468  return _valueAttribute.getReadSecurityRequirement();
1469  }
1470 
1471  /**
1472  * Set the security requirement of the write operations.
1473  *
1474  * @note If the signed write flag is set in the characteristic properties
1475  * then the security requirement applied to write operation must be either
1476  * AUTHENTICATED or UNAUTHENTICATED. Security requirements NONE and
1477  * SC_AUTHENTICATED are not applicable to signing operation.
1478  *
1479  * @param[in] security The security requirement of write operations.
1480  */
1481  void setWriteSecurityRequirement(SecurityRequirement_t security)
1482  {
1483 #if BLE_FEATURE_SECURITY
1484  MBED_ASSERT(
1486  ((security == SecurityRequirement_t::NONE) ||
1487  (security == SecurityRequirement_t::SC_AUTHENTICATED))) == false
1488  );
1489 #endif // BLE_FEATURE_SECURITY
1490  _valueAttribute.setWriteSecurityRequirement(security);
1491  }
1492 
1493  /**
1494  * Get the security requirement of write operations.
1495  *
1496  * @return The security requirement of write operations.
1497  */
1498  SecurityRequirement_t getWriteSecurityRequirement() const
1499  {
1500  return _valueAttribute.getWriteSecurityRequirement();
1501  }
1502 
1503  /**
1504  * Set the security requirement of update operations.
1505  *
1506  * @note This security requirement is also applied to the write operation of
1507  * the Client Characteristic Configuration Descriptor.
1508  *
1509  * @param[in] security The security requirement that must be met to send
1510  * updates and accept write of the CCCD.
1511  */
1512  void setUpdateSecurityRequirement(SecurityRequirement_t security)
1513  {
1514  _update_security = security.value();
1515  }
1516 
1517  /**
1518  * Get the security requirement of update operations.
1519  *
1520  * @note This security requirement is also applied to the write operation of
1521  * the Client Characteristic Configuration Descriptor.
1522  *
1523  * @return The security requirement that must be met to send updates and
1524  * accept write of the CCCD.
1525  */
1526  SecurityRequirement_t getUpdateSecurityRequirement() const
1527  {
1528  return static_cast<SecurityRequirement_t::type>(_update_security);
1529  }
1530 
1531 public:
1532  /**
1533  * Register a callback handling client's write requests or commands.
1534  *
1535  * The callback registered is invoked when the client attempts to write the
1536  * characteristic value; the event handler can accept or reject the write
1537  * request with the appropriate error code.
1538  *
1539  * @param[in] callback Event handler being registered.
1540  */
1543  ) {
1544  writeAuthorizationCallback.attach(callback);
1545  }
1546 
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] object Pointer to the object of a class defining the event
1555  * handler (@p member). It must remain valid for the lifetime of the
1556  * GattCharacteristic.
1557  * @param[in] member The member function that handles the write event.
1558  */
1559  template <typename T>
1561  T *object,
1562  void (T::*member)(GattWriteAuthCallbackParams *)
1563  ) {
1564  writeAuthorizationCallback.attach(object, member);
1565  }
1566 
1567  /**
1568  * Register the read requests event handler.
1569  *
1570  * The callback registered is invoked when the client attempts to read the
1571  * characteristic value; the event handler can accept or reject the read
1572  * request with the appropriate error code. It can also set specific outgoing
1573  * data.
1574  *
1575  * @param[in] callback Event handler being registered.
1576  */
1579  ) {
1580  readAuthorizationCallback.attach(callback);
1581  }
1582 
1583  /**
1584  * Register the read requests event handler.
1585  *
1586  * The callback registered is invoked when the client attempts to read the
1587  * characteristic value; the event handler can accept or reject the read
1588  * request with the appropriate error code. It can also set specific outgoing
1589  * data.
1590  *
1591  * @param[in] object Pointer to the object of a class defining the event
1592  * handler (@p member). It must remain valid for the lifetime of the
1593  * GattCharacteristic.
1594  * @param[in] member The member function that handles the read event.
1595  */
1596  template <typename T>
1598  T *object,
1599  void (T::*member)(GattReadAuthCallbackParams *)
1600  ) {
1601  readAuthorizationCallback.attach(object, member);
1602  }
1603 
1604  /**
1605  * Invoke the write authorization callback.
1606  *
1607  * This function is a helper that calls the registered write handler to
1608  * determine the authorization reply for a write request.
1609  *
1610  * @attention This function is not meant to be called by user code.
1611  *
1612  * @param[in] params Context of the write-auth request; it contains an
1613  * out-parameter used as a reply.
1614  *
1615  * @return A GattAuthCallbackReply_t value indicating whether authorization
1616  * is granted.
1617  */
1619  {
1620  if (!isWriteAuthorizationEnabled()) {
1622  }
1623 
1624  /* Initialized to no-error by default. */
1626  writeAuthorizationCallback.call(params);
1627  return params->authorizationReply;
1628  }
1629 
1630  /**
1631  * Invoke the read authorization callback.
1632  *
1633  * This function is a helper that calls the registered read handler to
1634  * determine the authorization reply for a read request.
1635  *
1636  * @attention This function is not meant to be called by user code.
1637  *
1638  * @param[in] params Context of the read-auth request; it contains an
1639  * out-parameter used as a reply and the handler can fill it with outgoing
1640  * data.
1641  *
1642  * @return A GattAuthCallbackReply_t value indicating whether authorization
1643  * is granted.
1644  *
1645  * @note If the read request is approved and params->data remains nullptr, then
1646  * the current characteristic value is used in the read response payload.
1647  *
1648  * @note If the read is approved, the event handler can specify an outgoing
1649  * value directly with the help of the fields
1650  * GattReadAuthCallbackParams::data and GattReadAuthCallbackParams::len.
1651  */
1653  {
1654  if (!isReadAuthorizationEnabled()) {
1656  }
1657 
1658  /* Initialized to no-error by default. */
1660  readAuthorizationCallback.call(params);
1661  return params->authorizationReply;
1662  }
1663 
1664 public:
1665  /**
1666  * Get the characteristic's value attribute.
1667  *
1668  * @return A reference to the characteristic's value attribute.
1669  */
1671  {
1672  return _valueAttribute;
1673  }
1674 
1675  /**
1676  * Get the characteristic's value attribute.
1677  *
1678  * @return A const reference to the characteristic's value attribute.
1679  */
1681  {
1682  return _valueAttribute;
1683  }
1684 
1685  /**
1686  * Get the characteristic's value attribute handle in the ATT table.
1687  *
1688  * @return The value attribute handle.
1689  *
1690  * @note The underlying BLE stack assigns the attribute handle when the
1691  * enclosing service is added.
1692  */
1694  {
1695  return getValueAttribute().getHandle();
1696  }
1697 
1698  /**
1699  * Get the characteristic's properties.
1700  *
1701  * @note Refer to GattCharacteristic::Properties_t.
1702  *
1703  * @return The characteristic's properties.
1704  */
1705  uint8_t getProperties() const
1706  {
1707  return _properties;
1708  }
1709 
1710  /**
1711  * Get the total number of descriptors within this characteristic.
1712  *
1713  * @return The total number of descriptors.
1714  */
1715  uint8_t getDescriptorCount() const
1716  {
1717  return _descriptorCount;
1718  }
1719 
1720  /**
1721  * Check whether read authorization is enabled.
1722  *
1723  * Read authorization is enabled when a read authorization event handler is
1724  * set up.
1725  *
1726  * @return true if read authorization is enabled and false otherwise.
1727  */
1729  {
1730  return readAuthorizationCallback;
1731  }
1732 
1733  /**
1734  * Check whether write authorization is enabled.
1735  *
1736  * Write authorization is enabled when a write authorization event handler is
1737  * set up.
1738  *
1739  * @return true if write authorization is enabled, false otherwise.
1740  */
1742  {
1743  return writeAuthorizationCallback;
1744  }
1745 
1746  /**
1747  * Get this characteristic's descriptor at a specific index.
1748  *
1749  * @param[in] index The index of the descriptor to get.
1750  *
1751  * @return A pointer the requested descriptor if @p index is within the
1752  * range of the descriptor array or nullptr otherwise.
1753  */
1755  {
1756  if (index >= _descriptorCount) {
1757  return nullptr;
1758  }
1759 
1760  return _descriptors[index];
1761  }
1762 
1763 private:
1764 
1765  /**
1766  * Attribute that contains the actual value of this characteristic.
1767  */
1768  GattAttribute _valueAttribute;
1769 
1770  /**
1771  * The characteristic's properties. Refer to
1772  * GattCharacteristic::Properties_t.
1773  */
1774  uint8_t _properties;
1775 
1776  /**
1777  * The characteristic's descriptor attributes.
1778  */
1779  GattAttribute **_descriptors;
1780 
1781  /**
1782  * The number of descriptors in this characteristic.
1783  */
1784  uint8_t _descriptorCount;
1785 
1786  /**
1787  * The registered callback handler for read authorization reply.
1788  */
1790  readAuthorizationCallback;
1791 
1792  /**
1793  * The registered callback handler for write authorization reply.
1794  */
1796  writeAuthorizationCallback;
1797 
1798  /**
1799  * Security requirements of update operations.
1800  *
1801  * The peer must meet the security requirement to enable, disable and
1802  * receive updates
1803  */
1804  uint8_t _update_security: SecurityRequirement_t::size;
1805 };
1806 
1807 /**
1808  * Helper class that represents a read only GattCharacteristic.
1809  */
1810 template <typename T>
1812 public:
1813  /**
1814  * Construct a ReadOnlyGattCharacteristic.
1815  *
1816  * @param[in] uuid The characteristic's UUID.
1817  * @param[in] valuePtr Pointer to the characteristic's initial value. The
1818  * pointer is reinterpreted as a pointer to an uint8_t buffer.
1819  * @param[in] additionalProperties Additional characteristic properties. By
1820  * default, the properties are set to
1821  * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
1822  * @param[in] descriptors An array of pointers to descriptors to be added
1823  * to the new characteristic.
1824  * @param[in] numDescriptors The total number of descriptors in @p
1825  * descriptors.
1826  *
1827  * @note Instances of ReadOnlyGattCharacteristic have a fixed length
1828  * attribute value that equals sizeof(T). For a variable length alternative,
1829  * use GattCharacteristic directly.
1830  */
1832  const UUID &uuid,
1833  T *valuePtr,
1834  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
1835  GattAttribute *descriptors[] = nullptr,
1836  unsigned numDescriptors = 0
1837  ) : GattCharacteristic(
1838  uuid,
1839  reinterpret_cast<uint8_t *>(valuePtr),
1840  sizeof(T),
1841  sizeof(T),
1842  BLE_GATT_CHAR_PROPERTIES_READ | additionalProperties,
1843  descriptors,
1844  numDescriptors,
1845  false
1846  ) {
1847  }
1848 };
1849 
1850 /**
1851  * Helper class that represents a write only GattCharacteristic.
1852  */
1853 template <typename T>
1855 public:
1856  /**
1857  * Construct a WriteOnlyGattCharacteristic.
1858  *
1859  * @param[in] uuid The characteristic's UUID.
1860  * @param[in] valuePtr Pointer to the characteristic's initial value. The
1861  * pointer is reinterpreted as a pointer to an uint8_t buffer.
1862  * @param[in] additionalProperties Additional characteristic properties. By
1863  * default, the properties are set to
1864  * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE.
1865  * @param[in] descriptors An array of pointers to descriptors to be added to
1866  * the new characteristic.
1867  * @param[in] numDescriptors The total number of descriptors in @p
1868  * descriptors.
1869  *
1870  * @note Instances of WriteOnlyGattCharacteristic have variable length
1871  * attribute value with maximum size equal to sizeof(T). For a fixed length
1872  * alternative, use GattCharacteristic directly.
1873  */
1875  const UUID &uuid,
1876  T *valuePtr,
1877  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
1878  GattAttribute *descriptors[] = nullptr,
1879  unsigned numDescriptors = 0
1880  ) : GattCharacteristic(
1881  uuid,
1882  reinterpret_cast<uint8_t *>(valuePtr),
1883  sizeof(T),
1884  sizeof(T),
1885  BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
1886  descriptors,
1887  numDescriptors
1888  ) {
1889  }
1890 };
1891 
1892 /**
1893  * Helper class that represents a readable and writable GattCharacteristic.
1894  */
1895 template <typename T>
1897 public:
1898  /**
1899  * Construct a ReadWriteGattCharacteristic.
1900  *
1901  * @param[in] uuid The characteristic's UUID.
1902  * @param[in] valuePtr Pointer to the characteristic's initial value. The
1903  * pointer is reinterpreted as a pointer to an uint8_t buffer.
1904  * @param[in] additionalProperties Additional characteristic properties. By
1905  * default, the properties are set to
1906  * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE and
1907  * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
1908  * @param[in] descriptors An array of pointers to descriptors to be added to
1909  * the new characteristic.
1910  * @param[in] numDescriptors The total number of descriptors in @p descriptors.
1911  *
1912  * @note Instances of ReadWriteGattCharacteristic have variable length
1913  * attribute value with maximum size equal to sizeof(T). For a fixed length
1914  * alternative, use GattCharacteristic directly.
1915  */
1917  const UUID &uuid,
1918  T *valuePtr,
1919  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
1920  GattAttribute *descriptors[] = nullptr,
1921  unsigned numDescriptors = 0
1922  ) : GattCharacteristic(
1923  uuid,
1924  reinterpret_cast<uint8_t *>(valuePtr),
1925  sizeof(T),
1926  sizeof(T),
1928  descriptors,
1929  numDescriptors
1930  ) {
1931  }
1932 };
1933 
1934 /**
1935  * Helper class that represents a write-only GattCharacteristic with an array
1936  * value.
1937  */
1938 template <typename T, unsigned NUM_ELEMENTS>
1940 public:
1941  /**
1942  * Construct a WriteOnlyGattCharacteristic.
1943  *
1944  * @param[in] uuid The characteristic's UUID.
1945  * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
1946  * the characteristic's initial value. The pointer is reinterpreted as a
1947  * pointer to an uint8_t buffer.
1948  * @param[in] additionalProperties Additional characteristic properties. By
1949  * default, the properties are set to
1950  * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE.
1951  * @param[in] descriptors An array of pointers to descriptors to be added to
1952  * the new characteristic.
1953  * @param[in] numDescriptors The total number of descriptors in @p descriptors.
1954  *
1955  * @note Instances of WriteOnlyGattCharacteristic have variable length
1956  * attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
1957  * For a fixed length alternative, use GattCharacteristic directly.
1958  */
1960  const UUID &uuid,
1961  T valuePtr[NUM_ELEMENTS],
1962  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
1963  GattAttribute *descriptors[] = nullptr,
1964  unsigned numDescriptors = 0
1965  ) : GattCharacteristic(
1966  uuid,
1967  reinterpret_cast<uint8_t *>(valuePtr),
1968  sizeof(T) * NUM_ELEMENTS,
1969  sizeof(T) * NUM_ELEMENTS,
1970  BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
1971  descriptors,
1972  numDescriptors
1973  ) {
1974  }
1975 };
1976 
1977 /**
1978  * Helper class that represents a read-only GattCharacteristic with an array
1979  * value.
1980  */
1981 template <typename T, unsigned NUM_ELEMENTS>
1983 public:
1984  /**
1985  * Construct a ReadOnlyGattCharacteristic.
1986  *
1987  * @param[in] uuid The characteristic's UUID.
1988  * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
1989  * the characteristic's initial value. The pointer is reinterpreted as a
1990  * 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_READ.
1994  * @param[in] descriptors An array of pointers to descriptors to be added to
1995  * the new characteristic.
1996  * @param[in] numDescriptors The total number of descriptors in @p
1997  * descriptors.
1998  *
1999  * @note Instances of ReadOnlyGattCharacteristic have fixed length
2000  * attribute value that equals sizeof(T) * NUM_ELEMENTS. For a variable
2001  * length alternative, use GattCharacteristic directly.
2002  */
2004  const UUID &uuid,
2005  T valuePtr[NUM_ELEMENTS],
2006  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
2007  GattAttribute *descriptors[] = nullptr,
2008  unsigned numDescriptors = 0
2009  ) : GattCharacteristic(
2010  uuid,
2011  reinterpret_cast<uint8_t *>(valuePtr),
2012  sizeof(T) * NUM_ELEMENTS,
2013  sizeof(T) * NUM_ELEMENTS,
2014  BLE_GATT_CHAR_PROPERTIES_READ | additionalProperties,
2015  descriptors,
2016  numDescriptors,
2017  false
2018  ) {
2019  }
2020 };
2021 
2022 /**
2023  * Helper class that represents a readable and writable GattCharacteristic with
2024  * an array value.
2025  */
2026 template <typename T, unsigned NUM_ELEMENTS>
2028 public:
2029  /**
2030  * Construct a ReadWriteGattCharacteristic.
2031  *
2032  * @param[in] uuid The characteristic's UUID.
2033  * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
2034  * the characteristic's initial value. The pointer is reinterpreted as a
2035  * pointer to an uint8_t buffer.
2036  * @param[in] additionalProperties Additional characteristic properties. By
2037  * default, the properties are set to
2038  * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE |
2039  * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
2040  * @param[in] descriptors An array of pointers to descriptors to be added to
2041  * the new characteristic.
2042  * @param[in] numDescriptors The total number of descriptors in @p descriptors.
2043  *
2044  * @note Instances of ReadWriteGattCharacteristic have variable length
2045  * attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
2046  * For a fixed length alternative, use GattCharacteristic directly.
2047  */
2049  const UUID &uuid,
2050  T valuePtr[NUM_ELEMENTS],
2051  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
2052  GattAttribute *descriptors[] = nullptr,
2053  unsigned numDescriptors = 0
2054  ) : GattCharacteristic(
2055  uuid,
2056  reinterpret_cast<uint8_t *>(valuePtr),
2057  sizeof(T) * NUM_ELEMENTS,
2058  sizeof(T) * NUM_ELEMENTS,
2060  descriptors,
2061  numDescriptors
2062  ) {
2063  }
2064 };
2065 
2066 /**
2067  * @}
2068  * @}
2069  * @}
2070  */
2071 
2072 #endif /* ifndef __GATT_CHARACTERISTIC_H__ */
Part of the Human Interface Device service.
Characteristic of the Device Information Service that contains a UTF8 string representing the serial ...
Helper class that represents a readable and writable GattCharacteristic.
Characteristic of the Phone Alert Status service that allows a client to configure operating mode...
uint8_t getProperties() const
Get the characteristic&#39;s properties.
Not used in a service as a characteristic.
Permits reads of the characteristic value.
Characteristic of the Alert Notification Service that shows how many numbers of unread alerts exist i...
GattAuthCallbackReply_t authorizationReply
Authorization result.
Not used in a service as a characteristic.
Characteristic of the Health Thermometer service that exposes the interval time between two measureme...
Characteristic of the Alert Notification Service that defines the category of the alert and how many ...
Part of the Human Interface Device service.
Characteristic of the Device Information Service that contains a UTF8 string representing the firmwar...
static bool isWritable(uint8_t properties)
Indicates if the properties has at least one of the writable flags.
uint8_t gatt_namespace
Namespace of the description field.
GattAuthCallbackReply_t authorizeRead(GattReadAuthCallbackParams *params)
Invoke the read authorization callback.
GATT write authorization request event.
Characteristic of the Alert Notification service, which exposes categories of unread alert supported ...
GattAttribute::Handle_t getValueHandle() const
Get the characteristic&#39;s value attribute handle in the ATT table.
Not used in a service as a characteristic.
Characteristic of the Health Thermometer service that describes where the measurement takes place...
Characteristic of the Device Information Service that contains an UTF8 string representing the softwa...
SecurityRequirement_t getReadSecurityRequirement() const
Get the security requirement of the read operation.
The operation require encryption with an authenticated peer that paired using secure connection pairi...
Characteristic of the Alert Notification Service that notifies the count of new alerts for a given ca...
Characteristic of the Environmental Sensing service, which exposes humidity measurements.
Handle_t getHandle() const
Get the attribute&#39;s handle in the ATT table.
Not used in a service as a characteristic.
Characteristic of the TX Power service that exposes the current transmission power in dBm...
Characteristic of the Battery service, which exposes the current battery level as a percentage...
Not used in a service as a characteristic.
void setUpdateSecurityRequirement(SecurityRequirement_t security)
Set the security requirement of update operations.
Security requirement that can be attached to an attribute operation.
void setSecurityRequirements(SecurityRequirement_t read_security, SecurityRequirement_t write_security, SecurityRequirement_t update_security)
Set all security requirements of the characteristic.
Characteristic of the Device Information Service that contains a UTF8 string representing the model n...
The operation requires security and there&#39;s no requirement towards peer authentication.
Characteristic of the Blood Pressure service that exposes the measurement of the blood sensor...
Helper class that represents a readable and writable GattCharacteristic with an array value...
ble::att_security_requirement_t SecurityRequirement_t
Security level applied to GATT operations.
GATT read authorization request event.
GattAttribute & getValueAttribute()
Get the characteristic&#39;s value attribute.
Permits notifications of a characteristic value without acknowledgment.
Characteristic of the Blood Pressure service, which exposes intermediate cuff pressure measurements...
GattAuthCallbackReply_t authorizationReply
Authorization result.
LayoutType value() const
Explicit access to the inner value of the SafeEnum instance.
const GattAttribute & getValueAttribute() const
Get the characteristic&#39;s value attribute.
The operation does not have security requirements.
Describe the features supported by the blood pressure sensor exposed by the Blood Pressure service...
Callback< R(ArgTs...)> callback(R(*func)(ArgTs...)=nullptr) noexcept
Create a callback class with type inferred from the arguments.
Definition: Callback.h:678
type
struct scoped enum wrapped by the class
Control point of the Alert Notification service that allows the client finely tune the notification c...
Not used in a service as a characteristic.
Helper class that represents a read-only GattCharacteristic with an array value.
Representation of a Universally Unique Identifier (UUID).
Definition: common/UUID.h:76
Characteristic of the Cycling Speed and Cadence (CSC) service that exposes measurements made by the s...
void setReadSecurityRequirement(SecurityRequirement_t security)
Set the security of the read operation.
Representation of a GattServer attribute.
Part of the Human Interface Device service.
Permits writes of the characteristic value without response.
Characteristic of the Cycling Speed and Cadence (CSC) service that exposes features supported by the ...
ble::attribute_handle_t Handle_t
Representation of an attribute handle.
Characteristic of the Running Speed and Cadence (RSC) service that exposes features supported by the ...
Helper class that represents a write-only GattCharacteristic with an array value. ...
int8_t exponent
Exponent for integer data types.
Characteristic of the Current Time service that contains the current time.
Characteristic of the Reference Time service that informs clients of the status of the time update op...
Not used in a service as a characteristic.
Characteristic of the current Time service that exposes information about the local time...
Characteristic of the Scan Parameter service that sends a notification to a client when the server re...
uint8_t getDescriptorCount() const
Get the total number of descriptors within this characteristic.
void setReadAuthorizationCallback(void(*callback)(GattReadAuthCallbackParams *))
Register the read requests event handler.
bool isReadAuthorizationEnabled() const
Check whether read authorization is enabled.
Characteristic of the Next DST Change service that returns to clients the time with DST...
GattAuthCallbackReply_t authorizeWrite(GattWriteAuthCallbackParams *params)
Invoke the write authorization callback.
Characteristic of the Glucose service that exposes glucose measurements.
Characteristic of the Glucose service that sends additional information related to the glucose measur...
#define MBED_ASSERT(expr)
MBED_ASSERT Declare runtime assertions: results in runtime error if condition is false.
Definition: mbed_assert.h:65
static const uint8_t size
Number of bits required to store the value.
Characteristic of the Environmental Sensing Service that exposes the pressure measured.
Characteristic of the Device Information Service that contains a UTF8 string representing the hardwar...
static bool isReadable(uint8_t properties)
Indicates if the properties is readable.
Control point of the Immediate Alert service that allows the client to command the server to alert to...
Characteristic of the Device Information Service that contains a UTF8 string representing the manufac...
SecurityRequirement_t getWriteSecurityRequirement() const
Get the security requirement of write operations.
The Characteristic Extended Properties descriptor defines additional characteristic properties...
Representation of a GattServer characteristic.
Characteristic of the Device Information Service that exposes a structure containing an Organizationa...
GattAttribute * getDescriptor(uint8_t index)
Get this characteristic&#39;s descriptor at a specific index.
Characteristic of the Health Thermometer service that sends intermediate temperature values while the...
Permits indications of a characteristic value with acknowledgment.
Characteristic of the Heart Rate service that indicate the intended location of the heart rate monito...
Characteristic of the Health Thermometer service that sends temperature measurement to clients...
Helper class that represents a write only GattCharacteristic.
Characteristic of the Scan Parameter service that stores the client&#39;s scan parameters (scan interval ...
Not used in a service as a characteristic.
uint16_t gatt_unit
Unit of the characteristic value.
Part of the Human Interface Device service.
Permits broadcasts of the characteristic value using the Server Characteristic Configuration descript...
Characteristic of the Environmental Sensing service that exposes the temperature measurement with a r...
bool isWriteAuthorizationEnabled() const
Check whether write authorization is enabled.
SecurityRequirement_t getUpdateSecurityRequirement() const
Get the security requirement of update operations.
void setReadAuthorizationCallback(T *object, void(T::*member)(GattReadAuthCallbackParams *))
Register the read requests event handler.
void setWriteAuthorizationCallback(void(*callback)(GattWriteAuthCallbackParams *))
Register a callback handling client&#39;s write requests or commands.
Characteristic of the Heart Rate that sends heart rate measurements to registered clients...
void setWriteSecurityRequirement(SecurityRequirement_t security)
Set the security requirement of the write operations.
Characteristic of the Device Information Service; it is a set of values used to create a device ID th...
Characteristic of the Heart Rate service used by the client to control the service behavior...
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.
Characteristic of the Glucose service that exposes features supported by the server.
Pulse Oxymeter, Glucose and Continuous Glucose Monitoring services use this control point to provide ...
void setWriteAuthorizationCallback(T *object, void(T::*member)(GattWriteAuthCallbackParams *))
Register a callback handling client&#39;s write requests or commands.
Characteristic of the Running Speed and Cadence (RSC) service that exposes measurements made by the s...
Helper class that represents a read only GattCharacteristic.
Characteristic of the Reference Time service that allows clients to control time update.
Value of a Characteristic Presentation Format descriptor.
Permits writes of the characteristic value with response.
Part of the Human Interface Device service.
GattAuthCallbackReply_t
Enumeration of allowed values returned by read or write authorization process.
Characteristic of the Phone Alert Status service that returns the ringer setting when read...
Part of the Human Interface Device service.
Characteristic of the Current Time service that exposes information related to the current time serve...
Characteristic of the Device Information Service, which exposes various regulatory or certification c...
Part of the Alert Notification service, which exposes the count of unread alert events existing in th...
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.