High level Bluetooth Low Energy API and radio abstraction layer

Dependencies:   nRF51822

Dependents:   LinkNode_LIS3DH

Fork of BLE_API by Bluetooth Low Energy

Committer:
ktownsend
Date:
Wed Dec 18 20:11:45 2013 +0000
Revision:
19:a6f33421746c
Parent:
18:86fe1e247a54
Child:
21:5442f7c70e71
A few more doxygen improvements

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ktownsend 2:ffc5216bd2cc 1 #ifndef __GAP_ADVERTISING_DATA_H__
ktownsend 2:ffc5216bd2cc 2 #define __GAP_ADVERTISING_DATA_H__
ktownsend 2:ffc5216bd2cc 3
ktownsend 2:ffc5216bd2cc 4 #include "blecommon.h"
ktownsend 2:ffc5216bd2cc 5
ktownsend 3:46de446e82ed 6 #define GAP_ADVERTISING_DATA_MAX_PAYLOAD (31)
ktownsend 3:46de446e82ed 7
ktownsend 3:46de446e82ed 8 /**************************************************************************/
ktownsend 3:46de446e82ed 9 /*!
ktownsend 18:86fe1e247a54 10 \brief
ktownsend 3:46de446e82ed 11 This class provides several helper functions to generate properly
ktownsend 3:46de446e82ed 12 formatted GAP Advertising and Scan Response data payloads
ktownsend 4:50a31ff5f974 13
ktownsend 18:86fe1e247a54 14 \note
ktownsend 18:86fe1e247a54 15 See Bluetooth Specification 4.0 (Vol. 3), Part C, Section 11 and 18
ktownsend 4:50a31ff5f974 16 for further information on Advertising and Scan Response data.
ktownsend 4:50a31ff5f974 17
ktownsend 18:86fe1e247a54 18 \par Advertising and Scan Response Payloads
ktownsend 3:46de446e82ed 19 Advertising data and Scan Response data are organized around a set of
ktownsend 4:50a31ff5f974 20 data types called 'AD types' in Bluetooth 4.0 (see the Bluetooth Core
ktownsend 4:50a31ff5f974 21 Specification v4.0, Vol. 3, Part C, Sections 11 and 18).
ktownsend 4:50a31ff5f974 22
ktownsend 18:86fe1e247a54 23 \par
ktownsend 3:46de446e82ed 24 Each AD type has it's own standardized 'assigned number', as defined
ktownsend 3:46de446e82ed 25 by the Bluetooth SIG:
ktownsend 3:46de446e82ed 26 https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile
ktownsend 3:46de446e82ed 27
ktownsend 18:86fe1e247a54 28 \par
ktownsend 3:46de446e82ed 29 For convenience sake, all appropriate AD types have been encapsulated
ktownsend 18:86fe1e247a54 30 into GapAdvertisingData::DataType.
ktownsend 3:46de446e82ed 31
ktownsend 18:86fe1e247a54 32 \par
ktownsend 4:50a31ff5f974 33 Before the AD Types and their payload (if any) can be inserted into
ktownsend 4:50a31ff5f974 34 the Advertising or Scan Response frames, they need to be formatted as
ktownsend 4:50a31ff5f974 35 follows:
ktownsend 3:46de446e82ed 36
ktownsend 18:86fe1e247a54 37 \li \c Record length (1 byte)
ktownsend 18:86fe1e247a54 38 \li \c AD Type (1 byte)
ktownsend 18:86fe1e247a54 39 \li \c AD payload (optional, only present if record length > 1)
ktownsend 5:7635f81a8e09 40
ktownsend 18:86fe1e247a54 41 \par
ktownsend 5:7635f81a8e09 42 This class takes care of properly formatting the payload, performs
ktownsend 5:7635f81a8e09 43 some basic checks on the payload length, and tries to avoid common
ktownsend 5:7635f81a8e09 44 errors like adding an exclusive AD field twice in the Advertising
ktownsend 5:7635f81a8e09 45 or Scan Response payload.
ktownsend 3:46de446e82ed 46
ktownsend 18:86fe1e247a54 47 \par EXAMPLE
ktownsend 5:7635f81a8e09 48
ktownsend 18:86fe1e247a54 49 \code
ktownsend 3:46de446e82ed 50
ktownsend 5:7635f81a8e09 51 // ToDo
ktownsend 5:7635f81a8e09 52
ktownsend 18:86fe1e247a54 53 \endcode
ktownsend 3:46de446e82ed 54 */
ktownsend 3:46de446e82ed 55 /**************************************************************************/
ktownsend 2:ffc5216bd2cc 56 class GapAdvertisingData
ktownsend 2:ffc5216bd2cc 57 {
ktownsend 4:50a31ff5f974 58 public:
ktownsend 19:a6f33421746c 59 /**********************************************************************/
ktownsend 19:a6f33421746c 60 /*!
ktownsend 19:a6f33421746c 61 \brief
ktownsend 19:a6f33421746c 62 A list of Advertising Data types commonly used by peripherals.
ktownsend 19:a6f33421746c 63 These AD types are used to describe the capabilities of the
ktownsend 19:a6f33421746c 64 peripheral, and get inserted inside the advertising or scan
ktownsend 19:a6f33421746c 65 response payloads.
ktownsend 19:a6f33421746c 66
ktownsend 19:a6f33421746c 67 \par Source
ktownsend 19:a6f33421746c 68 \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 11, 18
ktownsend 19:a6f33421746c 69 \li \c https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile
ktownsend 19:a6f33421746c 70 */
ktownsend 19:a6f33421746c 71 /**********************************************************************/
ktownsend 4:50a31ff5f974 72 enum DataType
ktownsend 4:50a31ff5f974 73 {
ktownsend 4:50a31ff5f974 74 FLAGS = 0x01,
ktownsend 4:50a31ff5f974 75 INCOMPLETE_LIST_16BIT_SERVICE_IDS = 0x02,
ktownsend 4:50a31ff5f974 76 COMPLETE_LIST_16BIT_SERVICE_IDS = 0x03,
ktownsend 4:50a31ff5f974 77 INCOMPLETE_LIST_32BIT_SERVICE_IDS = 0x04,
ktownsend 4:50a31ff5f974 78 COMPLETE_LIST_32BIT_SERVICE_IDS = 0x05,
ktownsend 4:50a31ff5f974 79 INCOMPLETE_LIST_128BIT_SERVICE_IDS = 0x06,
ktownsend 4:50a31ff5f974 80 COMPLETE_LIST_128BIT_SERVICE_IDS = 0x07,
ktownsend 4:50a31ff5f974 81 SHORTENED_LOCAL_NAME = 0x08,
ktownsend 4:50a31ff5f974 82 COMPLETE_LOCAL_NAME = 0x09,
ktownsend 4:50a31ff5f974 83 TX_POWER_LEVEL = 0x0A,
ktownsend 4:50a31ff5f974 84 DEVICE_ID = 0x10,
ktownsend 4:50a31ff5f974 85 SLAVE_CONNECTION_INTERVAL_RANGE = 0x12,
ktownsend 4:50a31ff5f974 86 SERVICE_DATA = 0x16,
ktownsend 4:50a31ff5f974 87 APPEARANCE = 0x19,
ktownsend 4:50a31ff5f974 88 ADVERTISING_INTERVAL = 0x1A,
ktownsend 4:50a31ff5f974 89 MANUFACTURER_SPECIFIC_DATA = 0xFF
ktownsend 4:50a31ff5f974 90 };
ktownsend 4:50a31ff5f974 91
ktownsend 19:a6f33421746c 92 /**********************************************************************/
ktownsend 19:a6f33421746c 93 /*!
ktownsend 19:a6f33421746c 94 \brief
ktownsend 19:a6f33421746c 95 A list of values for the FLAGS AD Type
ktownsend 19:a6f33421746c 96
ktownsend 19:a6f33421746c 97 \note
ktownsend 19:a6f33421746c 98 You can use more than one value in the FLAGS AD Type (ex.
ktownsend 19:a6f33421746c 99 LE_GENERAL_DISCOVERABLE and BREDR_NOT_SUPPORTED).
ktownsend 19:a6f33421746c 100
ktownsend 19:a6f33421746c 101 \par Source
ktownsend 19:a6f33421746c 102 \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 18.1
ktownsend 19:a6f33421746c 103 */
ktownsend 19:a6f33421746c 104 /**********************************************************************/
ktownsend 4:50a31ff5f974 105 enum Flags
ktownsend 4:50a31ff5f974 106 {
ktownsend 19:a6f33421746c 107 LE_LIMITED_DISCOVERABLE = 0x01, /**< Peripheral device is discoverable for a limited period of time */
ktownsend 19:a6f33421746c 108 LE_GENERAL_DISCOVERABLE = 0x02, /**< Peripheral device is discoverable at any moment */
ktownsend 19:a6f33421746c 109 BREDR_NOT_SUPPORTED = 0x04, /**< Peripheral device is LE only */
ktownsend 19:a6f33421746c 110 SIMULTANEOUS_LE_BREDR_C = 0x08, /**< Not relevant - central mode only */
ktownsend 19:a6f33421746c 111 SIMULTANEOUS_LE_BREDR_H = 0x10 /**< Not relevant - central mode only */
ktownsend 4:50a31ff5f974 112 };
ktownsend 4:50a31ff5f974 113
ktownsend 19:a6f33421746c 114 /**********************************************************************/
ktownsend 19:a6f33421746c 115 /*!
ktownsend 19:a6f33421746c 116 \brief
ktownsend 19:a6f33421746c 117 A list of values for the APPEARANCE AD Type, which describes the
ktownsend 19:a6f33421746c 118 physical shape or appearance of the device
ktownsend 19:a6f33421746c 119
ktownsend 19:a6f33421746c 120 \par Source
ktownsend 19:a6f33421746c 121 \li \c Bluetooth Core Specification Supplement, Part A, Section 1.12
ktownsend 19:a6f33421746c 122 \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 12.2
ktownsend 19:a6f33421746c 123 \li \c https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
ktownsend 19:a6f33421746c 124 */
ktownsend 19:a6f33421746c 125 /**********************************************************************/
ktownsend 4:50a31ff5f974 126 enum Appearance
ktownsend 4:50a31ff5f974 127 {
ktownsend 4:50a31ff5f974 128 UNKNOWN = 0,
ktownsend 4:50a31ff5f974 129 GENERIC_PHONE = 64,
ktownsend 4:50a31ff5f974 130 GENERIC_COMPUTER = 128,
ktownsend 4:50a31ff5f974 131 GENERIC_WATCH = 192,
ktownsend 4:50a31ff5f974 132 WATCH_SPORTS_WATCH = 193,
ktownsend 4:50a31ff5f974 133 GENERIC_CLOCK = 256,
ktownsend 4:50a31ff5f974 134 GENERIC_DISPLAY = 320,
ktownsend 4:50a31ff5f974 135 GENERIC_REMOTE_CONTROL = 384,
ktownsend 4:50a31ff5f974 136 GENERIC_EYE_GLASSES = 448,
ktownsend 4:50a31ff5f974 137 GENERIC_TAG = 512,
ktownsend 4:50a31ff5f974 138 GENERIC_KEYRING = 576,
ktownsend 4:50a31ff5f974 139 GENERIC_MEDIA_PLAYER = 640,
ktownsend 4:50a31ff5f974 140 GENERIC_BARCODE_SCANNER = 704,
ktownsend 4:50a31ff5f974 141 GENERIC_THERMOMETER = 768,
ktownsend 4:50a31ff5f974 142 THERMOMETER_EAR = 769,
ktownsend 4:50a31ff5f974 143 GENERIC_HEART_RATE_SENSOR = 832,
ktownsend 4:50a31ff5f974 144 HEART_RATE_SENSOR_HEART_RATE_BELT = 833,
ktownsend 4:50a31ff5f974 145 GENERIC_BLOOD_PRESSURE = 896,
ktownsend 4:50a31ff5f974 146 BLOOD_PRESSURE_ARM = 897,
ktownsend 4:50a31ff5f974 147 BLOOD_PRESSURE_WRIST = 898,
ktownsend 4:50a31ff5f974 148 HUMAN_INTERFACE_DEVICE_HID = 960,
ktownsend 4:50a31ff5f974 149 KEYBOARD = 961,
ktownsend 4:50a31ff5f974 150 MOUSE = 962,
ktownsend 4:50a31ff5f974 151 JOYSTICK = 963,
ktownsend 4:50a31ff5f974 152 GAMEPAD = 964,
ktownsend 4:50a31ff5f974 153 DIGITIZER_TABLET = 965,
ktownsend 4:50a31ff5f974 154 CARD_READER = 966,
ktownsend 4:50a31ff5f974 155 DIGITAL_PEN = 967,
ktownsend 4:50a31ff5f974 156 BARCODE_SCANNER = 968,
ktownsend 4:50a31ff5f974 157 GENERIC_GLUCOSE_METER = 1024,
ktownsend 4:50a31ff5f974 158 GENERIC_RUNNING_WALKING_SENSOR = 1088,
ktownsend 4:50a31ff5f974 159 RUNNING_WALKING_SENSOR_IN_SHOE = 1089,
ktownsend 4:50a31ff5f974 160 RUNNING_WALKING_SENSOR_ON_SHOE = 1090,
ktownsend 4:50a31ff5f974 161 RUNNING_WALKING_SENSOR_ON_HIP = 1091,
ktownsend 4:50a31ff5f974 162 GENERIC_CYCLING = 1152,
ktownsend 4:50a31ff5f974 163 CYCLING_CYCLING_COMPUTER = 1153,
ktownsend 4:50a31ff5f974 164 CYCLING_SPEED_SENSOR = 1154,
ktownsend 4:50a31ff5f974 165 CYCLING_CADENCE_SENSOR = 1155,
ktownsend 4:50a31ff5f974 166 CYCLING_POWER_SENSOR = 1156,
ktownsend 4:50a31ff5f974 167 CYCLING_SPEED_AND_CADENCE_SENSOR = 1157,
ktownsend 4:50a31ff5f974 168 PULSE_OXIMETER_GENERIC = 3136,
ktownsend 4:50a31ff5f974 169 PULSE_OXIMETER_FINGERTIP = 3137,
ktownsend 4:50a31ff5f974 170 PULSE_OXIMETER_WRIST_WORN = 3138,
ktownsend 4:50a31ff5f974 171 OUTDOOR_GENERIC = 5184,
ktownsend 4:50a31ff5f974 172 OUTDOOR_LOCATION_DISPLAY_DEVICE = 5185,
ktownsend 4:50a31ff5f974 173 OUTDOOR_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE = 5186,
ktownsend 4:50a31ff5f974 174 OUTDOOR_LOCATION_POD = 5187,
ktownsend 4:50a31ff5f974 175 OUTDOOR_LOCATION_AND_NAVIGATION_POD = 5188
ktownsend 4:50a31ff5f974 176 };
ktownsend 4:50a31ff5f974 177
ktownsend 2:ffc5216bd2cc 178 GapAdvertisingData(void);
ktownsend 2:ffc5216bd2cc 179 virtual ~GapAdvertisingData(void);
ktownsend 3:46de446e82ed 180
ktownsend 4:50a31ff5f974 181 ble_error_t addData(DataType, uint8_t *, uint8_t);
ktownsend 4:50a31ff5f974 182 ble_error_t addAppearance(Appearance appearance = UNKNOWN);
ktownsend 4:50a31ff5f974 183 ble_error_t addFlags(Flags flag = LE_GENERAL_DISCOVERABLE);
ktownsend 4:50a31ff5f974 184 ble_error_t addTxPower(int8_t txPower);
ktownsend 4:50a31ff5f974 185 void clear(void);
ktownsend 7:5e1f0d7f7c7d 186 uint8_t * getPayload(void);
ktownsend 3:46de446e82ed 187 uint8_t getPayloadLen(void);
ktownsend 4:50a31ff5f974 188
ktownsend 4:50a31ff5f974 189 private:
ktownsend 3:46de446e82ed 190 uint8_t _payload[GAP_ADVERTISING_DATA_MAX_PAYLOAD];
ktownsend 3:46de446e82ed 191 uint8_t _payloadLen;
ktownsend 2:ffc5216bd2cc 192 };
ktownsend 2:ffc5216bd2cc 193
ktownsend 2:ffc5216bd2cc 194 #endif