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 // Forward declare ble::impl::GattServer
28 namespace ble {
29 
30 #if !defined(DOXYGEN_ONLY)
31 namespace impl {
32 class 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  */
106 public:
107 
108  /*
109  * Enumeration of characteristic UUID defined by the Bluetooth body.
110  */
111  enum {
112  /**
113  * Not used in actual BLE service.
114  */
115  UUID_BATTERY_LEVEL_STATE_CHAR = 0x2A1B,
116 
117  /**
118  * Not used in actual BLE service.
119  */
120  UUID_BATTERY_POWER_STATE_CHAR = 0x2A1A,
121 
122  /**
123  * Not used in actual BLE service.
124  */
125  UUID_REMOVABLE_CHAR = 0x2A3A,
126 
127  /**
128  * Not used in actual BLE service.
129  */
130  UUID_SERVICE_REQUIRED_CHAR = 0x2A3B,
131 
132  /**
133  * Not used as a characteristic UUID.
134  */
135  UUID_ALERT_CATEGORY_ID_CHAR = 0x2A43,
136 
137  /**
138  * Not used as a characteristic UUID.
139  */
140  UUID_ALERT_CATEGORY_ID_BIT_MASK_CHAR = 0x2A42,
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  */
146  UUID_ALERT_LEVEL_CHAR = 0x2A06,
147 
148  /**
149  * Control point of the Alert Notification service that allows the client
150  * finely tune the notification configuration.
151  */
152  UUID_ALERT_NOTIFICATION_CONTROL_POINT_CHAR = 0x2A44,
153 
154  /**
155  * Part of the Alert Notification service, which exposes the count of
156  * unread alert events existing in the server.
157  */
158  UUID_ALERT_STATUS_CHAR = 0x2A3F,
159 
160  /**
161  * Characteristic of the Battery service, which exposes the current
162  * battery level as a percentage.
163  */
164  UUID_BATTERY_LEVEL_CHAR = 0x2A19,
165 
166  /**
167  * Describe the features supported by the blood pressure sensor exposed
168  * by the Blood Pressure service.
169  */
170  UUID_BLOOD_PRESSURE_FEATURE_CHAR = 0x2A49,
171 
172  /**
173  * Characteristic of the Blood Pressure service that exposes the
174  * measurement of the blood sensor.
175  */
176  UUID_BLOOD_PRESSURE_MEASUREMENT_CHAR = 0x2A35,
177 
178  /**
179  * Characteristic of the Heart Rate service that indicate the intended
180  * location of the heart rate monitor.
181  */
182  UUID_BODY_SENSOR_LOCATION_CHAR = 0x2A38,
183 
184  /**
185  * Part of the Human Interface Device service.
186  */
187  UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR = 0x2A22,
188 
189  /**
190  * Part of the Human Interface Device service.
191  */
192  UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR = 0x2A32,
193 
194  /**
195  * Part of the Human Interface Device service.
196  */
197  UUID_BOOT_MOUSE_INPUT_REPORT_CHAR = 0x2A33,
198 
199  /**
200  * Characteristic of the Current Time service that contains the current
201  * time.
202  */
203  UUID_CURRENT_TIME_CHAR = 0x2A2B,
204 
205  /**
206  * Not used in a service as a characteristic.
207  */
208  UUID_DATE_TIME_CHAR = 0x2A08,
209 
210  /**
211  * Not used in a service as a characteristic.
212  */
213  UUID_DAY_DATE_TIME_CHAR = 0x2A0A,
214 
215  /**
216  * Not used in a service as a characteristic.
217  */
218  UUID_DAY_OF_WEEK_CHAR = 0x2A09,
219 
220  /**
221  * Not used in a service as a characteristic.
222  */
223  UUID_DST_OFFSET_CHAR = 0x2A0D,
224 
225  /**
226  * Not used in a service as a characteristic.
227  */
228  UUID_EXACT_TIME_256_CHAR = 0x2A0C,
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  */
235  UUID_FIRMWARE_REVISION_STRING_CHAR = 0x2A26,
236 
237  /**
238  * Characteristic of the Glucose service that exposes features supported
239  * by the server.
240  */
241  UUID_GLUCOSE_FEATURE_CHAR = 0x2A51,
242 
243  /**
244  * Characteristic of the Glucose service that exposes glucose
245  * measurements.
246  */
247  UUID_GLUCOSE_MEASUREMENT_CHAR = 0x2A18,
248 
249  /**
250  * Characteristic of the Glucose service that sends additional
251  * information related to the glucose measurements.
252  */
253  UUID_GLUCOSE_MEASUREMENT_CONTEXT_CHAR = 0x2A34,
254 
255  /**
256  * Characteristic of the Device Information Service that contains a
257  * UTF8 string representing the hardware revision of the device.
258  */
259  UUID_HARDWARE_REVISION_STRING_CHAR = 0x2A27,
260 
261  /**
262  * Characteristic of the Heart Rate service used by the client to control
263  * the service behavior.
264  */
265  UUID_HEART_RATE_CONTROL_POINT_CHAR = 0x2A39,
266 
267  /**
268  * Characteristic of the Heart Rate that sends heart rate measurements to
269  * registered clients.
270  */
271  UUID_HEART_RATE_MEASUREMENT_CHAR = 0x2A37,
272 
273  /**
274  * Part of the Human Interface Device service.
275  */
276  UUID_HID_CONTROL_POINT_CHAR = 0x2A4C,
277 
278  /**
279  * Part of the Human Interface Device service.
280  */
281  UUID_HID_INFORMATION_CHAR = 0x2A4A,
282 
283  /**
284  * Characteristic of the Environmental Sensing service, which exposes
285  * humidity measurements.
286  */
287  UUID_HUMIDITY_CHAR = 0x2A6F,
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  */
294  UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR = 0x2A2A,
295 
296  /**
297  * Characteristic of the Blood Pressure service, which exposes intermediate
298  * cuff pressure measurements.
299  */
300  UUID_INTERMEDIATE_CUFF_PRESSURE_CHAR = 0x2A36,
301 
302  /**
303  * Characteristic of the Health Thermometer service that sends intermediate
304  * temperature values while the measurement is in progress.
305  */
306  UUID_INTERMEDIATE_TEMPERATURE_CHAR = 0x2A1E,
307 
308  /**
309  * Characteristic of the current Time service that exposes information
310  * about the local time.
311  */
312  UUID_LOCAL_TIME_INFORMATION_CHAR = 0x2A0F,
313 
314  /**
315  * Characteristic of the Device Information Service that contains a
316  * UTF8 string representing the manufacturer name of the device.
317  */
318  UUID_MANUFACTURER_NAME_STRING_CHAR = 0x2A29,
319 
320  /**
321  * Characteristic of the Health Thermometer service that exposes the
322  * interval time between two measurements.
323  */
324  UUID_MEASUREMENT_INTERVAL_CHAR = 0x2A21,
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  */
331  UUID_MODEL_NUMBER_STRING_CHAR = 0x2A24,
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  */
337  UUID_UNREAD_ALERT_CHAR = 0x2A45,
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  */
344  UUID_NEW_ALERT_CHAR = 0x2A46,
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  */
350  UUID_PNP_ID_CHAR = 0x2A50,
351 
352  /**
353  * Characteristic of the Environmental Sensing Service that exposes the
354  * pressure measured.
355  */
356  UUID_PRESSURE_CHAR = 0x2A6D,
357 
358  /**
359  * Part of the Human Interface Device service.
360  */
361  UUID_PROTOCOL_MODE_CHAR = 0x2A4E,
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  */
368  UUID_RECORD_ACCESS_CONTROL_POINT_CHAR = 0x2A52,
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  */
375  UUID_REFERENCE_TIME_INFORMATION_CHAR = 0x2A14,
376 
377  /**
378  * Part of the Human Interface Device service.
379  */
380  UUID_REPORT_CHAR = 0x2A4D,
381 
382  /**
383  * Part of the Human Interface Device service.
384  */
385  UUID_REPORT_MAP_CHAR = 0x2A4B,
386 
387  /**
388  * Characteristic of the Phone Alert Status service that allows a client
389  * to configure operating mode.
390  */
391  UUID_RINGER_CONTROL_POINT_CHAR = 0x2A40,
392 
393  /**
394  * Characteristic of the Phone Alert Status service that returns the
395  * ringer setting when read.
396  */
397  UUID_RINGER_SETTING_CHAR = 0x2A41,
398 
399  /**
400  * Characteristic of the Scan Parameter service that stores the client's
401  * scan parameters (scan interval and scan window).
402  */
403  UUID_SCAN_INTERVAL_WINDOW_CHAR = 0x2A4F,
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  */
409  UUID_SCAN_REFRESH_CHAR = 0x2A31,
410 
411  /**
412  * Characteristic of the Device Information Service that contains a
413  * UTF8 string representing the serial number of the device.
414  */
415  UUID_SERIAL_NUMBER_STRING_CHAR = 0x2A25,
416 
417  /**
418  * Characteristic of the Device Information Service that contains an
419  * UTF8 string representing the software revision of the device.
420  */
421  UUID_SOFTWARE_REVISION_STRING_CHAR = 0x2A28,
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  */
427  UUID_SUPPORTED_NEW_ALERT_CATEGORY_CHAR = 0x2A47,
428 
429  /**
430  * Characteristic of the Alert Notification service, which exposes
431  * categories of unread alert supported by the server.
432  */
433  UUID_SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR = 0x2A48,
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  */
441  UUID_SYSTEM_ID_CHAR = 0x2A23,
442 
443  /**
444  * Characteristic of the Environmental Sensing service that exposes the
445  * temperature measurement with a resolution of 0.01 degree Celsius.
446  */
447  UUID_TEMPERATURE_CHAR = 0x2A6E,
448 
449  /**
450  * Characteristic of the Health Thermometer service that sends temperature
451  * measurement to clients.
452  */
453  UUID_TEMPERATURE_MEASUREMENT_CHAR = 0x2A1C,
454 
455  /**
456  * Characteristic of the Health Thermometer service that describes
457  * where the measurement takes place.
458  */
459  UUID_TEMPERATURE_TYPE_CHAR = 0x2A1D,
460 
461  /**
462  * Not used in a service as a characteristic.
463  */
464  UUID_TIME_ACCURACY_CHAR = 0x2A12,
465 
466  /**
467  * Not used in a service as a characteristic.
468  */
469  UUID_TIME_SOURCE_CHAR = 0x2A13,
470 
471  /**
472  * Characteristic of the Reference Time service that allows clients to
473  * control time update.
474  */
475  UUID_TIME_UPDATE_CONTROL_POINT_CHAR = 0x2A16,
476 
477  /**
478  * Characteristic of the Reference Time service that informs clients of
479  * the status of the time update operation.
480  */
481  UUID_TIME_UPDATE_STATE_CHAR = 0x2A17,
482 
483  /**
484  * Characteristic of the Next DST Change service that returns to clients
485  * the time with DST.
486  */
487  UUID_TIME_WITH_DST_CHAR = 0x2A11,
488 
489  /**
490  * Not used in a service as a characteristic.
491  */
492  UUID_TIME_ZONE_CHAR = 0x2A0E,
493 
494  /**
495  * Characteristic of the TX Power service that exposes the current
496  * transmission power in dBm.
497  */
498  UUID_TX_POWER_LEVEL_CHAR = 0x2A07,
499 
500  /**
501  * Characteristic of the Cycling Speed and Cadence (CSC) service that
502  * exposes features supported by the server.
503  */
504  UUID_CSC_FEATURE_CHAR = 0x2A5C,
505 
506  /**
507  * Characteristic of the Cycling Speed and Cadence (CSC) service that
508  * exposes measurements made by the server.
509  */
510  UUID_CSC_MEASUREMENT_CHAR = 0x2A5B,
511 
512  /**
513  * Characteristic of the Running Speed and Cadence (RSC) service that
514  * exposes features supported by the server.
515  */
516  UUID_RSC_FEATURE_CHAR = 0x2A54,
517 
518  /**
519  * Characteristic of the Running Speed and Cadence (RSC) service that
520  * exposes measurements made by the server.
521  */
522  UUID_RSC_MEASUREMENT_CHAR = 0x2A53
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  */
540  BLE_GATT_UNIT_NONE = 0x2700,
541 
542  /**
543  * Length, meter.
544  */
545  BLE_GATT_UNIT_LENGTH_METRE = 0x2701,
546 
547  /**
548  * Mass, kilogram.
549  */
550  BLE_GATT_UNIT_MASS_KILOGRAM = 0x2702,
551 
552  /**
553  * Time, second.
554  */
555  BLE_GATT_UNIT_TIME_SECOND = 0x2703,
556 
557  /**
558  * Electric current, ampere.
559  */
560  BLE_GATT_UNIT_ELECTRIC_CURRENT_AMPERE = 0x2704,
561 
562  /**
563  * Thermodynamic temperature, kelvin.
564  */
565  BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_KELVIN = 0x2705,
566 
567  /** Amount of substance, mole.
568  *
569  */
570  BLE_GATT_UNIT_AMOUNT_OF_SUBSTANCE_MOLE = 0x2706,
571 
572  /**
573  * Luminous intensity, candela.
574  */
575  BLE_GATT_UNIT_LUMINOUS_INTENSITY_CANDELA = 0x2707,
576 
577  /**
578  * Area, square meters.
579  */
580  BLE_GATT_UNIT_AREA_SQUARE_METRES = 0x2710,
581 
582  /**
583  * Volume, cubic meters.
584  */
585  BLE_GATT_UNIT_VOLUME_CUBIC_METRES = 0x2711,
586 
587  /**
588  * Velocity, meters per second.
589  */
590  BLE_GATT_UNIT_VELOCITY_METRES_PER_SECOND = 0x2712,
591 
592  /**
593  * Acceleration, meters per second squared.
594  */
595  BLE_GATT_UNIT_ACCELERATION_METRES_PER_SECOND_SQUARED = 0x2713,
596 
597  /**
598  * Wave number reciprocal, meter.
599  */
600  BLE_GATT_UNIT_WAVENUMBER_RECIPROCAL_METRE = 0x2714,
601 
602  /**
603  * Density, kilogram per cubic meter.
604  */
605  BLE_GATT_UNIT_DENSITY_KILOGRAM_PER_CUBIC_METRE = 0x2715,
606 
607  /**
608  * Surface density (kilogram per square meter).
609  */
610  BLE_GATT_UNIT_SURFACE_DENSITY_KILOGRAM_PER_SQUARE_METRE = 0x2716,
611 
612  /**
613  * Specific volume (cubic meter per kilogram).
614  */
615  BLE_GATT_UNIT_SPECIFIC_VOLUME_CUBIC_METRE_PER_KILOGRAM = 0x2717,
616 
617  /**
618  * Current density (ampere per square meter).
619  */
620  BLE_GATT_UNIT_CURRENT_DENSITY_AMPERE_PER_SQUARE_METRE = 0x2718,
621 
622  /**
623  * Magnetic field strength, ampere per meter.
624  */
625  BLE_GATT_UNIT_MAGNETIC_FIELD_STRENGTH_AMPERE_PER_METRE = 0x2719,
626 
627  /**
628  * Amount concentration (mole per cubic meter).
629  */
630  BLE_GATT_UNIT_AMOUNT_CONCENTRATION_MOLE_PER_CUBIC_METRE = 0x271A,
631 
632  /**
633  * Mass concentration (kilogram per cubic meter).
634  */
635  BLE_GATT_UNIT_MASS_CONCENTRATION_KILOGRAM_PER_CUBIC_METRE = 0x271B,
636 
637  /**
638  * Luminance (candela per square meter).
639  */
640  BLE_GATT_UNIT_LUMINANCE_CANDELA_PER_SQUARE_METRE = 0x271C,
641 
642  /**
643  * Refractive index.
644  */
645  BLE_GATT_UNIT_REFRACTIVE_INDEX = 0x271D,
646 
647  /**
648  * Relative permeability.
649  */
650  BLE_GATT_UNIT_RELATIVE_PERMEABILITY = 0x271E,
651 
652  /**
653  * Plane angle (radian).
654  */
655  BLE_GATT_UNIT_PLANE_ANGLE_RADIAN = 0x2720,
656 
657  /**
658  * Solid angle (steradian).
659  */
660  BLE_GATT_UNIT_SOLID_ANGLE_STERADIAN = 0x2721,
661 
662  /**
663  * Frequency, hertz.
664  */
665  BLE_GATT_UNIT_FREQUENCY_HERTZ = 0x2722,
666 
667  /**
668  * Force, newton.
669  */
670  BLE_GATT_UNIT_FORCE_NEWTON = 0x2723,
671 
672  /**
673  * Pressure, pascal.
674  */
675  BLE_GATT_UNIT_PRESSURE_PASCAL = 0x2724,
676 
677  /**
678  * Energy, joule.
679  */
680  BLE_GATT_UNIT_ENERGY_JOULE = 0x2725,
681 
682  /**
683  * Power, watt.
684  */
685  BLE_GATT_UNIT_POWER_WATT = 0x2726,
686 
687  /**
688  * Electrical charge, coulomb.
689  */
690  BLE_GATT_UNIT_ELECTRIC_CHARGE_COULOMB = 0x2727,
691 
692  /**
693  * Electrical potential difference, voltage.
694  */
695  BLE_GATT_UNIT_ELECTRIC_POTENTIAL_DIFFERENCE_VOLT = 0x2728,
696 
697  /**
698  * Capacitance, farad.
699  */
700  BLE_GATT_UNIT_CAPACITANCE_FARAD = 0x2729,
701 
702  /**
703  * Electric resistance, ohm.
704  */
705  BLE_GATT_UNIT_ELECTRIC_RESISTANCE_OHM = 0x272A,
706 
707  /**
708  * Electric conductance, siemens.
709  */
710  BLE_GATT_UNIT_ELECTRIC_CONDUCTANCE_SIEMENS = 0x272B,
711 
712  /**
713  * Magnetic flux, weber.
714  */
715  BLE_GATT_UNIT_MAGNETIC_FLUX_WEBER = 0x272C,
716 
717  /**
718  * Magnetic flux density, tesla.
719  */
720  BLE_GATT_UNIT_MAGNETIC_FLUX_DENSITY_TESLA = 0x272D,
721 
722  /**
723  * Inductance, henry.
724  */
725  BLE_GATT_UNIT_INDUCTANCE_HENRY = 0x272E,
726 
727  /**
728  * Celsius temperature, degree Celsius.
729  */
730  BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_CELSIUS = 0x272F,
731 
732  /**
733  * Luminous flux, lumen.
734  */
735  BLE_GATT_UNIT_LUMINOUS_FLUX_LUMEN = 0x2730,
736 
737  /**
738  * Illuminance, lux.
739  */
740  BLE_GATT_UNIT_ILLUMINANCE_LUX = 0x2731,
741 
742  /**
743  * Activity referred to a radionuclide, becquerel.
744  */
745  BLE_GATT_UNIT_ACTIVITY_REFERRED_TO_A_RADIONUCLIDE_BECQUEREL = 0x2732,
746 
747  /**
748  * Absorbed dose, gray.
749  */
750  BLE_GATT_UNIT_ABSORBED_DOSE_GRAY = 0x2733,
751 
752  /**
753  * Dose equivalent, sievert.
754  */
755  BLE_GATT_UNIT_DOSE_EQUIVALENT_SIEVERT = 0x2734,
756 
757  /**
758  * Catalytic activity, katal.
759  */
760  BLE_GATT_UNIT_CATALYTIC_ACTIVITY_KATAL = 0x2735,
761 
762  /**
763  * Dynamic viscosity, pascal second.
764  */
765  BLE_GATT_UNIT_DYNAMIC_VISCOSITY_PASCAL_SECOND = 0x2740,
766 
767  /**
768  * Moment of force, newton meter.
769  */
770  BLE_GATT_UNIT_MOMENT_OF_FORCE_NEWTON_METRE = 0x2741,
771 
772  /**
773  * Surface tension, newton per meter.
774  */
775  BLE_GATT_UNIT_SURFACE_TENSION_NEWTON_PER_METRE = 0x2742,
776 
777  /**
778  * Angular velocity, radian per second.
779  */
780  BLE_GATT_UNIT_ANGULAR_VELOCITY_RADIAN_PER_SECOND = 0x2743,
781 
782  /**
783  * Angular acceleration, radian per second squared.
784  */
785  BLE_GATT_UNIT_ANGULAR_ACCELERATION_RADIAN_PER_SECOND_SQUARED = 0x2744,
786 
787  /**
788  * Heat flux density, watt per square meter.
789  */
790  BLE_GATT_UNIT_HEAT_FLUX_DENSITY_WATT_PER_SQUARE_METRE = 0x2745,
791 
792  /**
793  * Heat capacity, joule per kelvin.
794  */
795  BLE_GATT_UNIT_HEAT_CAPACITY_JOULE_PER_KELVIN = 0x2746,
796 
797  /**
798  * Specific heat capacity, joule per kilogram kelvin.
799  */
800  BLE_GATT_UNIT_SPECIFIC_HEAT_CAPACITY_JOULE_PER_KILOGRAM_KELVIN = 0x2747,
801 
802  /**
803  * Specific energy, joule per kilogram.
804  */
805  BLE_GATT_UNIT_SPECIFIC_ENERGY_JOULE_PER_KILOGRAM = 0x2748,
806 
807  /**
808  * Thermal conductivity, watt per meter kelvin.
809  */
810  BLE_GATT_UNIT_THERMAL_CONDUCTIVITY_WATT_PER_METRE_KELVIN = 0x2749,
811 
812  /**
813  * Energy density, joule per cubic meter.
814  */
815  BLE_GATT_UNIT_ENERGY_DENSITY_JOULE_PER_CUBIC_METRE = 0x274A,
816 
817  /**
818  * Electric field strength, volt per meter.
819  */
820  BLE_GATT_UNIT_ELECTRIC_FIELD_STRENGTH_VOLT_PER_METRE = 0x274B,
821 
822  /**
823  * Electric charge density, coulomb per cubic meter.
824  */
825  BLE_GATT_UNIT_ELECTRIC_CHARGE_DENSITY_COULOMB_PER_CUBIC_METRE = 0x274C,
826 
827  /**
828  * Surface charge density, coulomb per square meter.
829  */
830  BLE_GATT_UNIT_SURFACE_CHARGE_DENSITY_COULOMB_PER_SQUARE_METRE = 0x274D,
831 
832  /**
833  * Electric flux density, coulomb per square meter.
834  */
835  BLE_GATT_UNIT_ELECTRIC_FLUX_DENSITY_COULOMB_PER_SQUARE_METRE = 0x274E,
836 
837  /**
838  * Permittivity, farad per meter.
839  */
840  BLE_GATT_UNIT_PERMITTIVITY_FARAD_PER_METRE = 0x274F,
841 
842  /**
843  * Permeability, henry per meter.
844  */
845  BLE_GATT_UNIT_PERMEABILITY_HENRY_PER_METRE = 0x2750,
846 
847  /**
848  * Molar energy, joule per mole.
849  */
850  BLE_GATT_UNIT_MOLAR_ENERGY_JOULE_PER_MOLE = 0x2751,
851 
852  /**
853  * Molar entropy, joule per mole kelvin.
854  */
855  BLE_GATT_UNIT_MOLAR_ENTROPY_JOULE_PER_MOLE_KELVIN = 0x2752,
856 
857  /**
858  * Exposure, coulomb per kilogram.
859  */
860  BLE_GATT_UNIT_EXPOSURE_COULOMB_PER_KILOGRAM = 0x2753,
861 
862  /**
863  * Absorbed dose rate, gray per second.
864  */
865  BLE_GATT_UNIT_ABSORBED_DOSE_RATE_GRAY_PER_SECOND = 0x2754,
866 
867  /**
868  * Radiant intensity, watt per steradian.
869  */
870  BLE_GATT_UNIT_RADIANT_INTENSITY_WATT_PER_STERADIAN = 0x2755,
871 
872  /**
873  * Radiance, watt per square meter steradian.
874  */
875  BLE_GATT_UNIT_RADIANCE_WATT_PER_SQUARE_METRE_STERADIAN = 0x2756,
876 
877  /**
878  * Catalytic activity concentration, katal per cubic meter.
879  */
880  BLE_GATT_UNIT_CATALYTIC_ACTIVITY_CONCENTRATION_KATAL_PER_CUBIC_METRE = 0x2757,
881 
882  /**
883  * Time, minute.
884  */
885  BLE_GATT_UNIT_TIME_MINUTE = 0x2760,
886 
887  /**
888  * Time, hour.
889  */
890  BLE_GATT_UNIT_TIME_HOUR = 0x2761,
891 
892  /**
893  * Time, day.
894  */
895  BLE_GATT_UNIT_TIME_DAY = 0x2762,
896 
897  /**
898  * Plane angle, degree.
899  */
900  BLE_GATT_UNIT_PLANE_ANGLE_DEGREE = 0x2763,
901 
902  /**
903  * Plane angle, minute.
904  */
905  BLE_GATT_UNIT_PLANE_ANGLE_MINUTE = 0x2764,
906 
907  /**
908  * Plane angle, seconds.
909  */
910  BLE_GATT_UNIT_PLANE_ANGLE_SECOND = 0x2765,
911 
912  /**
913  * Area, hectare.
914  */
915  BLE_GATT_UNIT_AREA_HECTARE = 0x2766,
916 
917  /**
918  * Volume, liter.
919  */
920  BLE_GATT_UNIT_VOLUME_LITRE = 0x2767,
921 
922  /**
923  * Mass, ton.
924  */
925  BLE_GATT_UNIT_MASS_TONNE = 0x2768,
926 
927  /**
928  * Pressure, bar.
929  */
930  BLE_GATT_UNIT_PRESSURE_BAR = 0x2780,
931 
932  /**
933  * Pressure, millimeter of mercury.
934  */
935  BLE_GATT_UNIT_PRESSURE_MILLIMETRE_OF_MERCURY = 0x2781,
936 
937  /**
938  * Length, ngstrm.
939  */
940  BLE_GATT_UNIT_LENGTH_ANGSTROM = 0x2782,
941 
942  /**
943  * Length, nautical mile.
944  */
945  BLE_GATT_UNIT_LENGTH_NAUTICAL_MILE = 0x2783,
946 
947  /**
948  * Area, barn.
949  */
950  BLE_GATT_UNIT_AREA_BARN = 0x2784,
951 
952  /**
953  * Velocity, knot.
954  */
955  BLE_GATT_UNIT_VELOCITY_KNOT = 0x2785,
956 
957  /**
958  * Logarithmic radio quantity, neper.
959  */
960  BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_NEPER = 0x2786,
961 
962  /**
963  * Logarithmic radio quantity, bel.
964  */
965  BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_BEL = 0x2787,
966 
967  /**
968  * Length, yard.
969  */
970  BLE_GATT_UNIT_LENGTH_YARD = 0x27A0,
971 
972  /**
973  * Length, parsec.
974  */
975  BLE_GATT_UNIT_LENGTH_PARSEC = 0x27A1,
976 
977  /**
978  * Length, inch.
979  */
980  BLE_GATT_UNIT_LENGTH_INCH = 0x27A2,
981 
982  /**
983  * Length, foot.
984  */
985  BLE_GATT_UNIT_LENGTH_FOOT = 0x27A3,
986 
987  /**
988  * Length, mile.
989  */
990  BLE_GATT_UNIT_LENGTH_MILE = 0x27A4,
991 
992  /**
993  * Pressure, pound-force per square inch.
994  */
995  BLE_GATT_UNIT_PRESSURE_POUND_FORCE_PER_SQUARE_INCH = 0x27A5,
996 
997  /**
998  * Velocity, kilometer per hour.
999  */
1000  BLE_GATT_UNIT_VELOCITY_KILOMETRE_PER_HOUR = 0x27A6,
1001 
1002  /** Velocity, mile per hour.
1003  *
1004  */
1005  BLE_GATT_UNIT_VELOCITY_MILE_PER_HOUR = 0x27A7,
1006 
1007  /**
1008  * Angular Velocity, revolution per minute.
1009  */
1010  BLE_GATT_UNIT_ANGULAR_VELOCITY_REVOLUTION_PER_MINUTE = 0x27A8,
1011 
1012  /**
1013  * Energy, gram calorie.
1014  */
1015  BLE_GATT_UNIT_ENERGY_GRAM_CALORIE = 0x27A9,
1016 
1017  /**
1018  * Energy, kilogram calorie.
1019  */
1020  BLE_GATT_UNIT_ENERGY_KILOGRAM_CALORIE = 0x27AA,
1021 
1022  /**
1023  * Energy, killowatt hour.
1024  */
1025  BLE_GATT_UNIT_ENERGY_KILOWATT_HOUR = 0x27AB,
1026 
1027  /**
1028  * Thermodynamic temperature, degree Fahrenheit.
1029  */
1030  BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_FAHRENHEIT = 0x27AC,
1031 
1032  /**
1033  * Percentage.
1034  */
1035  BLE_GATT_UNIT_PERCENTAGE = 0x27AD,
1036 
1037  /**
1038  * Per mille.
1039  */
1040  BLE_GATT_UNIT_PER_MILLE = 0x27AE,
1041 
1042  /**
1043  * Period, beats per minute.
1044  */
1045  BLE_GATT_UNIT_PERIOD_BEATS_PER_MINUTE = 0x27AF,
1046 
1047  /**
1048  * Electric charge, ampere hours.
1049  */
1050  BLE_GATT_UNIT_ELECTRIC_CHARGE_AMPERE_HOURS = 0x27B0,
1051 
1052  /**
1053  * Mass density, milligram per deciliter.
1054  */
1055  BLE_GATT_UNIT_MASS_DENSITY_MILLIGRAM_PER_DECILITRE = 0x27B1,
1056 
1057  /**
1058  * Mass density, millimole per liter.
1059  */
1060  BLE_GATT_UNIT_MASS_DENSITY_MILLIMOLE_PER_LITRE = 0x27B2,
1061 
1062  /**
1063  * Time, year.
1064  */
1065  BLE_GATT_UNIT_TIME_YEAR = 0x27B3,
1066 
1067  /**
1068  * Time, month.
1069  */
1070  BLE_GATT_UNIT_TIME_MONTH = 0x27B4,
1071 
1072  /**
1073  * Concentration, count per cubic meter.
1074  */
1075  BLE_GATT_UNIT_CONCENTRATION_COUNT_PER_CUBIC_METRE = 0x27B5,
1076 
1077  /**
1078  * Irradiance, watt per square meter.
1079  */
1080  BLE_GATT_UNIT_IRRADIANCE_WATT_PER_SQUARE_METRE = 0x27B6
1081  };
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  */
1096  BLE_GATT_FORMAT_RFU = 0x00,
1097 
1098  /**
1099  * Boolean.
1100  */
1101  BLE_GATT_FORMAT_BOOLEAN = 0x01,
1102 
1103  /**
1104  * Unsigned 2-bit integer.
1105  */
1106  BLE_GATT_FORMAT_2BIT = 0x02,
1107 
1108  /**
1109  * Unsigned 4-bit integer.
1110  */
1111  BLE_GATT_FORMAT_NIBBLE = 0x03,
1112 
1113  /**
1114  * Unsigned 8-bit integer.
1115  */
1116  BLE_GATT_FORMAT_UINT8 = 0x04,
1117 
1118  /**
1119  * Unsigned 12-bit integer.
1120  */
1121  BLE_GATT_FORMAT_UINT12 = 0x05,
1122 
1123  /**
1124  * Unsigned 16-bit integer.
1125  */
1126  BLE_GATT_FORMAT_UINT16 = 0x06,
1127 
1128  /**
1129  * Unsigned 24-bit integer.
1130  */
1131  BLE_GATT_FORMAT_UINT24 = 0x07,
1132 
1133  /**
1134  * Unsigned 32-bit integer.
1135  */
1136  BLE_GATT_FORMAT_UINT32 = 0x08,
1137 
1138  /**
1139  * Unsigned 48-bit integer.
1140  */
1141  BLE_GATT_FORMAT_UINT48 = 0x09,
1142 
1143  /**
1144  * Unsigned 64-bit integer.
1145  */
1146  BLE_GATT_FORMAT_UINT64 = 0x0A,
1147 
1148  /**
1149  * Unsigned 128-bit integer.
1150  */
1151  BLE_GATT_FORMAT_UINT128 = 0x0B,
1152 
1153  /**
1154  * Signed 8-bit integer.
1155  */
1156  BLE_GATT_FORMAT_SINT8 = 0x0C,
1157 
1158  /**
1159  * Signed 12-bit integer.
1160  */
1161  BLE_GATT_FORMAT_SINT12 = 0x0D,
1162 
1163  /**
1164  * Signed 16-bit integer.
1165  */
1166  BLE_GATT_FORMAT_SINT16 = 0x0E,
1167 
1168  /**
1169  * Signed 24-bit integer.
1170  */
1171  BLE_GATT_FORMAT_SINT24 = 0x0F,
1172 
1173  /**
1174  * Signed 32-bit integer.
1175  */
1176  BLE_GATT_FORMAT_SINT32 = 0x10,
1177 
1178  /**
1179  * Signed 48-bit integer.
1180  */
1181  BLE_GATT_FORMAT_SINT48 = 0x11,
1182 
1183  /**
1184  * Signed 64-bit integer.
1185  */
1186  BLE_GATT_FORMAT_SINT64 = 0x12,
1187 
1188  /**
1189  * Signed 128-bit integer.
1190  */
1191  BLE_GATT_FORMAT_SINT128 = 0x13,
1192 
1193  /**
1194  * IEEE-754 32-bit floating point.
1195  */
1196  BLE_GATT_FORMAT_FLOAT32 = 0x14,
1197 
1198  /**
1199  * IEEE-754 64-bit floating point.
1200  */
1201  BLE_GATT_FORMAT_FLOAT64 = 0x15,
1202 
1203  /**
1204  * IEEE-11073 16-bit SFLOAT.
1205  */
1206  BLE_GATT_FORMAT_SFLOAT = 0x16,
1207 
1208  /**
1209  * IEEE-11073 32-bit FLOAT.
1210  */
1211  BLE_GATT_FORMAT_FLOAT = 0x17,
1212 
1213  /**
1214  * IEEE-20601 format.
1215  */
1216  BLE_GATT_FORMAT_DUINT16 = 0x18,
1217 
1218  /**
1219  * UTF8 string.
1220  */
1221  BLE_GATT_FORMAT_UTF8S = 0x19,
1222 
1223  /**
1224  * UTF16 string.
1225  */
1226  BLE_GATT_FORMAT_UTF16S = 0x1A,
1227 
1228  /**
1229  * Opaque Structure.
1230  */
1231  BLE_GATT_FORMAT_STRUCT = 0x1B
1232  };
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  */
1246  BLE_GATT_CHAR_PROPERTIES_NONE = 0x00,
1247 
1248  /**
1249  * Permits broadcasts of the characteristic value using the Server
1250  * Characteristic Configuration descriptor.
1251  */
1252  BLE_GATT_CHAR_PROPERTIES_BROADCAST = 0x01,
1253 
1254  /**
1255  * Permits reads of the characteristic value.
1256  */
1257  BLE_GATT_CHAR_PROPERTIES_READ = 0x02,
1258 
1259  /**
1260  * Permits writes of the characteristic value without response.
1261  */
1262  BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE = 0x04,
1263 
1264  /**
1265  * Permits writes of the characteristic value with response.
1266  */
1267  BLE_GATT_CHAR_PROPERTIES_WRITE = 0x08,
1268 
1269  /**
1270  * Permits notifications of a characteristic value without acknowledgment.
1271  */
1272  BLE_GATT_CHAR_PROPERTIES_NOTIFY = 0x10,
1273 
1274  /**
1275  * Permits indications of a characteristic value with acknowledgment.
1276  */
1277  BLE_GATT_CHAR_PROPERTIES_INDICATE = 0x20,
1278 
1279  /**
1280  * Permits signed writes to the characteristic value.
1281  */
1282  BLE_GATT_CHAR_PROPERTIES_AUTHENTICATED_SIGNED_WRITES = 0x40,
1283 
1284  /**
1285  * The Characteristic Extended Properties descriptor
1286  * defines additional characteristic properties.
1287  */
1288  BLE_GATT_CHAR_PROPERTIES_EXTENDED_PROPERTIES = 0x80
1289  };
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 =
1302  BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE |
1303  BLE_GATT_CHAR_PROPERTIES_WRITE |
1304  BLE_GATT_CHAR_PROPERTIES_AUTHENTICATED_SIGNED_WRITES;
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  */
1335  uint8_t gatt_format;
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.
1431  if (_properties & BLE_GATT_CHAR_PROPERTIES_AUTHENTICATED_SIGNED_WRITES) {
1432  _valueAttribute.setWriteSecurityRequirement(
1433  SecurityRequirement_t::UNAUTHENTICATED
1434  );
1435  }
1436 #endif // BLE_FEATURE_SECURITY
1437  }
1438 
1439  GattCharacteristic(const GattCharacteristic &) = delete;
1440  GattCharacteristic& operator=(const GattCharacteristic &) = delete;
1441 
1442  ~GattCharacteristic() {
1443  delete _implicit_cccd;
1444  _implicit_cccd = nullptr;
1445  }
1446 
1447 public:
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  */
1471  void setReadSecurityRequirement(SecurityRequirement_t security)
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  */
1481  SecurityRequirement_t getReadSecurityRequirement() const
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  */
1496  void setWriteSecurityRequirement(SecurityRequirement_t security)
1497  {
1498 #if BLE_FEATURE_SECURITY
1499  MBED_ASSERT(
1500  ((_properties & BLE_GATT_CHAR_PROPERTIES_AUTHENTICATED_SIGNED_WRITES) &&
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  */
1513  SecurityRequirement_t getWriteSecurityRequirement() const
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  */
1527  void setUpdateSecurityRequirement(SecurityRequirement_t security)
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  */
1541  SecurityRequirement_t getUpdateSecurityRequirement() const
1542  {
1543  return static_cast<SecurityRequirement_t::type>(_update_security);
1544  }
1545 
1546 public:
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  */
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  * Register the read requests event handler.
1584  *
1585  * The callback registered is invoked when the client attempts to read the
1586  * characteristic value; the event handler can accept or reject the read
1587  * request with the appropriate error code. It can also set specific outgoing
1588  * data.
1589  *
1590  * @param[in] callback Event handler being registered.
1591  */
1594  ) {
1595  readAuthorizationCallback.attach(callback);
1596  }
1597 
1598  /**
1599  * Register the read requests event handler.
1600  *
1601  * The callback registered is invoked when the client attempts to read the
1602  * characteristic value; the event handler can accept or reject the read
1603  * request with the appropriate error code. It can also set specific outgoing
1604  * data.
1605  *
1606  * @param[in] object Pointer to the object of a class defining the event
1607  * handler (@p member). It must remain valid for the lifetime of the
1608  * GattCharacteristic.
1609  * @param[in] member The member function that handles the read event.
1610  */
1611  template <typename T>
1613  T *object,
1614  void (T::*member)(GattReadAuthCallbackParams *)
1615  ) {
1616  readAuthorizationCallback.attach(object, member);
1617  }
1618 
1619  /**
1620  * Invoke the write authorization callback.
1621  *
1622  * This function is a helper that calls the registered write handler to
1623  * determine the authorization reply for a write request.
1624  *
1625  * @attention This function is not meant to be called by user code.
1626  *
1627  * @param[in] params Context of the write-auth request; it contains an
1628  * out-parameter used as a reply.
1629  *
1630  * @return A GattAuthCallbackReply_t value indicating whether authorization
1631  * is granted.
1632  */
1634  {
1635  if (!isWriteAuthorizationEnabled()) {
1637  }
1638 
1639  /* Initialized to no-error by default. */
1641  writeAuthorizationCallback.call(params);
1642  return params->authorizationReply;
1643  }
1644 
1645  /**
1646  * Invoke the read authorization callback.
1647  *
1648  * This function is a helper that calls the registered read handler to
1649  * determine the authorization reply for a read request.
1650  *
1651  * @attention This function is not meant to be called by user code.
1652  *
1653  * @param[in] params Context of the read-auth request; it contains an
1654  * out-parameter used as a reply and the handler can fill it with outgoing
1655  * data.
1656  *
1657  * @return A GattAuthCallbackReply_t value indicating whether authorization
1658  * is granted.
1659  *
1660  * @note If the read request is approved and params->data remains nullptr, then
1661  * the current characteristic value is used in the read response payload.
1662  *
1663  * @note If the read is approved, the event handler can specify an outgoing
1664  * value directly with the help of the fields
1665  * GattReadAuthCallbackParams::data and GattReadAuthCallbackParams::len.
1666  */
1668  {
1669  if (!isReadAuthorizationEnabled()) {
1671  }
1672 
1673  /* Initialized to no-error by default. */
1675  readAuthorizationCallback.call(params);
1676  return params->authorizationReply;
1677  }
1678 
1679 public:
1680  /**
1681  * Get the characteristic's value attribute.
1682  *
1683  * @return A reference to the characteristic's value attribute.
1684  */
1686  {
1687  return _valueAttribute;
1688  }
1689 
1690  /**
1691  * Get the characteristic's value attribute.
1692  *
1693  * @return A const reference to the characteristic's value attribute.
1694  */
1696  {
1697  return _valueAttribute;
1698  }
1699 
1700  /**
1701  * Get the characteristic's value attribute handle in the ATT table.
1702  *
1703  * @return The value attribute handle.
1704  *
1705  * @note The underlying BLE stack assigns the attribute handle when the
1706  * enclosing service is added.
1707  */
1709  {
1710  return getValueAttribute().getHandle();
1711  }
1712 
1713  /**
1714  * Get the characteristic's properties.
1715  *
1716  * @note Refer to GattCharacteristic::Properties_t.
1717  *
1718  * @return The characteristic's properties.
1719  */
1720  uint8_t getProperties() const
1721  {
1722  return _properties;
1723  }
1724 
1725  /**
1726  * Get the total number of descriptors within this characteristic.
1727  *
1728  * @return The total number of descriptors.
1729  */
1730  uint8_t getDescriptorCount() const
1731  {
1732  return (_implicit_cccd == nullptr? _descriptorCount : _descriptorCount+1);
1733  }
1734 
1735  /**
1736  * Check whether read authorization is enabled.
1737  *
1738  * Read authorization is enabled when a read authorization event handler is
1739  * set up.
1740  *
1741  * @return true if read authorization is enabled and false otherwise.
1742  */
1744  {
1745  return readAuthorizationCallback;
1746  }
1747 
1748  /**
1749  * Check whether write authorization is enabled.
1750  *
1751  * Write authorization is enabled when a write authorization event handler is
1752  * set up.
1753  *
1754  * @return true if write authorization is enabled, false otherwise.
1755  */
1757  {
1758  return writeAuthorizationCallback;
1759  }
1760 
1761  /**
1762  * Get this characteristic's descriptor at a specific index.
1763  *
1764  * @param[in] index The index of the descriptor to get.
1765  *
1766  * @return A pointer the requested descriptor if @p index is within the
1767  * range of the descriptor array or nullptr otherwise.
1768  *
1769  * @note if this characteristic has an implicitly-created CCCD this
1770  * descriptor will be available at the highest index
1771  * (ie: return of getDescriptorCount() - 1)
1772  */
1774  {
1775 
1776  if(index == _descriptorCount) {
1777  // If _implicit_cccd is nullptr, we want to return that anyway
1778  return _implicit_cccd;
1779  }
1780  else if (index > _descriptorCount) {
1781  return nullptr;
1782  }
1783 
1784  return _descriptors[index];
1785  }
1786 
1787 
1788 private:
1789 
1790  friend ble::impl::GattServer;
1791 
1792 #if !defined(DOXYGEN_ONLY)
1793  /**
1794  * Sets this GattCharacteristic's implicitly-created CCCD, if
1795  * applicable.
1796  *
1797  * @note once this is called, the pointed-to GattAttribute
1798  * is owned by this GattCharacteristic and will be deleted
1799  * during this object's destructor
1800  */
1801  void setImplicitCCCD(GattAttribute *implicit_cccd) {
1802  _implicit_cccd = implicit_cccd;
1803  }
1804 #endif // !defined(DOXYGEN_ONLY)
1805 
1806 
1807 private:
1808 
1809  /**
1810  * Attribute that contains the actual value of this characteristic.
1811  */
1812  GattAttribute _valueAttribute;
1813 
1814  /**
1815  * The characteristic's properties. Refer to
1816  * GattCharacteristic::Properties_t.
1817  */
1818  uint8_t _properties;
1819 
1820  /**
1821  * The characteristic's descriptor attributes.
1822  */
1823  GattAttribute **_descriptors;
1824 
1825  /**
1826  * The number of descriptors in this characteristic.
1827  */
1828  uint8_t _descriptorCount;
1829 
1830  /**
1831  * Pointer to characteristic's implicit CCCD, if applicable
1832  *
1833  * @note this is only populated if the stack creates an implicit CCCD
1834  * for this GattCharacteristic. If the descriptors array passed into
1835  * the constructor includes a CCCD this field is left as nullptr to
1836  * indicate the CCCD was explicitly created.
1837  */
1838  GattAttribute* _implicit_cccd = nullptr;
1839 
1840  /**
1841  * The registered callback handler for read authorization reply.
1842  */
1844  readAuthorizationCallback;
1845 
1846  /**
1847  * The registered callback handler for write authorization reply.
1848  */
1850  writeAuthorizationCallback;
1851 
1852  /**
1853  * Security requirements of update operations.
1854  *
1855  * The peer must meet the security requirement to enable, disable and
1856  * receive updates
1857  */
1858  uint8_t _update_security: SecurityRequirement_t::size;
1859 };
1860 
1861 /**
1862  * Helper class that represents a read only GattCharacteristic.
1863  */
1864 template <typename T>
1866 public:
1867  /**
1868  * Construct a ReadOnlyGattCharacteristic.
1869  *
1870  * @param[in] uuid The characteristic's UUID.
1871  * @param[in] valuePtr Pointer to the characteristic's initial value. The
1872  * pointer is reinterpreted as a pointer to an uint8_t buffer.
1873  * @param[in] additionalProperties Additional characteristic properties. By
1874  * default, the properties are set to
1875  * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
1876  * @param[in] descriptors An array of pointers to descriptors to be added
1877  * to the new characteristic.
1878  * @param[in] numDescriptors The total number of descriptors in @p
1879  * descriptors.
1880  *
1881  * @note Instances of ReadOnlyGattCharacteristic have a fixed length
1882  * attribute value that equals sizeof(T). For a variable length alternative,
1883  * use GattCharacteristic directly.
1884  */
1886  const UUID &uuid,
1887  T *valuePtr,
1888  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
1889  GattAttribute *descriptors[] = nullptr,
1890  unsigned numDescriptors = 0
1891  ) : GattCharacteristic(
1892  uuid,
1893  reinterpret_cast<uint8_t *>(valuePtr),
1894  sizeof(T),
1895  sizeof(T),
1896  BLE_GATT_CHAR_PROPERTIES_READ | additionalProperties,
1897  descriptors,
1898  numDescriptors,
1899  false
1900  ) {
1901  }
1902 };
1903 
1904 /**
1905  * Helper class that represents a write only GattCharacteristic.
1906  */
1907 template <typename T>
1909 public:
1910  /**
1911  * Construct a WriteOnlyGattCharacteristic.
1912  *
1913  * @param[in] uuid The characteristic's UUID.
1914  * @param[in] valuePtr Pointer to the characteristic's initial value. The
1915  * pointer is reinterpreted as a pointer to an uint8_t buffer.
1916  * @param[in] additionalProperties Additional characteristic properties. By
1917  * default, the properties are set to
1918  * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE.
1919  * @param[in] descriptors An array of pointers to descriptors to be added to
1920  * the new characteristic.
1921  * @param[in] numDescriptors The total number of descriptors in @p
1922  * descriptors.
1923  *
1924  * @note Instances of WriteOnlyGattCharacteristic have variable length
1925  * attribute value with maximum size equal to sizeof(T). For a fixed length
1926  * alternative, use GattCharacteristic directly.
1927  */
1929  const UUID &uuid,
1930  T *valuePtr,
1931  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
1932  GattAttribute *descriptors[] = nullptr,
1933  unsigned numDescriptors = 0
1934  ) : GattCharacteristic(
1935  uuid,
1936  reinterpret_cast<uint8_t *>(valuePtr),
1937  sizeof(T),
1938  sizeof(T),
1939  BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
1940  descriptors,
1941  numDescriptors
1942  ) {
1943  }
1944 };
1945 
1946 /**
1947  * Helper class that represents a readable and writable GattCharacteristic.
1948  */
1949 template <typename T>
1951 public:
1952  /**
1953  * Construct a ReadWriteGattCharacteristic.
1954  *
1955  * @param[in] uuid The characteristic's UUID.
1956  * @param[in] valuePtr Pointer to the characteristic's initial value. The
1957  * pointer is reinterpreted as a pointer to an uint8_t buffer.
1958  * @param[in] additionalProperties Additional characteristic properties. By
1959  * default, the properties are set to
1960  * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE and
1961  * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
1962  * @param[in] descriptors An array of pointers to descriptors to be added to
1963  * the new characteristic.
1964  * @param[in] numDescriptors The total number of descriptors in @p descriptors.
1965  *
1966  * @note Instances of ReadWriteGattCharacteristic have variable length
1967  * attribute value with maximum size equal to sizeof(T). For a fixed length
1968  * alternative, use GattCharacteristic directly.
1969  */
1971  const UUID &uuid,
1972  T *valuePtr,
1973  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
1974  GattAttribute *descriptors[] = nullptr,
1975  unsigned numDescriptors = 0
1976  ) : GattCharacteristic(
1977  uuid,
1978  reinterpret_cast<uint8_t *>(valuePtr),
1979  sizeof(T),
1980  sizeof(T),
1981  BLE_GATT_CHAR_PROPERTIES_READ | BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
1982  descriptors,
1983  numDescriptors
1984  ) {
1985  }
1986 };
1987 
1988 /**
1989  * Helper class that represents a write-only GattCharacteristic with an array
1990  * value.
1991  */
1992 template <typename T, unsigned NUM_ELEMENTS>
1994 public:
1995  /**
1996  * Construct a WriteOnlyGattCharacteristic.
1997  *
1998  * @param[in] uuid The characteristic's UUID.
1999  * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
2000  * the characteristic's initial value. The pointer is reinterpreted as a
2001  * pointer to an uint8_t buffer.
2002  * @param[in] additionalProperties Additional characteristic properties. By
2003  * default, the properties are set to
2004  * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE.
2005  * @param[in] descriptors An array of pointers to descriptors to be added to
2006  * the new characteristic.
2007  * @param[in] numDescriptors The total number of descriptors in @p descriptors.
2008  *
2009  * @note Instances of WriteOnlyGattCharacteristic have variable length
2010  * attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
2011  * For a fixed length alternative, use GattCharacteristic directly.
2012  */
2014  const UUID &uuid,
2015  T valuePtr[NUM_ELEMENTS],
2016  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
2017  GattAttribute *descriptors[] = nullptr,
2018  unsigned numDescriptors = 0
2019  ) : GattCharacteristic(
2020  uuid,
2021  reinterpret_cast<uint8_t *>(valuePtr),
2022  sizeof(T) * NUM_ELEMENTS,
2023  sizeof(T) * NUM_ELEMENTS,
2024  BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
2025  descriptors,
2026  numDescriptors
2027  ) {
2028  }
2029 };
2030 
2031 /**
2032  * Helper class that represents a read-only GattCharacteristic with an array
2033  * value.
2034  */
2035 template <typename T, unsigned NUM_ELEMENTS>
2037 public:
2038  /**
2039  * Construct a ReadOnlyGattCharacteristic.
2040  *
2041  * @param[in] uuid The characteristic's UUID.
2042  * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
2043  * the characteristic's initial value. The pointer is reinterpreted as a
2044  * pointer to an uint8_t buffer.
2045  * @param[in] additionalProperties Additional characteristic properties. By
2046  * default, the properties are set to
2047  * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
2048  * @param[in] descriptors An array of pointers to descriptors to be added to
2049  * the new characteristic.
2050  * @param[in] numDescriptors The total number of descriptors in @p
2051  * descriptors.
2052  *
2053  * @note Instances of ReadOnlyGattCharacteristic have fixed length
2054  * attribute value that equals sizeof(T) * NUM_ELEMENTS. For a variable
2055  * length alternative, use GattCharacteristic directly.
2056  */
2058  const UUID &uuid,
2059  T valuePtr[NUM_ELEMENTS],
2060  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
2061  GattAttribute *descriptors[] = nullptr,
2062  unsigned numDescriptors = 0
2063  ) : GattCharacteristic(
2064  uuid,
2065  reinterpret_cast<uint8_t *>(valuePtr),
2066  sizeof(T) * NUM_ELEMENTS,
2067  sizeof(T) * NUM_ELEMENTS,
2068  BLE_GATT_CHAR_PROPERTIES_READ | additionalProperties,
2069  descriptors,
2070  numDescriptors,
2071  false
2072  ) {
2073  }
2074 };
2075 
2076 /**
2077  * Helper class that represents a readable and writable GattCharacteristic with
2078  * an array value.
2079  */
2080 template <typename T, unsigned NUM_ELEMENTS>
2082 public:
2083  /**
2084  * Construct a ReadWriteGattCharacteristic.
2085  *
2086  * @param[in] uuid The characteristic's UUID.
2087  * @param[in] valuePtr Pointer to an array of length NUM_ELEMENTS containing
2088  * the characteristic's initial value. The pointer is reinterpreted as a
2089  * pointer to an uint8_t buffer.
2090  * @param[in] additionalProperties Additional characteristic properties. By
2091  * default, the properties are set to
2092  * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE |
2093  * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
2094  * @param[in] descriptors An array of pointers to descriptors to be added to
2095  * the new characteristic.
2096  * @param[in] numDescriptors The total number of descriptors in @p descriptors.
2097  *
2098  * @note Instances of ReadWriteGattCharacteristic have variable length
2099  * attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
2100  * For a fixed length alternative, use GattCharacteristic directly.
2101  */
2103  const UUID &uuid,
2104  T valuePtr[NUM_ELEMENTS],
2105  uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
2106  GattAttribute *descriptors[] = nullptr,
2107  unsigned numDescriptors = 0
2108  ) : GattCharacteristic(
2109  uuid,
2110  reinterpret_cast<uint8_t *>(valuePtr),
2111  sizeof(T) * NUM_ELEMENTS,
2112  sizeof(T) * NUM_ELEMENTS,
2113  BLE_GATT_CHAR_PROPERTIES_READ | BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties,
2114  descriptors,
2115  numDescriptors
2116  ) {
2117  }
2118 };
2119 
2120 /**
2121  * @}
2122  * @}
2123  * @}
2124  */
2125 
2126 #endif /* ifndef __GATT_CHARACTERISTIC_H__ */
Helper class that represents a readable and writable GattCharacteristic.
uint8_t getProperties() const
Get the characteristic&#39;s properties.
GattAuthCallbackReply_t authorizationReply
Authorization result.
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.
GattAttribute::Handle_t getValueHandle() const
Get the characteristic&#39;s value attribute handle in the ATT table.
SecurityRequirement_t getReadSecurityRequirement() const
Get the security requirement of the read operation.
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.
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.
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.
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
Helper class that represents a read-only GattCharacteristic with an array value.
Representation of a Universally Unique Identifier (UUID).
Definition: common/UUID.h:76
void setReadSecurityRequirement(SecurityRequirement_t security)
Set the security of the read operation.
Representation of a GattServer attribute.
ble::attribute_handle_t Handle_t
Representation of an attribute handle.
Helper class that represents a write-only GattCharacteristic with an array value. ...
int8_t exponent
Exponent for integer data types.
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.
GattAuthCallbackReply_t authorizeWrite(GattWriteAuthCallbackParams *params)
Invoke the write authorization callback.
#define MBED_ASSERT(expr)
MBED_ASSERT Declare runtime assertions: results in runtime error if condition is false.
Definition: mbed_assert.h:65
static bool isReadable(uint8_t properties)
Indicates if the properties is readable.
SecurityRequirement_t getWriteSecurityRequirement() const
Get the security requirement of write operations.
Representation of a GattServer characteristic.
GattAttribute * getDescriptor(uint8_t index)
Get this characteristic&#39;s descriptor at a specific index.
Helper class that represents a write only GattCharacteristic.
uint16_t gatt_unit
Unit of the characteristic value.
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.
void setWriteSecurityRequirement(SecurityRequirement_t security)
Set the security requirement of the write operations.
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.
void setWriteAuthorizationCallback(T *object, void(T::*member)(GattWriteAuthCallbackParams *))
Register a callback handling client&#39;s write requests or commands.
Helper class that represents a read only GattCharacteristic.
Value of a Characteristic Presentation Format descriptor.
Entry namespace for all BLE API definitions.
GattAuthCallbackReply_t
Enumeration of allowed values returned by read or write authorization process.
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.