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