mbed os with nrf51 internal bandgap enabled to read battery level

Dependents:   BLE_file_test BLE_Blink ExternalEncoder

Committer:
elessair
Date:
Sun Oct 23 15:10:02 2016 +0000
Revision:
0:f269e3021894
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elessair 0:f269e3021894 1 /* mbed Microcontroller Library
elessair 0:f269e3021894 2 * Copyright (c) 2006-2013 ARM Limited
elessair 0:f269e3021894 3 *
elessair 0:f269e3021894 4 * Licensed under the Apache License, Version 2.0 (the "License");
elessair 0:f269e3021894 5 * you may not use this file except in compliance with the License.
elessair 0:f269e3021894 6 * You may obtain a copy of the License at
elessair 0:f269e3021894 7 *
elessair 0:f269e3021894 8 * http://www.apache.org/licenses/LICENSE-2.0
elessair 0:f269e3021894 9 *
elessair 0:f269e3021894 10 * Unless required by applicable law or agreed to in writing, software
elessair 0:f269e3021894 11 * distributed under the License is distributed on an "AS IS" BASIS,
elessair 0:f269e3021894 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
elessair 0:f269e3021894 13 * See the License for the specific language governing permissions and
elessair 0:f269e3021894 14 * limitations under the License.
elessair 0:f269e3021894 15 */
elessair 0:f269e3021894 16
elessair 0:f269e3021894 17 #ifndef __GATT_CHARACTERISTIC_H__
elessair 0:f269e3021894 18 #define __GATT_CHARACTERISTIC_H__
elessair 0:f269e3021894 19
elessair 0:f269e3021894 20 #include "Gap.h"
elessair 0:f269e3021894 21 #include "SecurityManager.h"
elessair 0:f269e3021894 22 #include "GattAttribute.h"
elessair 0:f269e3021894 23 #include "GattCallbackParamTypes.h"
elessair 0:f269e3021894 24 #include "FunctionPointerWithContext.h"
elessair 0:f269e3021894 25
elessair 0:f269e3021894 26 class GattCharacteristic {
elessair 0:f269e3021894 27 public:
elessair 0:f269e3021894 28 enum {
elessair 0:f269e3021894 29 UUID_BATTERY_LEVEL_STATE_CHAR = 0x2A1B,
elessair 0:f269e3021894 30 UUID_BATTERY_POWER_STATE_CHAR = 0x2A1A,
elessair 0:f269e3021894 31 UUID_REMOVABLE_CHAR = 0x2A3A,
elessair 0:f269e3021894 32 UUID_SERVICE_REQUIRED_CHAR = 0x2A3B,
elessair 0:f269e3021894 33 UUID_ALERT_CATEGORY_ID_CHAR = 0x2A43,
elessair 0:f269e3021894 34 UUID_ALERT_CATEGORY_ID_BIT_MASK_CHAR = 0x2A42,
elessair 0:f269e3021894 35 UUID_ALERT_LEVEL_CHAR = 0x2A06,
elessair 0:f269e3021894 36 UUID_ALERT_NOTIFICATION_CONTROL_POINT_CHAR = 0x2A44,
elessair 0:f269e3021894 37 UUID_ALERT_STATUS_CHAR = 0x2A3F,
elessair 0:f269e3021894 38 UUID_BATTERY_LEVEL_CHAR = 0x2A19,
elessair 0:f269e3021894 39 UUID_BLOOD_PRESSURE_FEATURE_CHAR = 0x2A49,
elessair 0:f269e3021894 40 UUID_BLOOD_PRESSURE_MEASUREMENT_CHAR = 0x2A35,
elessair 0:f269e3021894 41 UUID_BODY_SENSOR_LOCATION_CHAR = 0x2A38,
elessair 0:f269e3021894 42 UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR = 0x2A22,
elessair 0:f269e3021894 43 UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR = 0x2A32,
elessair 0:f269e3021894 44 UUID_BOOT_MOUSE_INPUT_REPORT_CHAR = 0x2A33,
elessair 0:f269e3021894 45 UUID_CURRENT_TIME_CHAR = 0x2A2B,
elessair 0:f269e3021894 46 UUID_DATE_TIME_CHAR = 0x2A08,
elessair 0:f269e3021894 47 UUID_DAY_DATE_TIME_CHAR = 0x2A0A,
elessair 0:f269e3021894 48 UUID_DAY_OF_WEEK_CHAR = 0x2A09,
elessair 0:f269e3021894 49 UUID_DST_OFFSET_CHAR = 0x2A0D,
elessair 0:f269e3021894 50 UUID_EXACT_TIME_256_CHAR = 0x2A0C,
elessair 0:f269e3021894 51 UUID_FIRMWARE_REVISION_STRING_CHAR = 0x2A26,
elessair 0:f269e3021894 52 UUID_GLUCOSE_FEATURE_CHAR = 0x2A51,
elessair 0:f269e3021894 53 UUID_GLUCOSE_MEASUREMENT_CHAR = 0x2A18,
elessair 0:f269e3021894 54 UUID_GLUCOSE_MEASUREMENT_CONTEXT_CHAR = 0x2A34,
elessair 0:f269e3021894 55 UUID_HARDWARE_REVISION_STRING_CHAR = 0x2A27,
elessair 0:f269e3021894 56 UUID_HEART_RATE_CONTROL_POINT_CHAR = 0x2A39,
elessair 0:f269e3021894 57 UUID_HEART_RATE_MEASUREMENT_CHAR = 0x2A37,
elessair 0:f269e3021894 58 UUID_HID_CONTROL_POINT_CHAR = 0x2A4C,
elessair 0:f269e3021894 59 UUID_HID_INFORMATION_CHAR = 0x2A4A,
elessair 0:f269e3021894 60 UUID_HUMIDITY_CHAR = 0x2A6F,
elessair 0:f269e3021894 61 UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR = 0x2A2A,
elessair 0:f269e3021894 62 UUID_INTERMEDIATE_CUFF_PRESSURE_CHAR = 0x2A36,
elessair 0:f269e3021894 63 UUID_INTERMEDIATE_TEMPERATURE_CHAR = 0x2A1E,
elessair 0:f269e3021894 64 UUID_LOCAL_TIME_INFORMATION_CHAR = 0x2A0F,
elessair 0:f269e3021894 65 UUID_MANUFACTURER_NAME_STRING_CHAR = 0x2A29,
elessair 0:f269e3021894 66 UUID_MEASUREMENT_INTERVAL_CHAR = 0x2A21,
elessair 0:f269e3021894 67 UUID_MODEL_NUMBER_STRING_CHAR = 0x2A24,
elessair 0:f269e3021894 68 UUID_UNREAD_ALERT_CHAR = 0x2A45,
elessair 0:f269e3021894 69 UUID_NEW_ALERT_CHAR = 0x2A46,
elessair 0:f269e3021894 70 UUID_PNP_ID_CHAR = 0x2A50,
elessair 0:f269e3021894 71 UUID_PRESSURE_CHAR = 0x2A6D,
elessair 0:f269e3021894 72 UUID_PROTOCOL_MODE_CHAR = 0x2A4E,
elessair 0:f269e3021894 73 UUID_RECORD_ACCESS_CONTROL_POINT_CHAR = 0x2A52,
elessair 0:f269e3021894 74 UUID_REFERENCE_TIME_INFORMATION_CHAR = 0x2A14,
elessair 0:f269e3021894 75 UUID_REPORT_CHAR = 0x2A4D,
elessair 0:f269e3021894 76 UUID_REPORT_MAP_CHAR = 0x2A4B,
elessair 0:f269e3021894 77 UUID_RINGER_CONTROL_POINT_CHAR = 0x2A40,
elessair 0:f269e3021894 78 UUID_RINGER_SETTING_CHAR = 0x2A41,
elessair 0:f269e3021894 79 UUID_SCAN_INTERVAL_WINDOW_CHAR = 0x2A4F,
elessair 0:f269e3021894 80 UUID_SCAN_REFRESH_CHAR = 0x2A31,
elessair 0:f269e3021894 81 UUID_SERIAL_NUMBER_STRING_CHAR = 0x2A25,
elessair 0:f269e3021894 82 UUID_SOFTWARE_REVISION_STRING_CHAR = 0x2A28,
elessair 0:f269e3021894 83 UUID_SUPPORTED_NEW_ALERT_CATEGORY_CHAR = 0x2A47,
elessair 0:f269e3021894 84 UUID_SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR = 0x2A48,
elessair 0:f269e3021894 85 UUID_SYSTEM_ID_CHAR = 0x2A23,
elessair 0:f269e3021894 86 UUID_TEMPERATURE_CHAR = 0x2A6E,
elessair 0:f269e3021894 87 UUID_TEMPERATURE_MEASUREMENT_CHAR = 0x2A1C,
elessair 0:f269e3021894 88 UUID_TEMPERATURE_TYPE_CHAR = 0x2A1D,
elessair 0:f269e3021894 89 UUID_TIME_ACCURACY_CHAR = 0x2A12,
elessair 0:f269e3021894 90 UUID_TIME_SOURCE_CHAR = 0x2A13,
elessair 0:f269e3021894 91 UUID_TIME_UPDATE_CONTROL_POINT_CHAR = 0x2A16,
elessair 0:f269e3021894 92 UUID_TIME_UPDATE_STATE_CHAR = 0x2A17,
elessair 0:f269e3021894 93 UUID_TIME_WITH_DST_CHAR = 0x2A11,
elessair 0:f269e3021894 94 UUID_TIME_ZONE_CHAR = 0x2A0E,
elessair 0:f269e3021894 95 UUID_TX_POWER_LEVEL_CHAR = 0x2A07,
elessair 0:f269e3021894 96 UUID_CSC_FEATURE_CHAR = 0x2A5C,
elessair 0:f269e3021894 97 UUID_CSC_MEASUREMENT_CHAR = 0x2A5B,
elessair 0:f269e3021894 98 UUID_RSC_FEATURE_CHAR = 0x2A54,
elessair 0:f269e3021894 99 UUID_RSC_MEASUREMENT_CHAR = 0x2A53
elessair 0:f269e3021894 100 };
elessair 0:f269e3021894 101
elessair 0:f269e3021894 102 /**
elessair 0:f269e3021894 103 * @brief Standard GATT characteristic presentation format unit types.
elessair 0:f269e3021894 104 * These unit types are used to describe what the raw numeric
elessair 0:f269e3021894 105 * data in a characteristic actually represents.
elessair 0:f269e3021894 106 *
elessair 0:f269e3021894 107 * @note See https://developer.bluetooth.org/gatt/units/Pages/default.aspx
elessair 0:f269e3021894 108 */
elessair 0:f269e3021894 109 enum {
elessair 0:f269e3021894 110 BLE_GATT_UNIT_NONE = 0x2700, /**< No specified unit type. */
elessair 0:f269e3021894 111 BLE_GATT_UNIT_LENGTH_METRE = 0x2701, /**< Length, metre. */
elessair 0:f269e3021894 112 BLE_GATT_UNIT_MASS_KILOGRAM = 0x2702, /**< Mass, kilogram. */
elessair 0:f269e3021894 113 BLE_GATT_UNIT_TIME_SECOND = 0x2703, /**< Time, second. */
elessair 0:f269e3021894 114 BLE_GATT_UNIT_ELECTRIC_CURRENT_AMPERE = 0x2704, /**< Electric current, ampere. */
elessair 0:f269e3021894 115 BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_KELVIN = 0x2705, /**< Thermodynamic temperature, kelvin. */
elessair 0:f269e3021894 116 BLE_GATT_UNIT_AMOUNT_OF_SUBSTANCE_MOLE = 0x2706, /**< Amount of substance, mole. */
elessair 0:f269e3021894 117 BLE_GATT_UNIT_LUMINOUS_INTENSITY_CANDELA = 0x2707, /**< Luminous intensity, candela. */
elessair 0:f269e3021894 118 BLE_GATT_UNIT_AREA_SQUARE_METRES = 0x2710, /**< Area, square metres. */
elessair 0:f269e3021894 119 BLE_GATT_UNIT_VOLUME_CUBIC_METRES = 0x2711, /**< Volume, cubic metres. */
elessair 0:f269e3021894 120 BLE_GATT_UNIT_VELOCITY_METRES_PER_SECOND = 0x2712, /**< Velocity, metres per second. */
elessair 0:f269e3021894 121 BLE_GATT_UNIT_ACCELERATION_METRES_PER_SECOND_SQUARED = 0x2713, /**< Acceleration, metres per second squared. */
elessair 0:f269e3021894 122 BLE_GATT_UNIT_WAVENUMBER_RECIPROCAL_METRE = 0x2714, /**< Wave number reciprocal, metre. */
elessair 0:f269e3021894 123 BLE_GATT_UNIT_DENSITY_KILOGRAM_PER_CUBIC_METRE = 0x2715, /**< Density, kilogram per cubic metre. */
elessair 0:f269e3021894 124 BLE_GATT_UNIT_SURFACE_DENSITY_KILOGRAM_PER_SQUARE_METRE = 0x2716, /**< */
elessair 0:f269e3021894 125 BLE_GATT_UNIT_SPECIFIC_VOLUME_CUBIC_METRE_PER_KILOGRAM = 0x2717, /**< */
elessair 0:f269e3021894 126 BLE_GATT_UNIT_CURRENT_DENSITY_AMPERE_PER_SQUARE_METRE = 0x2718, /**< */
elessair 0:f269e3021894 127 BLE_GATT_UNIT_MAGNETIC_FIELD_STRENGTH_AMPERE_PER_METRE = 0x2719, /**< Magnetic field strength, ampere per metre. */
elessair 0:f269e3021894 128 BLE_GATT_UNIT_AMOUNT_CONCENTRATION_MOLE_PER_CUBIC_METRE = 0x271A, /**< */
elessair 0:f269e3021894 129 BLE_GATT_UNIT_MASS_CONCENTRATION_KILOGRAM_PER_CUBIC_METRE = 0x271B, /**< */
elessair 0:f269e3021894 130 BLE_GATT_UNIT_LUMINANCE_CANDELA_PER_SQUARE_METRE = 0x271C, /**< */
elessair 0:f269e3021894 131 BLE_GATT_UNIT_REFRACTIVE_INDEX = 0x271D, /**< */
elessair 0:f269e3021894 132 BLE_GATT_UNIT_RELATIVE_PERMEABILITY = 0x271E, /**< */
elessair 0:f269e3021894 133 BLE_GATT_UNIT_PLANE_ANGLE_RADIAN = 0x2720, /**< */
elessair 0:f269e3021894 134 BLE_GATT_UNIT_SOLID_ANGLE_STERADIAN = 0x2721, /**< */
elessair 0:f269e3021894 135 BLE_GATT_UNIT_FREQUENCY_HERTZ = 0x2722, /**< Frequency, hertz. */
elessair 0:f269e3021894 136 BLE_GATT_UNIT_FORCE_NEWTON = 0x2723, /**< Force, newton. */
elessair 0:f269e3021894 137 BLE_GATT_UNIT_PRESSURE_PASCAL = 0x2724, /**< Pressure, pascal. */
elessair 0:f269e3021894 138 BLE_GATT_UNIT_ENERGY_JOULE = 0x2725, /**< Energy, joule. */
elessair 0:f269e3021894 139 BLE_GATT_UNIT_POWER_WATT = 0x2726, /**< Power, watt. */
elessair 0:f269e3021894 140 BLE_GATT_UNIT_ELECTRIC_CHARGE_COULOMB = 0x2727, /**< Electrical charge, coulomb. */
elessair 0:f269e3021894 141 BLE_GATT_UNIT_ELECTRIC_POTENTIAL_DIFFERENCE_VOLT = 0x2728, /**< Electrical potential difference, voltage. */
elessair 0:f269e3021894 142 BLE_GATT_UNIT_CAPACITANCE_FARAD = 0x2729, /**< */
elessair 0:f269e3021894 143 BLE_GATT_UNIT_ELECTRIC_RESISTANCE_OHM = 0x272A, /**< */
elessair 0:f269e3021894 144 BLE_GATT_UNIT_ELECTRIC_CONDUCTANCE_SIEMENS = 0x272B, /**< */
elessair 0:f269e3021894 145 BLE_GATT_UNIT_MAGNETIC_FLEX_WEBER = 0x272C, /**< */
elessair 0:f269e3021894 146 BLE_GATT_UNIT_MAGNETIC_FLEX_DENSITY_TESLA = 0x272D, /**< */
elessair 0:f269e3021894 147 BLE_GATT_UNIT_INDUCTANCE_HENRY = 0x272E, /**< */
elessair 0:f269e3021894 148 BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_CELSIUS = 0x272F, /**< */
elessair 0:f269e3021894 149 BLE_GATT_UNIT_LUMINOUS_FLUX_LUMEN = 0x2730, /**< */
elessair 0:f269e3021894 150 BLE_GATT_UNIT_ILLUMINANCE_LUX = 0x2731, /**< */
elessair 0:f269e3021894 151 BLE_GATT_UNIT_ACTIVITY_REFERRED_TO_A_RADIONUCLIDE_BECQUEREL = 0x2732, /**< */
elessair 0:f269e3021894 152 BLE_GATT_UNIT_ABSORBED_DOSE_GRAY = 0x2733, /**< */
elessair 0:f269e3021894 153 BLE_GATT_UNIT_DOSE_EQUIVALENT_SIEVERT = 0x2734, /**< */
elessair 0:f269e3021894 154 BLE_GATT_UNIT_CATALYTIC_ACTIVITY_KATAL = 0x2735, /**< */
elessair 0:f269e3021894 155 BLE_GATT_UNIT_DYNAMIC_VISCOSITY_PASCAL_SECOND = 0x2740, /**< */
elessair 0:f269e3021894 156 BLE_GATT_UNIT_MOMENT_OF_FORCE_NEWTON_METRE = 0x2741, /**< */
elessair 0:f269e3021894 157 BLE_GATT_UNIT_SURFACE_TENSION_NEWTON_PER_METRE = 0x2742, /**< */
elessair 0:f269e3021894 158 BLE_GATT_UNIT_ANGULAR_VELOCITY_RADIAN_PER_SECOND = 0x2743, /**< */
elessair 0:f269e3021894 159 BLE_GATT_UNIT_ANGULAR_ACCELERATION_RADIAN_PER_SECOND_SQUARED = 0x2744, /**< */
elessair 0:f269e3021894 160 BLE_GATT_UNIT_HEAT_FLUX_DENSITY_WATT_PER_SQUARE_METRE = 0x2745, /**< */
elessair 0:f269e3021894 161 BLE_GATT_UNIT_HEAT_CAPACITY_JOULE_PER_KELVIN = 0x2746, /**< */
elessair 0:f269e3021894 162 BLE_GATT_UNIT_SPECIFIC_HEAT_CAPACITY_JOULE_PER_KILOGRAM_KELVIN = 0x2747, /**< */
elessair 0:f269e3021894 163 BLE_GATT_UNIT_SPECIFIC_ENERGY_JOULE_PER_KILOGRAM = 0x2748, /**< */
elessair 0:f269e3021894 164 BLE_GATT_UNIT_THERMAL_CONDUCTIVITY_WATT_PER_METRE_KELVIN = 0x2749, /**< */
elessair 0:f269e3021894 165 BLE_GATT_UNIT_ENERGY_DENSITY_JOULE_PER_CUBIC_METRE = 0x274A, /**< */
elessair 0:f269e3021894 166 BLE_GATT_UNIT_ELECTRIC_FIELD_STRENGTH_VOLT_PER_METRE = 0x274B, /**< */
elessair 0:f269e3021894 167 BLE_GATT_UNIT_ELECTRIC_CHARGE_DENSITY_COULOMB_PER_CUBIC_METRE = 0x274C, /**< */
elessair 0:f269e3021894 168 BLE_GATT_UNIT_SURFACE_CHARGE_DENSITY_COULOMB_PER_SQUARE_METRE = 0x274D, /**< */
elessair 0:f269e3021894 169 BLE_GATT_UNIT_ELECTRIC_FLUX_DENSITY_COULOMB_PER_SQUARE_METRE = 0x274E, /**< */
elessair 0:f269e3021894 170 BLE_GATT_UNIT_PERMITTIVITY_FARAD_PER_METRE = 0x274F, /**< */
elessair 0:f269e3021894 171 BLE_GATT_UNIT_PERMEABILITY_HENRY_PER_METRE = 0x2750, /**< */
elessair 0:f269e3021894 172 BLE_GATT_UNIT_MOLAR_ENERGY_JOULE_PER_MOLE = 0x2751, /**< */
elessair 0:f269e3021894 173 BLE_GATT_UNIT_MOLAR_ENTROPY_JOULE_PER_MOLE_KELVIN = 0x2752, /**< */
elessair 0:f269e3021894 174 BLE_GATT_UNIT_EXPOSURE_COULOMB_PER_KILOGRAM = 0x2753, /**< */
elessair 0:f269e3021894 175 BLE_GATT_UNIT_ABSORBED_DOSE_RATE_GRAY_PER_SECOND = 0x2754, /**< */
elessair 0:f269e3021894 176 BLE_GATT_UNIT_RADIANT_INTENSITY_WATT_PER_STERADIAN = 0x2755, /**< */
elessair 0:f269e3021894 177 BLE_GATT_UNIT_RADIANCE_WATT_PER_SQUARE_METRE_STERADIAN = 0x2756, /**< */
elessair 0:f269e3021894 178 BLE_GATT_UNIT_CATALYTIC_ACTIVITY_CONCENTRATION_KATAL_PER_CUBIC_METRE = 0x2757, /**< */
elessair 0:f269e3021894 179 BLE_GATT_UNIT_TIME_MINUTE = 0x2760, /**< Time, minute. */
elessair 0:f269e3021894 180 BLE_GATT_UNIT_TIME_HOUR = 0x2761, /**< Time, hour. */
elessair 0:f269e3021894 181 BLE_GATT_UNIT_TIME_DAY = 0x2762, /**< Time, day. */
elessair 0:f269e3021894 182 BLE_GATT_UNIT_PLANE_ANGLE_DEGREE = 0x2763, /**< */
elessair 0:f269e3021894 183 BLE_GATT_UNIT_PLANE_ANGLE_MINUTE = 0x2764, /**< */
elessair 0:f269e3021894 184 BLE_GATT_UNIT_PLANE_ANGLE_SECOND = 0x2765, /**< */
elessair 0:f269e3021894 185 BLE_GATT_UNIT_AREA_HECTARE = 0x2766, /**< */
elessair 0:f269e3021894 186 BLE_GATT_UNIT_VOLUME_LITRE = 0x2767, /**< */
elessair 0:f269e3021894 187 BLE_GATT_UNIT_MASS_TONNE = 0x2768, /**< */
elessair 0:f269e3021894 188 BLE_GATT_UNIT_PRESSURE_BAR = 0x2780, /**< Pressure, bar. */
elessair 0:f269e3021894 189 BLE_GATT_UNIT_PRESSURE_MILLIMETRE_OF_MERCURY = 0x2781, /**< Pressure, millimetre of mercury. */
elessair 0:f269e3021894 190 BLE_GATT_UNIT_LENGTH_ANGSTROM = 0x2782, /**< */
elessair 0:f269e3021894 191 BLE_GATT_UNIT_LENGTH_NAUTICAL_MILE = 0x2783, /**< */
elessair 0:f269e3021894 192 BLE_GATT_UNIT_AREA_BARN = 0x2784, /**< */
elessair 0:f269e3021894 193 BLE_GATT_UNIT_VELOCITY_KNOT = 0x2785, /**< */
elessair 0:f269e3021894 194 BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_NEPER = 0x2786, /**< */
elessair 0:f269e3021894 195 BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_BEL = 0x2787, /**< */
elessair 0:f269e3021894 196 BLE_GATT_UNIT_LENGTH_YARD = 0x27A0, /**< Length, yard. */
elessair 0:f269e3021894 197 BLE_GATT_UNIT_LENGTH_PARSEC = 0x27A1, /**< Length, parsec. */
elessair 0:f269e3021894 198 BLE_GATT_UNIT_LENGTH_INCH = 0x27A2, /**< Length, inch. */
elessair 0:f269e3021894 199 BLE_GATT_UNIT_LENGTH_FOOT = 0x27A3, /**< Length, foot. */
elessair 0:f269e3021894 200 BLE_GATT_UNIT_LENGTH_MILE = 0x27A4, /**< Length, mile. */
elessair 0:f269e3021894 201 BLE_GATT_UNIT_PRESSURE_POUND_FORCE_PER_SQUARE_INCH = 0x27A5, /**< */
elessair 0:f269e3021894 202 BLE_GATT_UNIT_VELOCITY_KILOMETRE_PER_HOUR = 0x27A6, /**< Velocity, kilometre per hour. */
elessair 0:f269e3021894 203 BLE_GATT_UNIT_VELOCITY_MILE_PER_HOUR = 0x27A7, /**< Velocity, mile per hour. */
elessair 0:f269e3021894 204 BLE_GATT_UNIT_ANGULAR_VELOCITY_REVOLUTION_PER_MINUTE = 0x27A8, /**< Angular Velocity, revolution per minute. */
elessair 0:f269e3021894 205 BLE_GATT_UNIT_ENERGY_GRAM_CALORIE = 0x27A9, /**< Energy, gram calorie. */
elessair 0:f269e3021894 206 BLE_GATT_UNIT_ENERGY_KILOGRAM_CALORIE = 0x27AA, /**< Energy, kilogram calorie. */
elessair 0:f269e3021894 207 BLE_GATT_UNIT_ENERGY_KILOWATT_HOUR = 0x27AB, /**< Energy, killowatt hour. */
elessair 0:f269e3021894 208 BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_FAHRENHEIT = 0x27AC, /**< */
elessair 0:f269e3021894 209 BLE_GATT_UNIT_PERCENTAGE = 0x27AD, /**< Percentage. */
elessair 0:f269e3021894 210 BLE_GATT_UNIT_PER_MILLE = 0x27AE, /**< */
elessair 0:f269e3021894 211 BLE_GATT_UNIT_PERIOD_BEATS_PER_MINUTE = 0x27AF, /**< */
elessair 0:f269e3021894 212 BLE_GATT_UNIT_ELECTRIC_CHARGE_AMPERE_HOURS = 0x27B0, /**< */
elessair 0:f269e3021894 213 BLE_GATT_UNIT_MASS_DENSITY_MILLIGRAM_PER_DECILITRE = 0x27B1, /**< */
elessair 0:f269e3021894 214 BLE_GATT_UNIT_MASS_DENSITY_MILLIMOLE_PER_LITRE = 0x27B2, /**< */
elessair 0:f269e3021894 215 BLE_GATT_UNIT_TIME_YEAR = 0x27B3, /**< Time, year. */
elessair 0:f269e3021894 216 BLE_GATT_UNIT_TIME_MONTH = 0x27B4, /**< Time, month. */
elessair 0:f269e3021894 217 BLE_GATT_UNIT_CONCENTRATION_COUNT_PER_CUBIC_METRE = 0x27B5, /**< */
elessair 0:f269e3021894 218 BLE_GATT_UNIT_IRRADIANCE_WATT_PER_SQUARE_METRE = 0x27B6 /**< */
elessair 0:f269e3021894 219 };
elessair 0:f269e3021894 220
elessair 0:f269e3021894 221 /**
elessair 0:f269e3021894 222 * @brief Standard GATT number types.
elessair 0:f269e3021894 223 *
elessair 0:f269e3021894 224 * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5.2.
elessair 0:f269e3021894 225 *
elessair 0:f269e3021894 226 * @note See http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
elessair 0:f269e3021894 227 */
elessair 0:f269e3021894 228 enum {
elessair 0:f269e3021894 229 BLE_GATT_FORMAT_RFU = 0x00, /**< Reserved for future use. */
elessair 0:f269e3021894 230 BLE_GATT_FORMAT_BOOLEAN = 0x01, /**< Boolean. */
elessair 0:f269e3021894 231 BLE_GATT_FORMAT_2BIT = 0x02, /**< Unsigned 2-bit integer. */
elessair 0:f269e3021894 232 BLE_GATT_FORMAT_NIBBLE = 0x03, /**< Unsigned 4-bit integer. */
elessair 0:f269e3021894 233 BLE_GATT_FORMAT_UINT8 = 0x04, /**< Unsigned 8-bit integer. */
elessair 0:f269e3021894 234 BLE_GATT_FORMAT_UINT12 = 0x05, /**< Unsigned 12-bit integer. */
elessair 0:f269e3021894 235 BLE_GATT_FORMAT_UINT16 = 0x06, /**< Unsigned 16-bit integer. */
elessair 0:f269e3021894 236 BLE_GATT_FORMAT_UINT24 = 0x07, /**< Unsigned 24-bit integer. */
elessair 0:f269e3021894 237 BLE_GATT_FORMAT_UINT32 = 0x08, /**< Unsigned 32-bit integer. */
elessair 0:f269e3021894 238 BLE_GATT_FORMAT_UINT48 = 0x09, /**< Unsigned 48-bit integer. */
elessair 0:f269e3021894 239 BLE_GATT_FORMAT_UINT64 = 0x0A, /**< Unsigned 64-bit integer. */
elessair 0:f269e3021894 240 BLE_GATT_FORMAT_UINT128 = 0x0B, /**< Unsigned 128-bit integer. */
elessair 0:f269e3021894 241 BLE_GATT_FORMAT_SINT8 = 0x0C, /**< Signed 2-bit integer. */
elessair 0:f269e3021894 242 BLE_GATT_FORMAT_SINT12 = 0x0D, /**< Signed 12-bit integer. */
elessair 0:f269e3021894 243 BLE_GATT_FORMAT_SINT16 = 0x0E, /**< Signed 16-bit integer. */
elessair 0:f269e3021894 244 BLE_GATT_FORMAT_SINT24 = 0x0F, /**< Signed 24-bit integer. */
elessair 0:f269e3021894 245 BLE_GATT_FORMAT_SINT32 = 0x10, /**< Signed 32-bit integer. */
elessair 0:f269e3021894 246 BLE_GATT_FORMAT_SINT48 = 0x11, /**< Signed 48-bit integer. */
elessair 0:f269e3021894 247 BLE_GATT_FORMAT_SINT64 = 0x12, /**< Signed 64-bit integer. */
elessair 0:f269e3021894 248 BLE_GATT_FORMAT_SINT128 = 0x13, /**< Signed 128-bit integer. */
elessair 0:f269e3021894 249 BLE_GATT_FORMAT_FLOAT32 = 0x14, /**< IEEE-754 32-bit floating point. */
elessair 0:f269e3021894 250 BLE_GATT_FORMAT_FLOAT64 = 0x15, /**< IEEE-754 64-bit floating point. */
elessair 0:f269e3021894 251 BLE_GATT_FORMAT_SFLOAT = 0x16, /**< IEEE-11073 16-bit SFLOAT. */
elessair 0:f269e3021894 252 BLE_GATT_FORMAT_FLOAT = 0x17, /**< IEEE-11073 32-bit FLOAT. */
elessair 0:f269e3021894 253 BLE_GATT_FORMAT_DUINT16 = 0x18, /**< IEEE-20601 format. */
elessair 0:f269e3021894 254 BLE_GATT_FORMAT_UTF8S = 0x19, /**< UTF-8 string. */
elessair 0:f269e3021894 255 BLE_GATT_FORMAT_UTF16S = 0x1A, /**< UTF-16 string. */
elessair 0:f269e3021894 256 BLE_GATT_FORMAT_STRUCT = 0x1B /**< Opaque Structure. */
elessair 0:f269e3021894 257 };
elessair 0:f269e3021894 258
elessair 0:f269e3021894 259 /*!
elessair 0:f269e3021894 260 * @brief Standard GATT characteristic properties.
elessair 0:f269e3021894 261 *
elessair 0:f269e3021894 262 * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.1.1
elessair 0:f269e3021894 263 * and Section 3.3.3.1 for Extended Properties.
elessair 0:f269e3021894 264 */
elessair 0:f269e3021894 265 enum Properties_t {
elessair 0:f269e3021894 266 BLE_GATT_CHAR_PROPERTIES_NONE = 0x00,
elessair 0:f269e3021894 267 BLE_GATT_CHAR_PROPERTIES_BROADCAST = 0x01, /**< Permits broadcasts of the characteristic value using the Server Characteristic Configuration descriptor. */
elessair 0:f269e3021894 268 BLE_GATT_CHAR_PROPERTIES_READ = 0x02, /**< Permits reads of the characteristic value. */
elessair 0:f269e3021894 269 BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE = 0x04, /**< Permits writes of the characteristic value without response. */
elessair 0:f269e3021894 270 BLE_GATT_CHAR_PROPERTIES_WRITE = 0x08, /**< Permits writes of the characteristic value with response. */
elessair 0:f269e3021894 271 BLE_GATT_CHAR_PROPERTIES_NOTIFY = 0x10, /**< Permits notifications of a characteristic value without acknowledgment. */
elessair 0:f269e3021894 272 BLE_GATT_CHAR_PROPERTIES_INDICATE = 0x20, /**< Permits indications of a characteristic value with acknowledgment. */
elessair 0:f269e3021894 273 BLE_GATT_CHAR_PROPERTIES_AUTHENTICATED_SIGNED_WRITES = 0x40, /**< Permits signed writes to the characteristic value. */
elessair 0:f269e3021894 274 BLE_GATT_CHAR_PROPERTIES_EXTENDED_PROPERTIES = 0x80 /**< Additional characteristic properties are defined in the Characteristic Extended Properties descriptor */
elessair 0:f269e3021894 275 };
elessair 0:f269e3021894 276
elessair 0:f269e3021894 277 /**
elessair 0:f269e3021894 278 * @brief GATT presentation format wrapper.
elessair 0:f269e3021894 279 *
elessair 0:f269e3021894 280 * @note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5.
elessair 0:f269e3021894 281 *
elessair 0:f269e3021894 282 * @note See https://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
elessair 0:f269e3021894 283 */
elessair 0:f269e3021894 284 struct PresentationFormat_t {
elessair 0:f269e3021894 285 uint8_t gatt_format; /**< Format of the value. */
elessair 0:f269e3021894 286 int8_t exponent; /**< Exponent for integer data types. Example: if Exponent = -3 and the char value is 3892, the actual value is 3.892 */
elessair 0:f269e3021894 287 uint16_t gatt_unit; /**< UUID from Bluetooth Assigned Numbers. */
elessair 0:f269e3021894 288 uint8_t gatt_namespace; /**< Namespace from Bluetooth Assigned Numbers, normally '1'. */
elessair 0:f269e3021894 289 uint16_t gatt_nsdesc; /**< Namespace description from Bluetooth Assigned Numbers, normally '0'. */
elessair 0:f269e3021894 290 };
elessair 0:f269e3021894 291
elessair 0:f269e3021894 292 /**
elessair 0:f269e3021894 293 * @brief Creates a new GattCharacteristic using the specified 16-bit
elessair 0:f269e3021894 294 * UUID, value length, and properties.
elessair 0:f269e3021894 295 *
elessair 0:f269e3021894 296 * @param[in] uuid
elessair 0:f269e3021894 297 * The UUID to use for this characteristic.
elessair 0:f269e3021894 298 * @param[in] valuePtr
elessair 0:f269e3021894 299 * The memory holding the initial value. The value is copied
elessair 0:f269e3021894 300 * into the stack when the enclosing service is added, and
elessair 0:f269e3021894 301 * is thereafter maintained internally by the stack.
elessair 0:f269e3021894 302 * @param[in] len
elessair 0:f269e3021894 303 * The length in bytes of this characteristic's value.
elessair 0:f269e3021894 304 * @param[in] maxLen
elessair 0:f269e3021894 305 * The max length in bytes of this characteristic's value.
elessair 0:f269e3021894 306 * @param[in] props
elessair 0:f269e3021894 307 * The 8-bit field containing the characteristic's properties.
elessair 0:f269e3021894 308 * @param[in] descriptors
elessair 0:f269e3021894 309 * A pointer to an array of descriptors to be included within
elessair 0:f269e3021894 310 * this characteristic. The memory for the descriptor array is
elessair 0:f269e3021894 311 * owned by the caller, and should remain valid at least until
elessair 0:f269e3021894 312 * the enclosing service is added to the GATT table.
elessair 0:f269e3021894 313 * @param[in] numDescriptors
elessair 0:f269e3021894 314 * The number of descriptors in the previous array.
elessair 0:f269e3021894 315 * @param[in] hasVariableLen
elessair 0:f269e3021894 316 * Whether the attribute's value length changes over time.
elessair 0:f269e3021894 317 *
elessair 0:f269e3021894 318 * @note The UUID value must be unique in the service and is normally >1.
elessair 0:f269e3021894 319 *
elessair 0:f269e3021894 320 * @note If valuePtr == NULL, length == 0, and properties == READ
elessair 0:f269e3021894 321 * for the value attribute of a characteristic, then that particular
elessair 0:f269e3021894 322 * characteristic may be considered optional and dropped while
elessair 0:f269e3021894 323 * instantiating the service with the underlying BLE stack.
elessair 0:f269e3021894 324 */
elessair 0:f269e3021894 325 GattCharacteristic(const UUID &uuid,
elessair 0:f269e3021894 326 uint8_t *valuePtr = NULL,
elessair 0:f269e3021894 327 uint16_t len = 0,
elessair 0:f269e3021894 328 uint16_t maxLen = 0,
elessair 0:f269e3021894 329 uint8_t props = BLE_GATT_CHAR_PROPERTIES_NONE,
elessair 0:f269e3021894 330 GattAttribute *descriptors[] = NULL,
elessair 0:f269e3021894 331 unsigned numDescriptors = 0,
elessair 0:f269e3021894 332 bool hasVariableLen = true) :
elessair 0:f269e3021894 333 _valueAttribute(uuid, valuePtr, len, maxLen, hasVariableLen),
elessair 0:f269e3021894 334 _properties(props),
elessair 0:f269e3021894 335 _requiredSecurity(SecurityManager::SECURITY_MODE_ENCRYPTION_OPEN_LINK),
elessair 0:f269e3021894 336 _descriptors(descriptors),
elessair 0:f269e3021894 337 _descriptorCount(numDescriptors),
elessair 0:f269e3021894 338 enabledReadAuthorization(false),
elessair 0:f269e3021894 339 enabledWriteAuthorization(false),
elessair 0:f269e3021894 340 readAuthorizationCallback(),
elessair 0:f269e3021894 341 writeAuthorizationCallback() {
elessair 0:f269e3021894 342 /* empty */
elessair 0:f269e3021894 343 }
elessair 0:f269e3021894 344
elessair 0:f269e3021894 345 public:
elessair 0:f269e3021894 346 /**
elessair 0:f269e3021894 347 * Set up the minimum security (mode and level) requirements for access to
elessair 0:f269e3021894 348 * the characteristic's value attribute.
elessair 0:f269e3021894 349 *
elessair 0:f269e3021894 350 * @param[in] securityMode
elessair 0:f269e3021894 351 * Can be one of encryption or signing, with or without
elessair 0:f269e3021894 352 * protection for man in the middle attacks (MITM).
elessair 0:f269e3021894 353 */
elessair 0:f269e3021894 354 void requireSecurity(SecurityManager::SecurityMode_t securityMode) {
elessair 0:f269e3021894 355 _requiredSecurity = securityMode;
elessair 0:f269e3021894 356 }
elessair 0:f269e3021894 357
elessair 0:f269e3021894 358 public:
elessair 0:f269e3021894 359 /**
elessair 0:f269e3021894 360 * Set up callback that will be triggered before the GATT Client is allowed
elessair 0:f269e3021894 361 * to write this characteristic. The handler will determine the
elessair 0:f269e3021894 362 * authorization reply for the write.
elessair 0:f269e3021894 363 *
elessair 0:f269e3021894 364 * @param[in] callback
elessair 0:f269e3021894 365 * Event handler being registered.
elessair 0:f269e3021894 366 */
elessair 0:f269e3021894 367 void setWriteAuthorizationCallback(void (*callback)(GattWriteAuthCallbackParams *)) {
elessair 0:f269e3021894 368 writeAuthorizationCallback.attach(callback);
elessair 0:f269e3021894 369 enabledWriteAuthorization = true;
elessair 0:f269e3021894 370 }
elessair 0:f269e3021894 371
elessair 0:f269e3021894 372 /**
elessair 0:f269e3021894 373 * Same as GattCharacrteristic::setWriteAuthorizationCallback(), but allows
elessair 0:f269e3021894 374 * the possibility to add an object reference and member function as
elessair 0:f269e3021894 375 * handler for connection event callbacks.
elessair 0:f269e3021894 376 *
elessair 0:f269e3021894 377 * @param[in] object
elessair 0:f269e3021894 378 * Pointer to the object of a class defining the member callback
elessair 0:f269e3021894 379 * function (@p member).
elessair 0:f269e3021894 380 * @param[in] member
elessair 0:f269e3021894 381 * The member callback (within the context of an object) to be
elessair 0:f269e3021894 382 * invoked.
elessair 0:f269e3021894 383 */
elessair 0:f269e3021894 384 template <typename T>
elessair 0:f269e3021894 385 void setWriteAuthorizationCallback(T *object, void (T::*member)(GattWriteAuthCallbackParams *)) {
elessair 0:f269e3021894 386 writeAuthorizationCallback.attach(object, member);
elessair 0:f269e3021894 387 enabledWriteAuthorization = true;
elessair 0:f269e3021894 388 }
elessair 0:f269e3021894 389
elessair 0:f269e3021894 390 /**
elessair 0:f269e3021894 391 * Set up callback that will be triggered before the GATT Client is allowed
elessair 0:f269e3021894 392 * to read this characteristic. The handler will determine the
elessair 0:f269e3021894 393 * authorizaion reply for the read.
elessair 0:f269e3021894 394 *
elessair 0:f269e3021894 395 * @param[in] callback
elessair 0:f269e3021894 396 * Event handler being registered.
elessair 0:f269e3021894 397 */
elessair 0:f269e3021894 398 void setReadAuthorizationCallback(void (*callback)(GattReadAuthCallbackParams *)) {
elessair 0:f269e3021894 399 readAuthorizationCallback.attach(callback);
elessair 0:f269e3021894 400 enabledReadAuthorization = true;
elessair 0:f269e3021894 401 }
elessair 0:f269e3021894 402
elessair 0:f269e3021894 403 /**
elessair 0:f269e3021894 404 * Same as GattCharacrteristic::setReadAuthorizationCallback(), but allows
elessair 0:f269e3021894 405 * the possibility to add an object reference and member function as
elessair 0:f269e3021894 406 * handler for connection event callbacks.
elessair 0:f269e3021894 407 *
elessair 0:f269e3021894 408 * @param[in] object
elessair 0:f269e3021894 409 * Pointer to the object of a class defining the member callback
elessair 0:f269e3021894 410 * function (@p member).
elessair 0:f269e3021894 411 * @param[in] member
elessair 0:f269e3021894 412 * The member callback (within the context of an object) to be
elessair 0:f269e3021894 413 * invoked.
elessair 0:f269e3021894 414 */
elessair 0:f269e3021894 415 template <typename T>
elessair 0:f269e3021894 416 void setReadAuthorizationCallback(T *object, void (T::*member)(GattReadAuthCallbackParams *)) {
elessair 0:f269e3021894 417 readAuthorizationCallback.attach(object, member);
elessair 0:f269e3021894 418 enabledReadAuthorization = true;
elessair 0:f269e3021894 419 }
elessair 0:f269e3021894 420
elessair 0:f269e3021894 421 /**
elessair 0:f269e3021894 422 * Helper that calls the registered handler to determine the authorization
elessair 0:f269e3021894 423 * reply for a write request. This function is meant to be called from the
elessair 0:f269e3021894 424 * BLE stack specific implementation.
elessair 0:f269e3021894 425 *
elessair 0:f269e3021894 426 * @param[in] params
elessair 0:f269e3021894 427 * To capture the context of the write-auth request. Also
elessair 0:f269e3021894 428 * contains an out-parameter for reply.
elessair 0:f269e3021894 429 *
elessair 0:f269e3021894 430 * @return A GattAuthCallbackReply_t value indicating whether authorization
elessair 0:f269e3021894 431 * is granted.
elessair 0:f269e3021894 432 */
elessair 0:f269e3021894 433 GattAuthCallbackReply_t authorizeWrite(GattWriteAuthCallbackParams *params) {
elessair 0:f269e3021894 434 if (!isWriteAuthorizationEnabled()) {
elessair 0:f269e3021894 435 return AUTH_CALLBACK_REPLY_SUCCESS;
elessair 0:f269e3021894 436 }
elessair 0:f269e3021894 437
elessair 0:f269e3021894 438 params->authorizationReply = AUTH_CALLBACK_REPLY_SUCCESS; /* Initialized to no-error by default. */
elessair 0:f269e3021894 439 writeAuthorizationCallback.call(params);
elessair 0:f269e3021894 440 return params->authorizationReply;
elessair 0:f269e3021894 441 }
elessair 0:f269e3021894 442
elessair 0:f269e3021894 443 /**
elessair 0:f269e3021894 444 * Helper that calls the registered handler to determine the authorization
elessair 0:f269e3021894 445 * reply for a read request. This function is meant to be called from the
elessair 0:f269e3021894 446 * BLE stack specific implementation.
elessair 0:f269e3021894 447 *
elessair 0:f269e3021894 448 * @param[in] params
elessair 0:f269e3021894 449 * To capture the context of the read-auth request.
elessair 0:f269e3021894 450 *
elessair 0:f269e3021894 451 * @return A GattAuthCallbackReply_t value indicating whether authorization
elessair 0:f269e3021894 452 * is granted.
elessair 0:f269e3021894 453 *
elessair 0:f269e3021894 454 * @note To authorize or deny the read the params->authorizationReply field
elessair 0:f269e3021894 455 * should be set to true (authorize) or false (deny).
elessair 0:f269e3021894 456 *
elessair 0:f269e3021894 457 * @note If the read is approved and params->data is unchanged (NULL),
elessair 0:f269e3021894 458 * the current characteristic value will be used.
elessair 0:f269e3021894 459 *
elessair 0:f269e3021894 460 * @note If the read is approved, a new value can be provided by setting
elessair 0:f269e3021894 461 * the params->data pointer and params->len fields.
elessair 0:f269e3021894 462 */
elessair 0:f269e3021894 463 GattAuthCallbackReply_t authorizeRead(GattReadAuthCallbackParams *params) {
elessair 0:f269e3021894 464 if (!isReadAuthorizationEnabled()) {
elessair 0:f269e3021894 465 return AUTH_CALLBACK_REPLY_SUCCESS;
elessair 0:f269e3021894 466 }
elessair 0:f269e3021894 467
elessair 0:f269e3021894 468 params->authorizationReply = AUTH_CALLBACK_REPLY_SUCCESS; /* Initialized to no-error by default. */
elessair 0:f269e3021894 469 readAuthorizationCallback.call(params);
elessair 0:f269e3021894 470 return params->authorizationReply;
elessair 0:f269e3021894 471 }
elessair 0:f269e3021894 472
elessair 0:f269e3021894 473 public:
elessair 0:f269e3021894 474 /**
elessair 0:f269e3021894 475 * Get the characteristic's value attribute.
elessair 0:f269e3021894 476 *
elessair 0:f269e3021894 477 * @return A reference to the characteristic's value attribute.
elessair 0:f269e3021894 478 */
elessair 0:f269e3021894 479 GattAttribute& getValueAttribute() {
elessair 0:f269e3021894 480 return _valueAttribute;
elessair 0:f269e3021894 481 }
elessair 0:f269e3021894 482
elessair 0:f269e3021894 483 /**
elessair 0:f269e3021894 484 * A const alternative to GattCharacteristic::getValueAttribute().
elessair 0:f269e3021894 485 *
elessair 0:f269e3021894 486 * @return A const reference to the characteristic's value attribute.
elessair 0:f269e3021894 487 */
elessair 0:f269e3021894 488 const GattAttribute& getValueAttribute() const {
elessair 0:f269e3021894 489 return _valueAttribute;
elessair 0:f269e3021894 490 }
elessair 0:f269e3021894 491
elessair 0:f269e3021894 492 /**
elessair 0:f269e3021894 493 * Get the characteristic's value attribute handle in the ATT table.
elessair 0:f269e3021894 494 *
elessair 0:f269e3021894 495 * @return The value attribute handle.
elessair 0:f269e3021894 496 *
elessair 0:f269e3021894 497 * @note The attribute handle is typically assigned by the underlying BLE
elessair 0:f269e3021894 498 * stack.
elessair 0:f269e3021894 499 */
elessair 0:f269e3021894 500 GattAttribute::Handle_t getValueHandle(void) const {
elessair 0:f269e3021894 501 return getValueAttribute().getHandle();
elessair 0:f269e3021894 502 }
elessair 0:f269e3021894 503
elessair 0:f269e3021894 504 /**
elessair 0:f269e3021894 505 * Get the characteristic's propertied. Refer to
elessair 0:f269e3021894 506 * GattCharacteristic::Properties_t.
elessair 0:f269e3021894 507 *
elessair 0:f269e3021894 508 * @return The characteristic's properties.
elessair 0:f269e3021894 509 */
elessair 0:f269e3021894 510 uint8_t getProperties(void) const {
elessair 0:f269e3021894 511 return _properties;
elessair 0:f269e3021894 512 }
elessair 0:f269e3021894 513
elessair 0:f269e3021894 514 /**
elessair 0:f269e3021894 515 * Get the characteristic's required security.
elessair 0:f269e3021894 516 *
elessair 0:f269e3021894 517 * @return The characteristic's required security.
elessair 0:f269e3021894 518 */
elessair 0:f269e3021894 519 SecurityManager::SecurityMode_t getRequiredSecurity() const {
elessair 0:f269e3021894 520 return _requiredSecurity;
elessair 0:f269e3021894 521 }
elessair 0:f269e3021894 522
elessair 0:f269e3021894 523 /**
elessair 0:f269e3021894 524 * Get the total number of descriptors within this characteristic.
elessair 0:f269e3021894 525 *
elessair 0:f269e3021894 526 * @return The total number of descriptors.
elessair 0:f269e3021894 527 */
elessair 0:f269e3021894 528 uint8_t getDescriptorCount(void) const {
elessair 0:f269e3021894 529 return _descriptorCount;
elessair 0:f269e3021894 530 }
elessair 0:f269e3021894 531
elessair 0:f269e3021894 532 /**
elessair 0:f269e3021894 533 * Check whether read authorization is enabled i.e. check whether a
elessair 0:f269e3021894 534 * read authorization callback was previously registered. Refer to
elessair 0:f269e3021894 535 * GattCharacteristic::setReadAuthorizationCallback().
elessair 0:f269e3021894 536 *
elessair 0:f269e3021894 537 * @return true if read authorization is enabled, false otherwise.
elessair 0:f269e3021894 538 */
elessair 0:f269e3021894 539 bool isReadAuthorizationEnabled() const {
elessair 0:f269e3021894 540 return enabledReadAuthorization;
elessair 0:f269e3021894 541 }
elessair 0:f269e3021894 542
elessair 0:f269e3021894 543 /**
elessair 0:f269e3021894 544 * Check whether write authorization is enabled i.e. check whether a
elessair 0:f269e3021894 545 * write authorization callback was previously registered. Refer to
elessair 0:f269e3021894 546 * GattCharacteristic::setReadAuthorizationCallback().
elessair 0:f269e3021894 547 *
elessair 0:f269e3021894 548 * @return true if write authorization is enabled, false otherwise.
elessair 0:f269e3021894 549 */
elessair 0:f269e3021894 550 bool isWriteAuthorizationEnabled() const {
elessair 0:f269e3021894 551 return enabledWriteAuthorization;
elessair 0:f269e3021894 552 }
elessair 0:f269e3021894 553
elessair 0:f269e3021894 554 /**
elessair 0:f269e3021894 555 * Get this characteristic's descriptor at a specific index.
elessair 0:f269e3021894 556 *
elessair 0:f269e3021894 557 * @param[in] index
elessair 0:f269e3021894 558 * The descriptor's index.
elessair 0:f269e3021894 559 *
elessair 0:f269e3021894 560 * @return A pointer the requested descriptor if @p index contains a valid
elessair 0:f269e3021894 561 * descriptor, or NULL otherwise.
elessair 0:f269e3021894 562 */
elessair 0:f269e3021894 563 GattAttribute *getDescriptor(uint8_t index) {
elessair 0:f269e3021894 564 if (index >= _descriptorCount) {
elessair 0:f269e3021894 565 return NULL;
elessair 0:f269e3021894 566 }
elessair 0:f269e3021894 567
elessair 0:f269e3021894 568 return _descriptors[index];
elessair 0:f269e3021894 569 }
elessair 0:f269e3021894 570
elessair 0:f269e3021894 571 private:
elessair 0:f269e3021894 572 /**
elessair 0:f269e3021894 573 * Attribute that contains the actual value of this characteristic.
elessair 0:f269e3021894 574 */
elessair 0:f269e3021894 575 GattAttribute _valueAttribute;
elessair 0:f269e3021894 576 /**
elessair 0:f269e3021894 577 * The characteristic's properties. Refer to
elessair 0:f269e3021894 578 * GattCharacteristic::Properties_t.
elessair 0:f269e3021894 579 */
elessair 0:f269e3021894 580 uint8_t _properties;
elessair 0:f269e3021894 581 /**
elessair 0:f269e3021894 582 * The characteristic's required security.
elessair 0:f269e3021894 583 */
elessair 0:f269e3021894 584 SecurityManager::SecurityMode_t _requiredSecurity;
elessair 0:f269e3021894 585 /**
elessair 0:f269e3021894 586 * The characteristic's descriptor attributes.
elessair 0:f269e3021894 587 */
elessair 0:f269e3021894 588 GattAttribute **_descriptors;
elessair 0:f269e3021894 589 /**
elessair 0:f269e3021894 590 * The number of descriptors in this characteristic.
elessair 0:f269e3021894 591 */
elessair 0:f269e3021894 592 uint8_t _descriptorCount;
elessair 0:f269e3021894 593
elessair 0:f269e3021894 594 /**
elessair 0:f269e3021894 595 * Whether read authorization is enabled i.e. whether there is a registered
elessair 0:f269e3021894 596 * callback to determine read authorization reply.
elessair 0:f269e3021894 597 */
elessair 0:f269e3021894 598 bool enabledReadAuthorization;
elessair 0:f269e3021894 599 /**
elessair 0:f269e3021894 600 * Whether write authorization is enabled i.e. whether there is a registered
elessair 0:f269e3021894 601 * callback to determine write authorization reply.
elessair 0:f269e3021894 602 */
elessair 0:f269e3021894 603 bool enabledWriteAuthorization;
elessair 0:f269e3021894 604 /**
elessair 0:f269e3021894 605 * The registered callback handler for read authorization reply.
elessair 0:f269e3021894 606 */
elessair 0:f269e3021894 607 FunctionPointerWithContext<GattReadAuthCallbackParams *> readAuthorizationCallback;
elessair 0:f269e3021894 608 /**
elessair 0:f269e3021894 609 * The registered callback handler for write authorization reply.
elessair 0:f269e3021894 610 */
elessair 0:f269e3021894 611 FunctionPointerWithContext<GattWriteAuthCallbackParams *> writeAuthorizationCallback;
elessair 0:f269e3021894 612
elessair 0:f269e3021894 613 private:
elessair 0:f269e3021894 614 /* Disallow copy and assignment. */
elessair 0:f269e3021894 615 GattCharacteristic(const GattCharacteristic &);
elessair 0:f269e3021894 616 GattCharacteristic& operator=(const GattCharacteristic &);
elessair 0:f269e3021894 617 };
elessair 0:f269e3021894 618
elessair 0:f269e3021894 619 /**
elessair 0:f269e3021894 620 * Helper class to construct a read-only GattCharacteristic.
elessair 0:f269e3021894 621 */
elessair 0:f269e3021894 622 template <typename T>
elessair 0:f269e3021894 623 class ReadOnlyGattCharacteristic : public GattCharacteristic {
elessair 0:f269e3021894 624 public:
elessair 0:f269e3021894 625 /**
elessair 0:f269e3021894 626 * Construct a ReadOnlyGattCharacteristic.
elessair 0:f269e3021894 627 *
elessair 0:f269e3021894 628 * @param[in] uuid
elessair 0:f269e3021894 629 * The characteristic's UUID.
elessair 0:f269e3021894 630 * @param[in] valuePtr
elessair 0:f269e3021894 631 * Pointer to the characterisitic's initial value.
elessair 0:f269e3021894 632 * @param[in] additionalProperties
elessair 0:f269e3021894 633 * Additional characterisitic properties. By default, the
elessair 0:f269e3021894 634 * properties are set to
elessair 0:f269e3021894 635 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
elessair 0:f269e3021894 636 * @param[in] descriptors
elessair 0:f269e3021894 637 * An array of pointers to descriptors to be added to the new
elessair 0:f269e3021894 638 * characteristic.
elessair 0:f269e3021894 639 * @param[in] numDescriptors
elessair 0:f269e3021894 640 * The total number of descriptors in @p descriptors.
elessair 0:f269e3021894 641 *
elessair 0:f269e3021894 642 * @note Instances of ReadOnlyGattCharacteristic have a fixed length
elessair 0:f269e3021894 643 * attribute value that equals sizeof(T). For a variable length
elessair 0:f269e3021894 644 * alternative use GattCharacteristic directly.
elessair 0:f269e3021894 645 */
elessair 0:f269e3021894 646 ReadOnlyGattCharacteristic<T>(const UUID &uuid,
elessair 0:f269e3021894 647 T *valuePtr,
elessair 0:f269e3021894 648 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
elessair 0:f269e3021894 649 GattAttribute *descriptors[] = NULL,
elessair 0:f269e3021894 650 unsigned numDescriptors = 0) :
elessair 0:f269e3021894 651 GattCharacteristic(uuid, reinterpret_cast<uint8_t *>(valuePtr), sizeof(T), sizeof(T),
elessair 0:f269e3021894 652 BLE_GATT_CHAR_PROPERTIES_READ | additionalProperties, descriptors, numDescriptors, false) {
elessair 0:f269e3021894 653 /* empty */
elessair 0:f269e3021894 654 }
elessair 0:f269e3021894 655 };
elessair 0:f269e3021894 656
elessair 0:f269e3021894 657 /**
elessair 0:f269e3021894 658 * Helper class to construct a write-only GattCharacteristic.
elessair 0:f269e3021894 659 */
elessair 0:f269e3021894 660 template <typename T>
elessair 0:f269e3021894 661 class WriteOnlyGattCharacteristic : public GattCharacteristic {
elessair 0:f269e3021894 662 public:
elessair 0:f269e3021894 663 /**
elessair 0:f269e3021894 664 * Construct a WriteOnlyGattCharacteristic.
elessair 0:f269e3021894 665 *
elessair 0:f269e3021894 666 * @param[in] uuid
elessair 0:f269e3021894 667 * The characteristic's UUID.
elessair 0:f269e3021894 668 * @param[in] valuePtr
elessair 0:f269e3021894 669 * Pointer to the characterisitic's initial value.
elessair 0:f269e3021894 670 * @param[in] additionalProperties
elessair 0:f269e3021894 671 * Additional characterisitic properties. By default, the
elessair 0:f269e3021894 672 * properties are set to
elessair 0:f269e3021894 673 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE.
elessair 0:f269e3021894 674 * @param[in] descriptors
elessair 0:f269e3021894 675 * An array of pointers to descriptors to be added to the new
elessair 0:f269e3021894 676 * characteristic.
elessair 0:f269e3021894 677 * @param[in] numDescriptors
elessair 0:f269e3021894 678 * The total number of descriptors in @p descriptors.
elessair 0:f269e3021894 679 *
elessair 0:f269e3021894 680 * @note Instances of WriteOnlyGattCharacteristic have variable length
elessair 0:f269e3021894 681 * attribute value with maximum size equal to sizeof(T). For a fixed length
elessair 0:f269e3021894 682 * alternative use GattCharacteristic directly.
elessair 0:f269e3021894 683 */
elessair 0:f269e3021894 684 WriteOnlyGattCharacteristic<T>(const UUID &uuid,
elessair 0:f269e3021894 685 T *valuePtr,
elessair 0:f269e3021894 686 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
elessair 0:f269e3021894 687 GattAttribute *descriptors[] = NULL,
elessair 0:f269e3021894 688 unsigned numDescriptors = 0) :
elessair 0:f269e3021894 689 GattCharacteristic(uuid, reinterpret_cast<uint8_t *>(valuePtr), sizeof(T), sizeof(T),
elessair 0:f269e3021894 690 BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties, descriptors, numDescriptors) {
elessair 0:f269e3021894 691 /* empty */
elessair 0:f269e3021894 692 }
elessair 0:f269e3021894 693 };
elessair 0:f269e3021894 694
elessair 0:f269e3021894 695 /**
elessair 0:f269e3021894 696 * Helper class to construct a readable and writable GattCharacteristic.
elessair 0:f269e3021894 697 */
elessair 0:f269e3021894 698 template <typename T>
elessair 0:f269e3021894 699 class ReadWriteGattCharacteristic : public GattCharacteristic {
elessair 0:f269e3021894 700 public:
elessair 0:f269e3021894 701 /**
elessair 0:f269e3021894 702 * Construct a ReadWriteGattCharacteristic.
elessair 0:f269e3021894 703 *
elessair 0:f269e3021894 704 * @param[in] uuid
elessair 0:f269e3021894 705 * The characteristic's UUID.
elessair 0:f269e3021894 706 * @param[in] valuePtr
elessair 0:f269e3021894 707 * Pointer to the characterisitic's initial value.
elessair 0:f269e3021894 708 * @param[in] additionalProperties
elessair 0:f269e3021894 709 * Additional characterisitic properties. By default, the
elessair 0:f269e3021894 710 * properties are set to
elessair 0:f269e3021894 711 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE |
elessair 0:f269e3021894 712 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
elessair 0:f269e3021894 713 * @param[in] descriptors
elessair 0:f269e3021894 714 * An array of pointers to descriptors to be added to the new
elessair 0:f269e3021894 715 * characteristic.
elessair 0:f269e3021894 716 * @param[in] numDescriptors
elessair 0:f269e3021894 717 * The total number of descriptors in @p descriptors.
elessair 0:f269e3021894 718 *
elessair 0:f269e3021894 719 * @note Instances of ReadWriteGattCharacteristic have variable length
elessair 0:f269e3021894 720 * attribute value with maximum size equal to sizeof(T). For a fixed length
elessair 0:f269e3021894 721 * alternative use GattCharacteristic directly.
elessair 0:f269e3021894 722 */
elessair 0:f269e3021894 723 ReadWriteGattCharacteristic<T>(const UUID &uuid,
elessair 0:f269e3021894 724 T *valuePtr,
elessair 0:f269e3021894 725 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
elessair 0:f269e3021894 726 GattAttribute *descriptors[] = NULL,
elessair 0:f269e3021894 727 unsigned numDescriptors = 0) :
elessair 0:f269e3021894 728 GattCharacteristic(uuid, reinterpret_cast<uint8_t *>(valuePtr), sizeof(T), sizeof(T),
elessair 0:f269e3021894 729 BLE_GATT_CHAR_PROPERTIES_READ | BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties, descriptors, numDescriptors) {
elessair 0:f269e3021894 730 /* empty */
elessair 0:f269e3021894 731 }
elessair 0:f269e3021894 732 };
elessair 0:f269e3021894 733
elessair 0:f269e3021894 734 /**
elessair 0:f269e3021894 735 * Helper class to construct a write-only GattCharacteristic with an array
elessair 0:f269e3021894 736 * value.
elessair 0:f269e3021894 737 */
elessair 0:f269e3021894 738 template <typename T, unsigned NUM_ELEMENTS>
elessair 0:f269e3021894 739 class WriteOnlyArrayGattCharacteristic : public GattCharacteristic {
elessair 0:f269e3021894 740 public:
elessair 0:f269e3021894 741 /**
elessair 0:f269e3021894 742 * Construct a WriteOnlyGattCharacteristic.
elessair 0:f269e3021894 743 *
elessair 0:f269e3021894 744 * @param[in] uuid
elessair 0:f269e3021894 745 * The characteristic's UUID.
elessair 0:f269e3021894 746 * @param[in] valuePtr
elessair 0:f269e3021894 747 * Pointer to an array of length NUM_ELEMENTS containing the
elessair 0:f269e3021894 748 * characteristic's intitial value.
elessair 0:f269e3021894 749 * @param[in] additionalProperties
elessair 0:f269e3021894 750 * Additional characterisitic properties. By default, the
elessair 0:f269e3021894 751 * properties are set to
elessair 0:f269e3021894 752 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE.
elessair 0:f269e3021894 753 * @param[in] descriptors
elessair 0:f269e3021894 754 * An array of pointers to descriptors to be added to the new
elessair 0:f269e3021894 755 * characteristic.
elessair 0:f269e3021894 756 * @param[in] numDescriptors
elessair 0:f269e3021894 757 * The total number of descriptors in @p descriptors.
elessair 0:f269e3021894 758 *
elessair 0:f269e3021894 759 * @note Instances of WriteOnlyGattCharacteristic have variable length
elessair 0:f269e3021894 760 * attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
elessair 0:f269e3021894 761 * For a fixed length alternative use GattCharacteristic directly.
elessair 0:f269e3021894 762 */
elessair 0:f269e3021894 763 WriteOnlyArrayGattCharacteristic<T, NUM_ELEMENTS>(const UUID &uuid,
elessair 0:f269e3021894 764 T valuePtr[NUM_ELEMENTS],
elessair 0:f269e3021894 765 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
elessair 0:f269e3021894 766 GattAttribute *descriptors[] = NULL,
elessair 0:f269e3021894 767 unsigned numDescriptors = 0) :
elessair 0:f269e3021894 768 GattCharacteristic(uuid, reinterpret_cast<uint8_t *>(valuePtr), sizeof(T) * NUM_ELEMENTS, sizeof(T) * NUM_ELEMENTS,
elessair 0:f269e3021894 769 BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties, descriptors, numDescriptors) {
elessair 0:f269e3021894 770 /* empty */
elessair 0:f269e3021894 771 }
elessair 0:f269e3021894 772 };
elessair 0:f269e3021894 773
elessair 0:f269e3021894 774 /**
elessair 0:f269e3021894 775 * Helper class to construct a read-only GattCharacteristic with an array
elessair 0:f269e3021894 776 * value.
elessair 0:f269e3021894 777 */
elessair 0:f269e3021894 778 template <typename T, unsigned NUM_ELEMENTS>
elessair 0:f269e3021894 779 class ReadOnlyArrayGattCharacteristic : public GattCharacteristic {
elessair 0:f269e3021894 780 public:
elessair 0:f269e3021894 781 /**
elessair 0:f269e3021894 782 * Construct a ReadOnlyGattCharacteristic.
elessair 0:f269e3021894 783 *
elessair 0:f269e3021894 784 * @param[in] uuid
elessair 0:f269e3021894 785 * The characteristic's UUID.
elessair 0:f269e3021894 786 * @param[in] valuePtr
elessair 0:f269e3021894 787 * Pointer to an array of length NUM_ELEMENTS containing the
elessair 0:f269e3021894 788 * characteristic's intitial value.
elessair 0:f269e3021894 789 * @param[in] additionalProperties
elessair 0:f269e3021894 790 * Additional characterisitic properties. By default, the
elessair 0:f269e3021894 791 * properties are set to
elessair 0:f269e3021894 792 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
elessair 0:f269e3021894 793 * @param[in] descriptors
elessair 0:f269e3021894 794 * An array of pointers to descriptors to be added to the new
elessair 0:f269e3021894 795 * characteristic.
elessair 0:f269e3021894 796 * @param[in] numDescriptors
elessair 0:f269e3021894 797 * The total number of descriptors in @p descriptors.
elessair 0:f269e3021894 798 *
elessair 0:f269e3021894 799 * @note Instances of ReadOnlyGattCharacteristic have fixed length
elessair 0:f269e3021894 800 * attribute value that equals sizeof(T) * NUM_ELEMENTS.
elessair 0:f269e3021894 801 * For a variable length alternative use GattCharacteristic directly.
elessair 0:f269e3021894 802 */
elessair 0:f269e3021894 803 ReadOnlyArrayGattCharacteristic<T, NUM_ELEMENTS>(const UUID &uuid,
elessair 0:f269e3021894 804 T valuePtr[NUM_ELEMENTS],
elessair 0:f269e3021894 805 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
elessair 0:f269e3021894 806 GattAttribute *descriptors[] = NULL,
elessair 0:f269e3021894 807 unsigned numDescriptors = 0) :
elessair 0:f269e3021894 808 GattCharacteristic(uuid, reinterpret_cast<uint8_t *>(valuePtr), sizeof(T) * NUM_ELEMENTS, sizeof(T) * NUM_ELEMENTS,
elessair 0:f269e3021894 809 BLE_GATT_CHAR_PROPERTIES_READ | additionalProperties, descriptors, numDescriptors, false) {
elessair 0:f269e3021894 810 /* empty */
elessair 0:f269e3021894 811 }
elessair 0:f269e3021894 812 };
elessair 0:f269e3021894 813
elessair 0:f269e3021894 814 /**
elessair 0:f269e3021894 815 * Helper class to construct a readable and writable GattCharacteristic with an array
elessair 0:f269e3021894 816 * value.
elessair 0:f269e3021894 817 */
elessair 0:f269e3021894 818 template <typename T, unsigned NUM_ELEMENTS>
elessair 0:f269e3021894 819 class ReadWriteArrayGattCharacteristic : public GattCharacteristic {
elessair 0:f269e3021894 820 public:
elessair 0:f269e3021894 821 /**
elessair 0:f269e3021894 822 * Construct a ReadWriteGattCharacteristic.
elessair 0:f269e3021894 823 *
elessair 0:f269e3021894 824 * @param[in] uuid
elessair 0:f269e3021894 825 * The characteristic's UUID.
elessair 0:f269e3021894 826 * @param[in] valuePtr
elessair 0:f269e3021894 827 * Pointer to an array of length NUM_ELEMENTS containing the
elessair 0:f269e3021894 828 * characteristic's intitial value.
elessair 0:f269e3021894 829 * @param[in] additionalProperties
elessair 0:f269e3021894 830 * Additional characterisitic properties. By default, the
elessair 0:f269e3021894 831 * properties are set to
elessair 0:f269e3021894 832 * Properties_t::BLE_GATT_CHAR_PROPERTIES_WRITE |
elessair 0:f269e3021894 833 * Properties_t::BLE_GATT_CHAR_PROPERTIES_READ.
elessair 0:f269e3021894 834 * @param[in] descriptors
elessair 0:f269e3021894 835 * An array of pointers to descriptors to be added to the new
elessair 0:f269e3021894 836 * characteristic.
elessair 0:f269e3021894 837 * @param[in] numDescriptors
elessair 0:f269e3021894 838 * The total number of descriptors in @p descriptors.
elessair 0:f269e3021894 839 *
elessair 0:f269e3021894 840 * @note Instances of ReadWriteGattCharacteristic have variable length
elessair 0:f269e3021894 841 * attribute value with maximum size equal to sizeof(T) * NUM_ELEMENTS.
elessair 0:f269e3021894 842 * For a fixed length alternative use GattCharacteristic directly.
elessair 0:f269e3021894 843 */
elessair 0:f269e3021894 844 ReadWriteArrayGattCharacteristic<T, NUM_ELEMENTS>(const UUID &uuid,
elessair 0:f269e3021894 845 T valuePtr[NUM_ELEMENTS],
elessair 0:f269e3021894 846 uint8_t additionalProperties = BLE_GATT_CHAR_PROPERTIES_NONE,
elessair 0:f269e3021894 847 GattAttribute *descriptors[] = NULL,
elessair 0:f269e3021894 848 unsigned numDescriptors = 0) :
elessair 0:f269e3021894 849 GattCharacteristic(uuid, reinterpret_cast<uint8_t *>(valuePtr), sizeof(T) * NUM_ELEMENTS, sizeof(T) * NUM_ELEMENTS,
elessair 0:f269e3021894 850 BLE_GATT_CHAR_PROPERTIES_READ | BLE_GATT_CHAR_PROPERTIES_WRITE | additionalProperties, descriptors, numDescriptors) {
elessair 0:f269e3021894 851 /* empty */
elessair 0:f269e3021894 852 }
elessair 0:f269e3021894 853 };
elessair 0:f269e3021894 854
elessair 0:f269e3021894 855 #endif /* ifndef __GATT_CHARACTERISTIC_H__ */