Bluetooth LE library for Nucleo board

Dependents:   Nucleo_BLE_HeartRate Nucleo_BLE_UART Nucleo_BLE_Demo Nucleo_BLE_UART

Warning: Deprecated!

Supported drivers and applications can be found at this link.

Committer:
sjallouli
Date:
Fri Dec 19 19:52:49 2014 +0000
Revision:
1:79e5c08cbcc7
Parent:
0:289fd2dae405
change the USARTService->write() method access permission to public

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sjallouli 0:289fd2dae405 1 /* mbed Microcontroller Library
sjallouli 0:289fd2dae405 2 * Copyright (c) 2006-2013 ARM Limited
sjallouli 0:289fd2dae405 3 *
sjallouli 0:289fd2dae405 4 * Licensed under the Apache License, Version 2.0 (the "License");
sjallouli 0:289fd2dae405 5 * you may not use this file except in compliance with the License.
sjallouli 0:289fd2dae405 6 * You may obtain a copy of the License at
sjallouli 0:289fd2dae405 7 *
sjallouli 0:289fd2dae405 8 * http://www.apache.org/licenses/LICENSE-2.0
sjallouli 0:289fd2dae405 9 *
sjallouli 0:289fd2dae405 10 * Unless required by applicable law or agreed to in writing, software
sjallouli 0:289fd2dae405 11 * distributed under the License is distributed on an "AS IS" BASIS,
sjallouli 0:289fd2dae405 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sjallouli 0:289fd2dae405 13 * See the License for the specific language governing permissions and
sjallouli 0:289fd2dae405 14 * limitations under the License.
sjallouli 0:289fd2dae405 15 */
sjallouli 0:289fd2dae405 16
sjallouli 0:289fd2dae405 17
sjallouli 0:289fd2dae405 18 #ifndef __GATT_CHARACTERISTIC_H__
sjallouli 0:289fd2dae405 19 #define __GATT_CHARACTERISTIC_H__
sjallouli 0:289fd2dae405 20
sjallouli 0:289fd2dae405 21 #include "blecommon.h"
sjallouli 0:289fd2dae405 22 #include "UUID.h"
sjallouli 0:289fd2dae405 23 #include "GattAttribute.h"
sjallouli 0:289fd2dae405 24
sjallouli 0:289fd2dae405 25 /**************************************************************************/
sjallouli 0:289fd2dae405 26 /*!
sjallouli 0:289fd2dae405 27 \brief GATT characteristic
sjallouli 0:289fd2dae405 28 */
sjallouli 0:289fd2dae405 29 /**************************************************************************/
sjallouli 0:289fd2dae405 30 class GattCharacteristic
sjallouli 0:289fd2dae405 31 {
sjallouli 0:289fd2dae405 32 public:
sjallouli 0:289fd2dae405 33 enum {
sjallouli 0:289fd2dae405 34 UUID_BATTERY_LEVEL_STATE_CHAR = 0x2A1B,
sjallouli 0:289fd2dae405 35 UUID_BATTERY_POWER_STATE_CHAR = 0x2A1A,
sjallouli 0:289fd2dae405 36 UUID_REMOVABLE_CHAR = 0x2A3A,
sjallouli 0:289fd2dae405 37 UUID_SERVICE_REQUIRED_CHAR = 0x2A3B,
sjallouli 0:289fd2dae405 38 UUID_ALERT_CATEGORY_ID_CHAR = 0x2A43,
sjallouli 0:289fd2dae405 39 UUID_ALERT_CATEGORY_ID_BIT_MASK_CHAR = 0x2A42,
sjallouli 0:289fd2dae405 40 UUID_ALERT_LEVEL_CHAR = 0x2A06,
sjallouli 0:289fd2dae405 41 UUID_ALERT_NOTIFICATION_CONTROL_POINT_CHAR = 0x2A44,
sjallouli 0:289fd2dae405 42 UUID_ALERT_STATUS_CHAR = 0x2A3F,
sjallouli 0:289fd2dae405 43 UUID_BATTERY_LEVEL_CHAR = 0x2A19,
sjallouli 0:289fd2dae405 44 UUID_BLOOD_PRESSURE_FEATURE_CHAR = 0x2A49,
sjallouli 0:289fd2dae405 45 UUID_BLOOD_PRESSURE_MEASUREMENT_CHAR = 0x2A35,
sjallouli 0:289fd2dae405 46 UUID_BODY_SENSOR_LOCATION_CHAR = 0x2A38,
sjallouli 0:289fd2dae405 47 UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR = 0x2A22,
sjallouli 0:289fd2dae405 48 UUID_BOOT_KEYBOARD_OUTPUT_REPORT_CHAR = 0x2A32,
sjallouli 0:289fd2dae405 49 UUID_BOOT_MOUSE_INPUT_REPORT_CHAR = 0x2A33,
sjallouli 0:289fd2dae405 50 UUID_CURRENT_TIME_CHAR = 0x2A2B,
sjallouli 0:289fd2dae405 51 UUID_DATE_TIME_CHAR = 0x2A08,
sjallouli 0:289fd2dae405 52 UUID_DAY_DATE_TIME_CHAR = 0x2A0A,
sjallouli 0:289fd2dae405 53 UUID_DAY_OF_WEEK_CHAR = 0x2A09,
sjallouli 0:289fd2dae405 54 UUID_DST_OFFSET_CHAR = 0x2A0D,
sjallouli 0:289fd2dae405 55 UUID_EXACT_TIME_256_CHAR = 0x2A0C,
sjallouli 0:289fd2dae405 56 UUID_FIRMWARE_REVISION_STRING_CHAR = 0x2A26,
sjallouli 0:289fd2dae405 57 UUID_GLUCOSE_FEATURE_CHAR = 0x2A51,
sjallouli 0:289fd2dae405 58 UUID_GLUCOSE_MEASUREMENT_CHAR = 0x2A18,
sjallouli 0:289fd2dae405 59 UUID_GLUCOSE_MEASUREMENT_CONTEXT_CHAR = 0x2A34,
sjallouli 0:289fd2dae405 60 UUID_HARDWARE_REVISION_STRING_CHAR = 0x2A27,
sjallouli 0:289fd2dae405 61 UUID_HEART_RATE_CONTROL_POINT_CHAR = 0x2A39,
sjallouli 0:289fd2dae405 62 UUID_HEART_RATE_MEASUREMENT_CHAR = 0x2A37,
sjallouli 0:289fd2dae405 63 UUID_HID_CONTROL_POINT_CHAR = 0x2A4C,
sjallouli 0:289fd2dae405 64 UUID_HID_INFORMATION_CHAR = 0x2A4A,
sjallouli 0:289fd2dae405 65 UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR = 0x2A2A,
sjallouli 0:289fd2dae405 66 UUID_INTERMEDIATE_CUFF_PRESSURE_CHAR = 0x2A36,
sjallouli 0:289fd2dae405 67 UUID_INTERMEDIATE_TEMPERATURE_CHAR = 0x2A1E,
sjallouli 0:289fd2dae405 68 UUID_LOCAL_TIME_INFORMATION_CHAR = 0x2A0F,
sjallouli 0:289fd2dae405 69 UUID_MANUFACTURER_NAME_STRING_CHAR = 0x2A29,
sjallouli 0:289fd2dae405 70 UUID_MEASUREMENT_INTERVAL_CHAR = 0x2A21,
sjallouli 0:289fd2dae405 71 UUID_MODEL_NUMBER_STRING_CHAR = 0x2A24,
sjallouli 0:289fd2dae405 72 UUID_UNREAD_ALERT_CHAR = 0x2A45,
sjallouli 0:289fd2dae405 73 UUID_NEW_ALERT_CHAR = 0x2A46,
sjallouli 0:289fd2dae405 74 UUID_PNP_ID_CHAR = 0x2A50,
sjallouli 0:289fd2dae405 75 UUID_PROTOCOL_MODE_CHAR = 0x2A4E,
sjallouli 0:289fd2dae405 76 UUID_RECORD_ACCESS_CONTROL_POINT_CHAR = 0x2A52,
sjallouli 0:289fd2dae405 77 UUID_REFERENCE_TIME_INFORMATION_CHAR = 0x2A14,
sjallouli 0:289fd2dae405 78 UUID_REPORT_CHAR = 0x2A4D,
sjallouli 0:289fd2dae405 79 UUID_REPORT_MAP_CHAR = 0x2A4B,
sjallouli 0:289fd2dae405 80 UUID_RINGER_CONTROL_POINT_CHAR = 0x2A40,
sjallouli 0:289fd2dae405 81 UUID_RINGER_SETTING_CHAR = 0x2A41,
sjallouli 0:289fd2dae405 82 UUID_SCAN_INTERVAL_WINDOW_CHAR = 0x2A4F,
sjallouli 0:289fd2dae405 83 UUID_SCAN_REFRESH_CHAR = 0x2A31,
sjallouli 0:289fd2dae405 84 UUID_SERIAL_NUMBER_STRING_CHAR = 0x2A25,
sjallouli 0:289fd2dae405 85 UUID_SOFTWARE_REVISION_STRING_CHAR = 0x2A28,
sjallouli 0:289fd2dae405 86 UUID_SUPPORTED_NEW_ALERT_CATEGORY_CHAR = 0x2A47,
sjallouli 0:289fd2dae405 87 UUID_SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR = 0x2A48,
sjallouli 0:289fd2dae405 88 UUID_SYSTEM_ID_CHAR = 0x2A23,
sjallouli 0:289fd2dae405 89 UUID_TEMPERATURE_MEASUREMENT_CHAR = 0x2A1C,
sjallouli 0:289fd2dae405 90 UUID_TEMPERATURE_TYPE_CHAR = 0x2A1D,
sjallouli 0:289fd2dae405 91 UUID_TIME_ACCURACY_CHAR = 0x2A12,
sjallouli 0:289fd2dae405 92 UUID_TIME_SOURCE_CHAR = 0x2A13,
sjallouli 0:289fd2dae405 93 UUID_TIME_UPDATE_CONTROL_POINT_CHAR = 0x2A16,
sjallouli 0:289fd2dae405 94 UUID_TIME_UPDATE_STATE_CHAR = 0x2A17,
sjallouli 0:289fd2dae405 95 UUID_TIME_WITH_DST_CHAR = 0x2A11,
sjallouli 0:289fd2dae405 96 UUID_TIME_ZONE_CHAR = 0x2A0E,
sjallouli 0:289fd2dae405 97 UUID_TX_POWER_LEVEL_CHAR = 0x2A07,
sjallouli 0:289fd2dae405 98 UUID_CSC_FEATURE_CHAR = 0x2A5C,
sjallouli 0:289fd2dae405 99 UUID_CSC_MEASUREMENT_CHAR = 0x2A5B,
sjallouli 0:289fd2dae405 100 UUID_RSC_FEATURE_CHAR = 0x2A54,
sjallouli 0:289fd2dae405 101 UUID_RSC_MEASUREMENT_CHAR = 0x2A53,
sjallouli 0:289fd2dae405 102 };
sjallouli 0:289fd2dae405 103
sjallouli 0:289fd2dae405 104 /**************************************************************************/
sjallouli 0:289fd2dae405 105 /*!
sjallouli 0:289fd2dae405 106 \brief Standard GATT characteristic presentation format unit types.
sjallouli 0:289fd2dae405 107 These unit types are used to decribe what the raw numeric
sjallouli 0:289fd2dae405 108 data in a characteristic actually represents.
sjallouli 0:289fd2dae405 109
sjallouli 0:289fd2dae405 110 \note See https://developer.bluetooth.org/gatt/units/Pages/default.aspx
sjallouli 0:289fd2dae405 111 */
sjallouli 0:289fd2dae405 112 /**************************************************************************/
sjallouli 0:289fd2dae405 113 typedef enum ble_gatt_unit_e {
sjallouli 0:289fd2dae405 114 BLE_GATT_UNIT_NONE = 0x2700, /**< No specified unit type */
sjallouli 0:289fd2dae405 115 BLE_GATT_UNIT_LENGTH_METRE = 0x2701, /**< Length, Metre */
sjallouli 0:289fd2dae405 116 BLE_GATT_UNIT_MASS_KILOGRAM = 0x2702, /**< Mass, Kilogram */
sjallouli 0:289fd2dae405 117 BLE_GATT_UNIT_TIME_SECOND = 0x2703, /**< Time, Second */
sjallouli 0:289fd2dae405 118 BLE_GATT_UNIT_ELECTRIC_CURRENT_AMPERE = 0x2704, /**< Electric Current, Ampere */
sjallouli 0:289fd2dae405 119 BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_KELVIN = 0x2705, /**< Thermodynamic Temperature, Kelvin */
sjallouli 0:289fd2dae405 120 BLE_GATT_UNIT_AMOUNT_OF_SUBSTANCE_MOLE = 0x2706, /**< Amount of Substance, Mole */
sjallouli 0:289fd2dae405 121 BLE_GATT_UNIT_LUMINOUS_INTENSITY_CANDELA = 0x2707, /**< Luminous Intensity, Candela */
sjallouli 0:289fd2dae405 122 BLE_GATT_UNIT_AREA_SQUARE_METRES = 0x2710, /**< Area, Square Metres */
sjallouli 0:289fd2dae405 123 BLE_GATT_UNIT_VOLUME_CUBIC_METRES = 0x2711, /**< Volume, Cubic Metres*/
sjallouli 0:289fd2dae405 124 BLE_GATT_UNIT_VELOCITY_METRES_PER_SECOND = 0x2712, /**< Velocity, Metres per Second*/
sjallouli 0:289fd2dae405 125 BLE_GATT_UNIT_ACCELERATION_METRES_PER_SECOND_SQUARED = 0x2713, /**< Acceleration, Metres per Second Squared */
sjallouli 0:289fd2dae405 126 BLE_GATT_UNIT_WAVENUMBER_RECIPROCAL_METRE = 0x2714, /**< Wave Number Reciprocal, Metre */
sjallouli 0:289fd2dae405 127 BLE_GATT_UNIT_DENSITY_KILOGRAM_PER_CUBIC_METRE = 0x2715, /**< Density, Kilogram per Cubic Metre */
sjallouli 0:289fd2dae405 128 BLE_GATT_UNIT_SURFACE_DENSITY_KILOGRAM_PER_SQUARE_METRE = 0x2716, /**< */
sjallouli 0:289fd2dae405 129 BLE_GATT_UNIT_SPECIFIC_VOLUME_CUBIC_METRE_PER_KILOGRAM = 0x2717, /**< */
sjallouli 0:289fd2dae405 130 BLE_GATT_UNIT_CURRENT_DENSITY_AMPERE_PER_SQUARE_METRE = 0x2718, /**< */
sjallouli 0:289fd2dae405 131 BLE_GATT_UNIT_MAGNETIC_FIELD_STRENGTH_AMPERE_PER_METRE = 0x2719, /**< Magnetic Field Strength, Ampere per Metre */
sjallouli 0:289fd2dae405 132 BLE_GATT_UNIT_AMOUNT_CONCENTRATION_MOLE_PER_CUBIC_METRE = 0x271A, /**< */
sjallouli 0:289fd2dae405 133 BLE_GATT_UNIT_MASS_CONCENTRATION_KILOGRAM_PER_CUBIC_METRE = 0x271B, /**< */
sjallouli 0:289fd2dae405 134 BLE_GATT_UNIT_LUMINANCE_CANDELA_PER_SQUARE_METRE = 0x271C, /**< */
sjallouli 0:289fd2dae405 135 BLE_GATT_UNIT_REFRACTIVE_INDEX = 0x271D, /**< */
sjallouli 0:289fd2dae405 136 BLE_GATT_UNIT_RELATIVE_PERMEABILITY = 0x271E, /**< */
sjallouli 0:289fd2dae405 137 BLE_GATT_UNIT_PLANE_ANGLE_RADIAN = 0x2720, /**< */
sjallouli 0:289fd2dae405 138 BLE_GATT_UNIT_SOLID_ANGLE_STERADIAN = 0x2721, /**< */
sjallouli 0:289fd2dae405 139 BLE_GATT_UNIT_FREQUENCY_HERTZ = 0x2722, /**< Frequency, Hertz */
sjallouli 0:289fd2dae405 140 BLE_GATT_UNIT_FORCE_NEWTON = 0x2723, /**< Force, Newton */
sjallouli 0:289fd2dae405 141 BLE_GATT_UNIT_PRESSURE_PASCAL = 0x2724, /**< Pressure, Pascal */
sjallouli 0:289fd2dae405 142 BLE_GATT_UNIT_ENERGY_JOULE = 0x2725, /**< Energy, Joule */
sjallouli 0:289fd2dae405 143 BLE_GATT_UNIT_POWER_WATT = 0x2726, /**< Power, Watt */
sjallouli 0:289fd2dae405 144 BLE_GATT_UNIT_ELECTRIC_CHARGE_COULOMB = 0x2727, /**< Electrical Charge, Coulomb */
sjallouli 0:289fd2dae405 145 BLE_GATT_UNIT_ELECTRIC_POTENTIAL_DIFFERENCE_VOLT = 0x2728, /**< Electrical Potential Difference, Voltage */
sjallouli 0:289fd2dae405 146 BLE_GATT_UNIT_CAPACITANCE_FARAD = 0x2729, /**< */
sjallouli 0:289fd2dae405 147 BLE_GATT_UNIT_ELECTRIC_RESISTANCE_OHM = 0x272A, /**< */
sjallouli 0:289fd2dae405 148 BLE_GATT_UNIT_ELECTRIC_CONDUCTANCE_SIEMENS = 0x272B, /**< */
sjallouli 0:289fd2dae405 149 BLE_GATT_UNIT_MAGNETIC_FLEX_WEBER = 0x272C, /**< */
sjallouli 0:289fd2dae405 150 BLE_GATT_UNIT_MAGNETIC_FLEX_DENSITY_TESLA = 0x272D, /**< */
sjallouli 0:289fd2dae405 151 BLE_GATT_UNIT_INDUCTANCE_HENRY = 0x272E, /**< */
sjallouli 0:289fd2dae405 152 BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_CELSIUS = 0x272F, /**< */
sjallouli 0:289fd2dae405 153 BLE_GATT_UNIT_LUMINOUS_FLUX_LUMEN = 0x2730, /**< */
sjallouli 0:289fd2dae405 154 BLE_GATT_UNIT_ILLUMINANCE_LUX = 0x2731, /**< */
sjallouli 0:289fd2dae405 155 BLE_GATT_UNIT_ACTIVITY_REFERRED_TO_A_RADIONUCLIDE_BECQUEREL = 0x2732, /**< */
sjallouli 0:289fd2dae405 156 BLE_GATT_UNIT_ABSORBED_DOSE_GRAY = 0x2733, /**< */
sjallouli 0:289fd2dae405 157 BLE_GATT_UNIT_DOSE_EQUIVALENT_SIEVERT = 0x2734, /**< */
sjallouli 0:289fd2dae405 158 BLE_GATT_UNIT_CATALYTIC_ACTIVITY_KATAL = 0x2735, /**< */
sjallouli 0:289fd2dae405 159 BLE_GATT_UNIT_DYNAMIC_VISCOSITY_PASCAL_SECOND = 0x2740, /**< */
sjallouli 0:289fd2dae405 160 BLE_GATT_UNIT_MOMENT_OF_FORCE_NEWTON_METRE = 0x2741, /**< */
sjallouli 0:289fd2dae405 161 BLE_GATT_UNIT_SURFACE_TENSION_NEWTON_PER_METRE = 0x2742, /**< */
sjallouli 0:289fd2dae405 162 BLE_GATT_UNIT_ANGULAR_VELOCITY_RADIAN_PER_SECOND = 0x2743, /**< */
sjallouli 0:289fd2dae405 163 BLE_GATT_UNIT_ANGULAR_ACCELERATION_RADIAN_PER_SECOND_SQUARED = 0x2744, /**< */
sjallouli 0:289fd2dae405 164 BLE_GATT_UNIT_HEAT_FLUX_DENSITY_WATT_PER_SQUARE_METRE = 0x2745, /**< */
sjallouli 0:289fd2dae405 165 BLE_GATT_UNIT_HEAT_CAPACITY_JOULE_PER_KELVIN = 0x2746, /**< */
sjallouli 0:289fd2dae405 166 BLE_GATT_UNIT_SPECIFIC_HEAT_CAPACITY_JOULE_PER_KILOGRAM_KELVIN = 0x2747, /**< */
sjallouli 0:289fd2dae405 167 BLE_GATT_UNIT_SPECIFIC_ENERGY_JOULE_PER_KILOGRAM = 0x2748, /**< */
sjallouli 0:289fd2dae405 168 BLE_GATT_UNIT_THERMAL_CONDUCTIVITY_WATT_PER_METRE_KELVIN = 0x2749, /**< */
sjallouli 0:289fd2dae405 169 BLE_GATT_UNIT_ENERGY_DENSITY_JOULE_PER_CUBIC_METRE = 0x274A, /**< */
sjallouli 0:289fd2dae405 170 BLE_GATT_UNIT_ELECTRIC_FIELD_STRENGTH_VOLT_PER_METRE = 0x274B, /**< */
sjallouli 0:289fd2dae405 171 BLE_GATT_UNIT_ELECTRIC_CHARGE_DENSITY_COULOMB_PER_CUBIC_METRE = 0x274C, /**< */
sjallouli 0:289fd2dae405 172 BLE_GATT_UNIT_SURFACE_CHARGE_DENSITY_COULOMB_PER_SQUARE_METRE = 0x274D, /**< */
sjallouli 0:289fd2dae405 173 BLE_GATT_UNIT_ELECTRIC_FLUX_DENSITY_COULOMB_PER_SQUARE_METRE = 0x274E, /**< */
sjallouli 0:289fd2dae405 174 BLE_GATT_UNIT_PERMITTIVITY_FARAD_PER_METRE = 0x274F, /**< */
sjallouli 0:289fd2dae405 175 BLE_GATT_UNIT_PERMEABILITY_HENRY_PER_METRE = 0x2750, /**< */
sjallouli 0:289fd2dae405 176 BLE_GATT_UNIT_MOLAR_ENERGY_JOULE_PER_MOLE = 0x2751, /**< */
sjallouli 0:289fd2dae405 177 BLE_GATT_UNIT_MOLAR_ENTROPY_JOULE_PER_MOLE_KELVIN = 0x2752, /**< */
sjallouli 0:289fd2dae405 178 BLE_GATT_UNIT_EXPOSURE_COULOMB_PER_KILOGRAM = 0x2753, /**< */
sjallouli 0:289fd2dae405 179 BLE_GATT_UNIT_ABSORBED_DOSE_RATE_GRAY_PER_SECOND = 0x2754, /**< */
sjallouli 0:289fd2dae405 180 BLE_GATT_UNIT_RADIANT_INTENSITY_WATT_PER_STERADIAN = 0x2755, /**< */
sjallouli 0:289fd2dae405 181 BLE_GATT_UNIT_RADIANCE_WATT_PER_SQUARE_METRE_STERADIAN = 0x2756, /**< */
sjallouli 0:289fd2dae405 182 BLE_GATT_UNIT_CATALYTIC_ACTIVITY_CONCENTRATION_KATAL_PER_CUBIC_METRE = 0x2757, /**< */
sjallouli 0:289fd2dae405 183 BLE_GATT_UNIT_TIME_MINUTE = 0x2760, /**< Time, Minute */
sjallouli 0:289fd2dae405 184 BLE_GATT_UNIT_TIME_HOUR = 0x2761, /**< Time, Hour */
sjallouli 0:289fd2dae405 185 BLE_GATT_UNIT_TIME_DAY = 0x2762, /**< Time, Day */
sjallouli 0:289fd2dae405 186 BLE_GATT_UNIT_PLANE_ANGLE_DEGREE = 0x2763, /**< */
sjallouli 0:289fd2dae405 187 BLE_GATT_UNIT_PLANE_ANGLE_MINUTE = 0x2764, /**< */
sjallouli 0:289fd2dae405 188 BLE_GATT_UNIT_PLANE_ANGLE_SECOND = 0x2765, /**< */
sjallouli 0:289fd2dae405 189 BLE_GATT_UNIT_AREA_HECTARE = 0x2766, /**< */
sjallouli 0:289fd2dae405 190 BLE_GATT_UNIT_VOLUME_LITRE = 0x2767, /**< */
sjallouli 0:289fd2dae405 191 BLE_GATT_UNIT_MASS_TONNE = 0x2768, /**< */
sjallouli 0:289fd2dae405 192 BLE_GATT_UNIT_PRESSURE_BAR = 0x2780, /**< Pressure, Bar */
sjallouli 0:289fd2dae405 193 BLE_GATT_UNIT_PRESSURE_MILLIMETRE_OF_MERCURY = 0x2781, /**< Pressure, Millimetre of Mercury */
sjallouli 0:289fd2dae405 194 BLE_GATT_UNIT_LENGTH_ANGSTROM = 0x2782, /**< */
sjallouli 0:289fd2dae405 195 BLE_GATT_UNIT_LENGTH_NAUTICAL_MILE = 0x2783, /**< */
sjallouli 0:289fd2dae405 196 BLE_GATT_UNIT_AREA_BARN = 0x2784, /**< */
sjallouli 0:289fd2dae405 197 BLE_GATT_UNIT_VELOCITY_KNOT = 0x2785, /**< */
sjallouli 0:289fd2dae405 198 BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_NEPER = 0x2786, /**< */
sjallouli 0:289fd2dae405 199 BLE_GATT_UNIT_LOGARITHMIC_RADIO_QUANTITY_BEL = 0x2787, /**< */
sjallouli 0:289fd2dae405 200 BLE_GATT_UNIT_LENGTH_YARD = 0x27A0, /**< Length, Yard */
sjallouli 0:289fd2dae405 201 BLE_GATT_UNIT_LENGTH_PARSEC = 0x27A1, /**< Length, Parsec */
sjallouli 0:289fd2dae405 202 BLE_GATT_UNIT_LENGTH_INCH = 0x27A2, /**< Length, Inch */
sjallouli 0:289fd2dae405 203 BLE_GATT_UNIT_LENGTH_FOOT = 0x27A3, /**< Length, Foot */
sjallouli 0:289fd2dae405 204 BLE_GATT_UNIT_LENGTH_MILE = 0x27A4, /**< Length, Mile */
sjallouli 0:289fd2dae405 205 BLE_GATT_UNIT_PRESSURE_POUND_FORCE_PER_SQUARE_INCH = 0x27A5, /**< */
sjallouli 0:289fd2dae405 206 BLE_GATT_UNIT_VELOCITY_KILOMETRE_PER_HOUR = 0x27A6, /**< Velocity, Kilometre per Hour */
sjallouli 0:289fd2dae405 207 BLE_GATT_UNIT_VELOCITY_MILE_PER_HOUR = 0x27A7, /**< Velocity, Mile per Hour */
sjallouli 0:289fd2dae405 208 BLE_GATT_UNIT_ANGULAR_VELOCITY_REVOLUTION_PER_MINUTE = 0x27A8, /**< Angular Velocity, Revolution per Minute */
sjallouli 0:289fd2dae405 209 BLE_GATT_UNIT_ENERGY_GRAM_CALORIE = 0x27A9, /**< Energy, Gram Calorie */
sjallouli 0:289fd2dae405 210 BLE_GATT_UNIT_ENERGY_KILOGRAM_CALORIE = 0x27AA, /**< Energy, Kilogram Calorie */
sjallouli 0:289fd2dae405 211 BLE_GATT_UNIT_ENERGY_KILOWATT_HOUR = 0x27AB, /**< Energy, Killowatt Hour */
sjallouli 0:289fd2dae405 212 BLE_GATT_UNIT_THERMODYNAMIC_TEMPERATURE_DEGREE_FAHRENHEIT = 0x27AC, /**< */
sjallouli 0:289fd2dae405 213 BLE_GATT_UNIT_PERCENTAGE = 0x27AD, /**< Percentage */
sjallouli 0:289fd2dae405 214 BLE_GATT_UNIT_PER_MILLE = 0x27AE, /**< */
sjallouli 0:289fd2dae405 215 BLE_GATT_UNIT_PERIOD_BEATS_PER_MINUTE = 0x27AF, /**< */
sjallouli 0:289fd2dae405 216 BLE_GATT_UNIT_ELECTRIC_CHARGE_AMPERE_HOURS = 0x27B0, /**< */
sjallouli 0:289fd2dae405 217 BLE_GATT_UNIT_MASS_DENSITY_MILLIGRAM_PER_DECILITRE = 0x27B1, /**< */
sjallouli 0:289fd2dae405 218 BLE_GATT_UNIT_MASS_DENSITY_MILLIMOLE_PER_LITRE = 0x27B2, /**< */
sjallouli 0:289fd2dae405 219 BLE_GATT_UNIT_TIME_YEAR = 0x27B3, /**< Time, Year */
sjallouli 0:289fd2dae405 220 BLE_GATT_UNIT_TIME_MONTH = 0x27B4, /**< Time, Month */
sjallouli 0:289fd2dae405 221 BLE_GATT_UNIT_CONCENTRATION_COUNT_PER_CUBIC_METRE = 0x27B5, /**< */
sjallouli 0:289fd2dae405 222 BLE_GATT_UNIT_IRRADIANCE_WATT_PER_SQUARE_METRE = 0x27B6 /**< */
sjallouli 0:289fd2dae405 223 } ble_gatt_unit_t;
sjallouli 0:289fd2dae405 224
sjallouli 0:289fd2dae405 225 /**************************************************************************/
sjallouli 0:289fd2dae405 226 /*!
sjallouli 0:289fd2dae405 227 \brief Standard GATT number types
sjallouli 0:289fd2dae405 228
sjallouli 0:289fd2dae405 229 \note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5.2
sjallouli 0:289fd2dae405 230 \note See http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
sjallouli 0:289fd2dae405 231 */
sjallouli 0:289fd2dae405 232 /**************************************************************************/
sjallouli 0:289fd2dae405 233 typedef enum ble_gatt_format_e {
sjallouli 0:289fd2dae405 234 BLE_GATT_FORMAT_RFU = 0x00, /**< Reserved For Future Use. */
sjallouli 0:289fd2dae405 235 BLE_GATT_FORMAT_BOOLEAN = 0x01, /**< Boolean. */
sjallouli 0:289fd2dae405 236 BLE_GATT_FORMAT_2BIT = 0x02, /**< Unsigned 2-bit integer. */
sjallouli 0:289fd2dae405 237 BLE_GATT_FORMAT_NIBBLE = 0x03, /**< Unsigned 4-bit integer. */
sjallouli 0:289fd2dae405 238 BLE_GATT_FORMAT_UINT8 = 0x04, /**< Unsigned 8-bit integer. */
sjallouli 0:289fd2dae405 239 BLE_GATT_FORMAT_UINT12 = 0x05, /**< Unsigned 12-bit integer. */
sjallouli 0:289fd2dae405 240 BLE_GATT_FORMAT_UINT16 = 0x06, /**< Unsigned 16-bit integer. */
sjallouli 0:289fd2dae405 241 BLE_GATT_FORMAT_UINT24 = 0x07, /**< Unsigned 24-bit integer. */
sjallouli 0:289fd2dae405 242 BLE_GATT_FORMAT_UINT32 = 0x08, /**< Unsigned 32-bit integer. */
sjallouli 0:289fd2dae405 243 BLE_GATT_FORMAT_UINT48 = 0x09, /**< Unsigned 48-bit integer. */
sjallouli 0:289fd2dae405 244 BLE_GATT_FORMAT_UINT64 = 0x0A, /**< Unsigned 64-bit integer. */
sjallouli 0:289fd2dae405 245 BLE_GATT_FORMAT_UINT128 = 0x0B, /**< Unsigned 128-bit integer. */
sjallouli 0:289fd2dae405 246 BLE_GATT_FORMAT_SINT8 = 0x0C, /**< Signed 2-bit integer. */
sjallouli 0:289fd2dae405 247 BLE_GATT_FORMAT_SINT12 = 0x0D, /**< Signed 12-bit integer. */
sjallouli 0:289fd2dae405 248 BLE_GATT_FORMAT_SINT16 = 0x0E, /**< Signed 16-bit integer. */
sjallouli 0:289fd2dae405 249 BLE_GATT_FORMAT_SINT24 = 0x0F, /**< Signed 24-bit integer. */
sjallouli 0:289fd2dae405 250 BLE_GATT_FORMAT_SINT32 = 0x10, /**< Signed 32-bit integer. */
sjallouli 0:289fd2dae405 251 BLE_GATT_FORMAT_SINT48 = 0x11, /**< Signed 48-bit integer. */
sjallouli 0:289fd2dae405 252 BLE_GATT_FORMAT_SINT64 = 0x12, /**< Signed 64-bit integer. */
sjallouli 0:289fd2dae405 253 BLE_GATT_FORMAT_SINT128 = 0x13, /**< Signed 128-bit integer. */
sjallouli 0:289fd2dae405 254 BLE_GATT_FORMAT_FLOAT32 = 0x14, /**< IEEE-754 32-bit floating point. */
sjallouli 0:289fd2dae405 255 BLE_GATT_FORMAT_FLOAT64 = 0x15, /**< IEEE-754 64-bit floating point. */
sjallouli 0:289fd2dae405 256 BLE_GATT_FORMAT_SFLOAT = 0x16, /**< IEEE-11073 16-bit SFLOAT. */
sjallouli 0:289fd2dae405 257 BLE_GATT_FORMAT_FLOAT = 0x17, /**< IEEE-11073 32-bit FLOAT. */
sjallouli 0:289fd2dae405 258 BLE_GATT_FORMAT_DUINT16 = 0x18, /**< IEEE-20601 format. */
sjallouli 0:289fd2dae405 259 BLE_GATT_FORMAT_UTF8S = 0x19, /**< UTF-8 string. */
sjallouli 0:289fd2dae405 260 BLE_GATT_FORMAT_UTF16S = 0x1A, /**< UTF-16 string. */
sjallouli 0:289fd2dae405 261 BLE_GATT_FORMAT_STRUCT = 0x1B /**< Opaque Structure. */
sjallouli 0:289fd2dae405 262 } ble_gatt_format_t;
sjallouli 0:289fd2dae405 263
sjallouli 0:289fd2dae405 264 /**************************************************************************/
sjallouli 0:289fd2dae405 265 /*!
sjallouli 0:289fd2dae405 266 \brief Standard GATT characteritic properties
sjallouli 0:289fd2dae405 267
sjallouli 0:289fd2dae405 268 \note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.1.1
sjallouli 0:289fd2dae405 269 and Section 3.3.3.1 for Extended Properties
sjallouli 0:289fd2dae405 270 */
sjallouli 0:289fd2dae405 271 /**************************************************************************/
sjallouli 0:289fd2dae405 272 typedef enum ble_gatt_char_properties_e {
sjallouli 0:289fd2dae405 273 BLE_GATT_CHAR_PROPERTIES_NONE = 0x00,
sjallouli 0:289fd2dae405 274 BLE_GATT_CHAR_PROPERTIES_BROADCAST = 0x01, /**< Permits broadcasts of the Characteristic Value using Server Characteristic Configuration Descriptor. */
sjallouli 0:289fd2dae405 275 BLE_GATT_CHAR_PROPERTIES_READ = 0x02, /**< Permits reads of the Characteristic Value. */
sjallouli 0:289fd2dae405 276 BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE = 0x04, /**< Permits writes of the Characteristic Value without response. */
sjallouli 0:289fd2dae405 277 BLE_GATT_CHAR_PROPERTIES_WRITE = 0x08, /**< Permits writes of the Characteristic Value with response. */
sjallouli 0:289fd2dae405 278 BLE_GATT_CHAR_PROPERTIES_NOTIFY = 0x10, /**< Permits notifications of a Characteristic Value without acknowledgement. */
sjallouli 0:289fd2dae405 279 BLE_GATT_CHAR_PROPERTIES_INDICATE = 0x20, /**< Permits indications of a Characteristic Value with acknowledgement. */
sjallouli 0:289fd2dae405 280 BLE_GATT_CHAR_PROPERTIES_AUTHENTICATED_SIGNED_WRITES = 0x40, /**< Permits signed writes to the Characteristic Value. */
sjallouli 0:289fd2dae405 281 BLE_GATT_CHAR_PROPERTIES_EXTENDED_PROPERTIES = 0x80 /**< Additional characteristic properties are defined in the Characteristic Extended Properties Descriptor */
sjallouli 0:289fd2dae405 282 } ble_gatt_char_properties_t;
sjallouli 0:289fd2dae405 283
sjallouli 0:289fd2dae405 284 /**************************************************************************/
sjallouli 0:289fd2dae405 285 /*!
sjallouli 0:289fd2dae405 286 \brief GATT presentation format wrapper
sjallouli 0:289fd2dae405 287
sjallouli 0:289fd2dae405 288 \note See Bluetooth Specification 4.0 (Vol. 3), Part G, Section 3.3.3.5
sjallouli 0:289fd2dae405 289 \note See https://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
sjallouli 0:289fd2dae405 290 */
sjallouli 0:289fd2dae405 291 /**************************************************************************/
sjallouli 0:289fd2dae405 292 typedef struct PresentationFormat {
sjallouli 0:289fd2dae405 293 uint8_t gatt_format; /**< Format of the value, see @ref ble_gatt_format_t. */
sjallouli 0:289fd2dae405 294 int8_t exponent; /**< Exponent for integer data types. Ex. if Exponent = -3 and the char value is 3892, the actual value is 3.892 */
sjallouli 0:289fd2dae405 295 uint16_t gatt_unit; /**< UUID from Bluetooth Assigned Numbers, see @ref ble_gatt_unit_t. */
sjallouli 0:289fd2dae405 296 uint8_t gatt_namespace; /**< Namespace from Bluetooth Assigned Numbers, normally '1', see @ref BLE_GATT_CPF_NAMESPACES. */
sjallouli 0:289fd2dae405 297 uint16_t gatt_nsdesc; /**< Namespace description from Bluetooth Assigned Numbers, normally '0', see @ref BLE_GATT_CPF_NAMESPACES. */
sjallouli 0:289fd2dae405 298 } presentation_format_t;
sjallouli 0:289fd2dae405 299
sjallouli 0:289fd2dae405 300 /**
sjallouli 0:289fd2dae405 301 * @brief Creates a new GattCharacteristic using the specified 16-bit
sjallouli 0:289fd2dae405 302 * UUID, value length, and properties
sjallouli 0:289fd2dae405 303 *
sjallouli 0:289fd2dae405 304 * @note The UUID value must be unique in the service and is normally >1
sjallouli 0:289fd2dae405 305 *
sjallouli 0:289fd2dae405 306 * @param[in] uuid
sjallouli 0:289fd2dae405 307 * The UUID to use for this characteristic
sjallouli 0:289fd2dae405 308 * @param[in] valuePtr
sjallouli 0:289fd2dae405 309 * The memory holding the initial value. The value is copied
sjallouli 0:289fd2dae405 310 * into the stack when the enclosing service is added; and
sjallouli 0:289fd2dae405 311 * thereafter maintained internally by the stack.
sjallouli 0:289fd2dae405 312 * @param[in] initialLen
sjallouli 0:289fd2dae405 313 * The min length in bytes of this characteristic's value
sjallouli 0:289fd2dae405 314 * @param[in] maxLen
sjallouli 0:289fd2dae405 315 * The max length in bytes of this characteristic's value
sjallouli 0:289fd2dae405 316 * @param[in] props
sjallouli 0:289fd2dae405 317 * The 8-bit bit field containing the characteristic's properties
sjallouli 0:289fd2dae405 318 * @param[in] descriptors
sjallouli 0:289fd2dae405 319 * A pointer to an array of descriptors to be included within this characteristic
sjallouli 0:289fd2dae405 320 * @param[in] numDescriptors
sjallouli 0:289fd2dae405 321 * The number of descriptors
sjallouli 0:289fd2dae405 322 *
sjallouli 0:289fd2dae405 323 * @NOTE: If valuePtr == NULL, initialLength == 0, and properties == READ
sjallouli 0:289fd2dae405 324 * for the value attribute of a characteristic, then that particular
sjallouli 0:289fd2dae405 325 * characteristic may be considered optional and dropped while
sjallouli 0:289fd2dae405 326 * instantiating the service with the underlying BLE stack.
sjallouli 0:289fd2dae405 327 */
sjallouli 0:289fd2dae405 328 /**************************************************************************/
sjallouli 0:289fd2dae405 329 GattCharacteristic(const UUID &uuid, uint8_t *valuePtr = NULL, uint16_t initialLen = 0, uint16_t maxLen = 0,
sjallouli 0:289fd2dae405 330 uint8_t props = BLE_GATT_CHAR_PROPERTIES_NONE,
sjallouli 0:289fd2dae405 331 GattAttribute *descriptors[] = NULL, unsigned numDescriptors = 0) :
sjallouli 0:289fd2dae405 332 _valueAttribute(uuid, valuePtr, initialLen, maxLen), _properties(props), _descriptors(descriptors), _descriptorCount(numDescriptors) {
sjallouli 0:289fd2dae405 333 }
sjallouli 0:289fd2dae405 334
sjallouli 0:289fd2dae405 335 public:
sjallouli 0:289fd2dae405 336 GattAttribute& getValueAttribute() {
sjallouli 0:289fd2dae405 337 return _valueAttribute;
sjallouli 0:289fd2dae405 338 }
sjallouli 0:289fd2dae405 339 uint8_t getProperties(void) const {
sjallouli 0:289fd2dae405 340 return _properties;
sjallouli 0:289fd2dae405 341 }
sjallouli 0:289fd2dae405 342 uint8_t getDescriptorCount(void) const {
sjallouli 0:289fd2dae405 343 return _descriptorCount;
sjallouli 0:289fd2dae405 344 }
sjallouli 0:289fd2dae405 345 GattAttribute *getDescriptor(uint8_t index) {
sjallouli 0:289fd2dae405 346 if (index >= _descriptorCount) {
sjallouli 0:289fd2dae405 347 return NULL;
sjallouli 0:289fd2dae405 348 }
sjallouli 0:289fd2dae405 349
sjallouli 0:289fd2dae405 350 return _descriptors[index];
sjallouli 0:289fd2dae405 351 }
sjallouli 0:289fd2dae405 352
sjallouli 0:289fd2dae405 353 private:
sjallouli 0:289fd2dae405 354 GattAttribute _valueAttribute;
sjallouli 0:289fd2dae405 355 uint8_t _properties;
sjallouli 0:289fd2dae405 356 GattAttribute ** _descriptors;
sjallouli 0:289fd2dae405 357 uint8_t _descriptorCount;
sjallouli 0:289fd2dae405 358 };
sjallouli 0:289fd2dae405 359
sjallouli 0:289fd2dae405 360 #endif // ifndef __GATT_CHARACTERISTIC_H__