Includes library modifications to allow access to AIN_4 (AIN_0 / 5)

Committer:
bryantaylor
Date:
Tue Sep 20 21:26:12 2016 +0000
Revision:
0:eafc3fd41f75
hackathon

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bryantaylor 0:eafc3fd41f75 1 /* mbed Microcontroller Library
bryantaylor 0:eafc3fd41f75 2 * Copyright (c) 2006-2013 ARM Limited
bryantaylor 0:eafc3fd41f75 3 *
bryantaylor 0:eafc3fd41f75 4 * Licensed under the Apache License, Version 2.0 (the "License");
bryantaylor 0:eafc3fd41f75 5 * you may not use this file except in compliance with the License.
bryantaylor 0:eafc3fd41f75 6 * You may obtain a copy of the License at
bryantaylor 0:eafc3fd41f75 7 *
bryantaylor 0:eafc3fd41f75 8 * http://www.apache.org/licenses/LICENSE-2.0
bryantaylor 0:eafc3fd41f75 9 *
bryantaylor 0:eafc3fd41f75 10 * Unless required by applicable law or agreed to in writing, software
bryantaylor 0:eafc3fd41f75 11 * distributed under the License is distributed on an "AS IS" BASIS,
bryantaylor 0:eafc3fd41f75 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bryantaylor 0:eafc3fd41f75 13 * See the License for the specific language governing permissions and
bryantaylor 0:eafc3fd41f75 14 * limitations under the License.
bryantaylor 0:eafc3fd41f75 15 */
bryantaylor 0:eafc3fd41f75 16
bryantaylor 0:eafc3fd41f75 17 #ifndef __GAP_ADVERTISING_DATA_H__
bryantaylor 0:eafc3fd41f75 18 #define __GAP_ADVERTISING_DATA_H__
bryantaylor 0:eafc3fd41f75 19
bryantaylor 0:eafc3fd41f75 20 #include <stdint.h>
bryantaylor 0:eafc3fd41f75 21 #include <string.h>
bryantaylor 0:eafc3fd41f75 22
bryantaylor 0:eafc3fd41f75 23 #include "blecommon.h"
bryantaylor 0:eafc3fd41f75 24
bryantaylor 0:eafc3fd41f75 25 #define GAP_ADVERTISING_DATA_MAX_PAYLOAD (31)
bryantaylor 0:eafc3fd41f75 26
bryantaylor 0:eafc3fd41f75 27 /**
bryantaylor 0:eafc3fd41f75 28 * @brief This class provides several helper functions to generate properly
bryantaylor 0:eafc3fd41f75 29 * formatted GAP Advertising and Scan Response data payloads.
bryantaylor 0:eafc3fd41f75 30 *
bryantaylor 0:eafc3fd41f75 31 * @note See Bluetooth Specification 4.0 (Vol. 3), Part C, Sections 11 and 18
bryantaylor 0:eafc3fd41f75 32 * for further information on Advertising and Scan Response data.
bryantaylor 0:eafc3fd41f75 33 *
bryantaylor 0:eafc3fd41f75 34 * @par Advertising and Scan Response Payloads
bryantaylor 0:eafc3fd41f75 35 * Advertising data and Scan Response data are organized around a set of
bryantaylor 0:eafc3fd41f75 36 * data types called 'AD types' in Bluetooth 4.0 (see the Bluetooth Core
bryantaylor 0:eafc3fd41f75 37 * Specification v4.0, Vol. 3, Part C, Sections 11 and 18).
bryantaylor 0:eafc3fd41f75 38 *
bryantaylor 0:eafc3fd41f75 39 * @par
bryantaylor 0:eafc3fd41f75 40 * Each AD type has its own standardized assigned number, as defined
bryantaylor 0:eafc3fd41f75 41 * by the Bluetooth SIG:
bryantaylor 0:eafc3fd41f75 42 * https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile.
bryantaylor 0:eafc3fd41f75 43 *
bryantaylor 0:eafc3fd41f75 44 * @par
bryantaylor 0:eafc3fd41f75 45 * For convenience, all appropriate AD types are encapsulated
bryantaylor 0:eafc3fd41f75 46 * in GapAdvertisingData::DataType.
bryantaylor 0:eafc3fd41f75 47 *
bryantaylor 0:eafc3fd41f75 48 * @par
bryantaylor 0:eafc3fd41f75 49 * Before the AD Types and their payload (if any) can be inserted into
bryantaylor 0:eafc3fd41f75 50 * the Advertising or Scan Response frames, they need to be formatted as
bryantaylor 0:eafc3fd41f75 51 * follows:
bryantaylor 0:eafc3fd41f75 52 *
bryantaylor 0:eafc3fd41f75 53 * @li @c Record length (1 byte).
bryantaylor 0:eafc3fd41f75 54 * @li @c AD Type (1 byte).
bryantaylor 0:eafc3fd41f75 55 * @li @c AD payload (optional; only present if record length > 1).
bryantaylor 0:eafc3fd41f75 56 *
bryantaylor 0:eafc3fd41f75 57 * @par
bryantaylor 0:eafc3fd41f75 58 * This class takes care of properly formatting the payload, performs
bryantaylor 0:eafc3fd41f75 59 * some basic checks on the payload length, and tries to avoid common
bryantaylor 0:eafc3fd41f75 60 * errors like adding an exclusive AD field twice in the Advertising
bryantaylor 0:eafc3fd41f75 61 * or Scan Response payload.
bryantaylor 0:eafc3fd41f75 62 *
bryantaylor 0:eafc3fd41f75 63 * @par EXAMPLE
bryantaylor 0:eafc3fd41f75 64 *
bryantaylor 0:eafc3fd41f75 65 * @code
bryantaylor 0:eafc3fd41f75 66 *
bryantaylor 0:eafc3fd41f75 67 * // ToDo
bryantaylor 0:eafc3fd41f75 68 *
bryantaylor 0:eafc3fd41f75 69 * @endcode
bryantaylor 0:eafc3fd41f75 70 */
bryantaylor 0:eafc3fd41f75 71 class GapAdvertisingData
bryantaylor 0:eafc3fd41f75 72 {
bryantaylor 0:eafc3fd41f75 73 public:
bryantaylor 0:eafc3fd41f75 74 /*!
bryantaylor 0:eafc3fd41f75 75 * @brief A list of Advertising Data types commonly used by peripherals.
bryantaylor 0:eafc3fd41f75 76 * These AD types are used to describe the capabilities of the
bryantaylor 0:eafc3fd41f75 77 * peripheral, and are inserted inside the advertising or scan
bryantaylor 0:eafc3fd41f75 78 * response payloads.
bryantaylor 0:eafc3fd41f75 79 *
bryantaylor 0:eafc3fd41f75 80 * @par Source
bryantaylor 0:eafc3fd41f75 81 *
bryantaylor 0:eafc3fd41f75 82 * @li @c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 11, 18.
bryantaylor 0:eafc3fd41f75 83 * @li @c https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile.
bryantaylor 0:eafc3fd41f75 84 */
bryantaylor 0:eafc3fd41f75 85 enum DataType_t {
bryantaylor 0:eafc3fd41f75 86 FLAGS = 0x01, /**< Flags, refer to GapAdvertisingData::Flags_t. */
bryantaylor 0:eafc3fd41f75 87 INCOMPLETE_LIST_16BIT_SERVICE_IDS = 0x02, /**< Incomplete list of 16-bit Service IDs. */
bryantaylor 0:eafc3fd41f75 88 COMPLETE_LIST_16BIT_SERVICE_IDS = 0x03, /**< Complete list of 16-bit Service IDs. */
bryantaylor 0:eafc3fd41f75 89 INCOMPLETE_LIST_32BIT_SERVICE_IDS = 0x04, /**< Incomplete list of 32-bit Service IDs (not relevant for Bluetooth 4.0). */
bryantaylor 0:eafc3fd41f75 90 COMPLETE_LIST_32BIT_SERVICE_IDS = 0x05, /**< Complete list of 32-bit Service IDs (not relevant for Bluetooth 4.0). */
bryantaylor 0:eafc3fd41f75 91 INCOMPLETE_LIST_128BIT_SERVICE_IDS = 0x06, /**< Incomplete list of 128-bit Service IDs. */
bryantaylor 0:eafc3fd41f75 92 COMPLETE_LIST_128BIT_SERVICE_IDS = 0x07, /**< Complete list of 128-bit Service IDs. */
bryantaylor 0:eafc3fd41f75 93 SHORTENED_LOCAL_NAME = 0x08, /**< Shortened Local Name. */
bryantaylor 0:eafc3fd41f75 94 COMPLETE_LOCAL_NAME = 0x09, /**< Complete Local Name. */
bryantaylor 0:eafc3fd41f75 95 TX_POWER_LEVEL = 0x0A, /**< TX Power Level (in dBm). */
bryantaylor 0:eafc3fd41f75 96 DEVICE_ID = 0x10, /**< Device ID. */
bryantaylor 0:eafc3fd41f75 97 SLAVE_CONNECTION_INTERVAL_RANGE = 0x12, /**< Slave Connection Interval Range. */
bryantaylor 0:eafc3fd41f75 98 LIST_128BIT_SOLICITATION_IDS = 0x15, /**< List of 128 bit service UUIDs the device is looking for. */
bryantaylor 0:eafc3fd41f75 99 SERVICE_DATA = 0x16, /**< Service Data. */
bryantaylor 0:eafc3fd41f75 100 APPEARANCE = 0x19, /**< Appearance, refer to GapAdvertisingData::Appearance_t. */
bryantaylor 0:eafc3fd41f75 101 ADVERTISING_INTERVAL = 0x1A, /**< Advertising Interval. */
bryantaylor 0:eafc3fd41f75 102 MANUFACTURER_SPECIFIC_DATA = 0xFF /**< Manufacturer Specific Data. */
bryantaylor 0:eafc3fd41f75 103 };
bryantaylor 0:eafc3fd41f75 104 /**
bryantaylor 0:eafc3fd41f75 105 * Type alias for GapAdvertisingData::DataType_t.
bryantaylor 0:eafc3fd41f75 106 *
bryantaylor 0:eafc3fd41f75 107 * @deprecated This type alias will be dropped in future releases.
bryantaylor 0:eafc3fd41f75 108 */
bryantaylor 0:eafc3fd41f75 109 typedef enum DataType_t DataType;
bryantaylor 0:eafc3fd41f75 110
bryantaylor 0:eafc3fd41f75 111 /**
bryantaylor 0:eafc3fd41f75 112 * @brief A list of values for the FLAGS AD Type.
bryantaylor 0:eafc3fd41f75 113 *
bryantaylor 0:eafc3fd41f75 114 * @note You can use more than one value in the FLAGS AD Type (ex.
bryantaylor 0:eafc3fd41f75 115 * LE_GENERAL_DISCOVERABLE and BREDR_NOT_SUPPORTED).
bryantaylor 0:eafc3fd41f75 116 *
bryantaylor 0:eafc3fd41f75 117 * @par Source
bryantaylor 0:eafc3fd41f75 118 *
bryantaylor 0:eafc3fd41f75 119 * @li @c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 18.1.
bryantaylor 0:eafc3fd41f75 120 */
bryantaylor 0:eafc3fd41f75 121 enum Flags_t {
bryantaylor 0:eafc3fd41f75 122 LE_LIMITED_DISCOVERABLE = 0x01, /**< Peripheral device is discoverable for a limited period of time. */
bryantaylor 0:eafc3fd41f75 123 LE_GENERAL_DISCOVERABLE = 0x02, /**< Peripheral device is discoverable at any moment. */
bryantaylor 0:eafc3fd41f75 124 BREDR_NOT_SUPPORTED = 0x04, /**< Peripheral device is LE only. */
bryantaylor 0:eafc3fd41f75 125 SIMULTANEOUS_LE_BREDR_C = 0x08, /**< Not relevant - central mode only. */
bryantaylor 0:eafc3fd41f75 126 SIMULTANEOUS_LE_BREDR_H = 0x10 /**< Not relevant - central mode only. */
bryantaylor 0:eafc3fd41f75 127 };
bryantaylor 0:eafc3fd41f75 128 /**
bryantaylor 0:eafc3fd41f75 129 * Type alias for GapAdvertisingData::Flags_t.
bryantaylor 0:eafc3fd41f75 130 *
bryantaylor 0:eafc3fd41f75 131 * @deprecated This type alias will be dropped in future releases.
bryantaylor 0:eafc3fd41f75 132 */
bryantaylor 0:eafc3fd41f75 133 typedef enum Flags_t Flags;
bryantaylor 0:eafc3fd41f75 134
bryantaylor 0:eafc3fd41f75 135 /**
bryantaylor 0:eafc3fd41f75 136 * @brief
bryantaylor 0:eafc3fd41f75 137 * A list of values for the APPEARANCE AD Type, which describes the
bryantaylor 0:eafc3fd41f75 138 * physical shape or appearance of the device.
bryantaylor 0:eafc3fd41f75 139 *
bryantaylor 0:eafc3fd41f75 140 * @par Source
bryantaylor 0:eafc3fd41f75 141 *
bryantaylor 0:eafc3fd41f75 142 * @li @c Bluetooth Core Specification Supplement, Part A, Section 1.12.
bryantaylor 0:eafc3fd41f75 143 * @li @c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 12.2.
bryantaylor 0:eafc3fd41f75 144 * @li @c https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml.
bryantaylor 0:eafc3fd41f75 145 */
bryantaylor 0:eafc3fd41f75 146 enum Appearance_t {
bryantaylor 0:eafc3fd41f75 147 UNKNOWN = 0, /**< Unknown or unspecified appearance type. */
bryantaylor 0:eafc3fd41f75 148 GENERIC_PHONE = 64, /**< Generic Phone. */
bryantaylor 0:eafc3fd41f75 149 GENERIC_COMPUTER = 128, /**< Generic Computer. */
bryantaylor 0:eafc3fd41f75 150 GENERIC_WATCH = 192, /**< Generic Watch. */
bryantaylor 0:eafc3fd41f75 151 WATCH_SPORTS_WATCH = 193, /**< Sports Watch. */
bryantaylor 0:eafc3fd41f75 152 GENERIC_CLOCK = 256, /**< Generic Clock. */
bryantaylor 0:eafc3fd41f75 153 GENERIC_DISPLAY = 320, /**< Generic Display. */
bryantaylor 0:eafc3fd41f75 154 GENERIC_REMOTE_CONTROL = 384, /**< Generic Remote Control. */
bryantaylor 0:eafc3fd41f75 155 GENERIC_EYE_GLASSES = 448, /**< Generic Eye Glasses. */
bryantaylor 0:eafc3fd41f75 156 GENERIC_TAG = 512, /**< Generic Tag. */
bryantaylor 0:eafc3fd41f75 157 GENERIC_KEYRING = 576, /**< Generic Keyring. */
bryantaylor 0:eafc3fd41f75 158 GENERIC_MEDIA_PLAYER = 640, /**< Generic Media Player. */
bryantaylor 0:eafc3fd41f75 159 GENERIC_BARCODE_SCANNER = 704, /**< Generic Barcode Scanner. */
bryantaylor 0:eafc3fd41f75 160 GENERIC_THERMOMETER = 768, /**< Generic Thermometer. */
bryantaylor 0:eafc3fd41f75 161 THERMOMETER_EAR = 769, /**< Ear Thermometer. */
bryantaylor 0:eafc3fd41f75 162 GENERIC_HEART_RATE_SENSOR = 832, /**< Generic Heart Rate Sensor. */
bryantaylor 0:eafc3fd41f75 163 HEART_RATE_SENSOR_HEART_RATE_BELT = 833, /**< Belt Heart Rate Sensor. */
bryantaylor 0:eafc3fd41f75 164 GENERIC_BLOOD_PRESSURE = 896, /**< Generic Blood Pressure. */
bryantaylor 0:eafc3fd41f75 165 BLOOD_PRESSURE_ARM = 897, /**< Arm Blood Pressure. */
bryantaylor 0:eafc3fd41f75 166 BLOOD_PRESSURE_WRIST = 898, /**< Wrist Blood Pressure. */
bryantaylor 0:eafc3fd41f75 167 HUMAN_INTERFACE_DEVICE_HID = 960, /**< Human Interface Device (HID). */
bryantaylor 0:eafc3fd41f75 168 KEYBOARD = 961, /**< Keyboard. */
bryantaylor 0:eafc3fd41f75 169 MOUSE = 962, /**< Mouse. */
bryantaylor 0:eafc3fd41f75 170 JOYSTICK = 963, /**< Joystick. */
bryantaylor 0:eafc3fd41f75 171 GAMEPAD = 964, /**< Gamepad. */
bryantaylor 0:eafc3fd41f75 172 DIGITIZER_TABLET = 965, /**< Digitizer Tablet. */
bryantaylor 0:eafc3fd41f75 173 CARD_READER = 966, /**< Card Reader. */
bryantaylor 0:eafc3fd41f75 174 DIGITAL_PEN = 967, /**< Digital Pen. */
bryantaylor 0:eafc3fd41f75 175 BARCODE_SCANNER = 968, /**< Barcode Scanner. */
bryantaylor 0:eafc3fd41f75 176 GENERIC_GLUCOSE_METER = 1024, /**< Generic Glucose Meter. */
bryantaylor 0:eafc3fd41f75 177 GENERIC_RUNNING_WALKING_SENSOR = 1088, /**< Generic Running/Walking Sensor. */
bryantaylor 0:eafc3fd41f75 178 RUNNING_WALKING_SENSOR_IN_SHOE = 1089, /**< In Shoe Running/Walking Sensor. */
bryantaylor 0:eafc3fd41f75 179 RUNNING_WALKING_SENSOR_ON_SHOE = 1090, /**< On Shoe Running/Walking Sensor. */
bryantaylor 0:eafc3fd41f75 180 RUNNING_WALKING_SENSOR_ON_HIP = 1091, /**< On Hip Running/Walking Sensor. */
bryantaylor 0:eafc3fd41f75 181 GENERIC_CYCLING = 1152, /**< Generic Cycling. */
bryantaylor 0:eafc3fd41f75 182 CYCLING_CYCLING_COMPUTER = 1153, /**< Cycling Computer. */
bryantaylor 0:eafc3fd41f75 183 CYCLING_SPEED_SENSOR = 1154, /**< Cycling Speed Sensor. */
bryantaylor 0:eafc3fd41f75 184 CYCLING_CADENCE_SENSOR = 1155, /**< Cycling Cadence Sensor. */
bryantaylor 0:eafc3fd41f75 185 CYCLING_POWER_SENSOR = 1156, /**< Cycling Power Sensor. */
bryantaylor 0:eafc3fd41f75 186 CYCLING_SPEED_AND_CADENCE_SENSOR = 1157, /**< Cycling Speed and Cadence Sensor. */
bryantaylor 0:eafc3fd41f75 187 PULSE_OXIMETER_GENERIC = 3136, /**< Generic Pulse Oximeter. */
bryantaylor 0:eafc3fd41f75 188 PULSE_OXIMETER_FINGERTIP = 3137, /**< Fingertip Pulse Oximeter. */
bryantaylor 0:eafc3fd41f75 189 PULSE_OXIMETER_WRIST_WORN = 3138, /**< Wrist Worn Pulse Oximeter. */
bryantaylor 0:eafc3fd41f75 190 GENERIC_WEIGHT_SCALE = 3200, /**< Generic Weight Scale. */
bryantaylor 0:eafc3fd41f75 191 OUTDOOR_GENERIC = 5184, /**< Generic Outdoor. */
bryantaylor 0:eafc3fd41f75 192 OUTDOOR_LOCATION_DISPLAY_DEVICE = 5185, /**< Outdoor Location Display Device. */
bryantaylor 0:eafc3fd41f75 193 OUTDOOR_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE = 5186, /**< Outdoor Location and Navigation Display Device. */
bryantaylor 0:eafc3fd41f75 194 OUTDOOR_LOCATION_POD = 5187, /**< Outdoor Location Pod. */
bryantaylor 0:eafc3fd41f75 195 OUTDOOR_LOCATION_AND_NAVIGATION_POD = 5188 /**< Outdoor Location and Navigation Pod. */
bryantaylor 0:eafc3fd41f75 196 };
bryantaylor 0:eafc3fd41f75 197 /**
bryantaylor 0:eafc3fd41f75 198 * Type alias for GapAdvertisingData::Appearance_t.
bryantaylor 0:eafc3fd41f75 199 *
bryantaylor 0:eafc3fd41f75 200 * @deprecated This type alias will be dropped in future releases.
bryantaylor 0:eafc3fd41f75 201 */
bryantaylor 0:eafc3fd41f75 202 typedef enum Appearance_t Appearance;
bryantaylor 0:eafc3fd41f75 203
bryantaylor 0:eafc3fd41f75 204 /**
bryantaylor 0:eafc3fd41f75 205 * Empty constructor.
bryantaylor 0:eafc3fd41f75 206 */
bryantaylor 0:eafc3fd41f75 207 GapAdvertisingData(void) : _payload(), _payloadLen(0), _appearance(GENERIC_TAG) {
bryantaylor 0:eafc3fd41f75 208 /* empty */
bryantaylor 0:eafc3fd41f75 209 }
bryantaylor 0:eafc3fd41f75 210
bryantaylor 0:eafc3fd41f75 211 /**
bryantaylor 0:eafc3fd41f75 212 * Adds advertising data based on the specified AD type (see GapAdvertisingData::DataType_t).
bryantaylor 0:eafc3fd41f75 213 * If the supplied AD type is already present in the advertising
bryantaylor 0:eafc3fd41f75 214 * payload, then the value is updated.
bryantaylor 0:eafc3fd41f75 215 *
bryantaylor 0:eafc3fd41f75 216 * @param[in] advDataType The Advertising 'DataType' to add.
bryantaylor 0:eafc3fd41f75 217 * @param[in] payload Pointer to the payload contents.
bryantaylor 0:eafc3fd41f75 218 * @param[in] len Size of the payload in bytes.
bryantaylor 0:eafc3fd41f75 219 *
bryantaylor 0:eafc3fd41f75 220 * @return BLE_ERROR_BUFFER_OVERFLOW if the new value causes the
bryantaylor 0:eafc3fd41f75 221 * advertising buffer to overflow. BLE_ERROR_NONE is returned
bryantaylor 0:eafc3fd41f75 222 * on success.
bryantaylor 0:eafc3fd41f75 223 *
bryantaylor 0:eafc3fd41f75 224 * @note When the specified AD type is INCOMPLETE_LIST_16BIT_SERVICE_IDS,
bryantaylor 0:eafc3fd41f75 225 * COMPLETE_LIST_16BIT_SERVICE_IDS, INCOMPLETE_LIST_32BIT_SERVICE_IDS,
bryantaylor 0:eafc3fd41f75 226 * COMPLETE_LIST_32BIT_SERVICE_IDS, INCOMPLETE_LIST_128BIT_SERVICE_IDS,
bryantaylor 0:eafc3fd41f75 227 * COMPLETE_LIST_128BIT_SERVICE_IDS or LIST_128BIT_SOLICITATION_IDS the
bryantaylor 0:eafc3fd41f75 228 * supplied value is appended to the values previously added to the
bryantaylor 0:eafc3fd41f75 229 * payload.
bryantaylor 0:eafc3fd41f75 230 */
bryantaylor 0:eafc3fd41f75 231 ble_error_t addData(DataType_t advDataType, const uint8_t *payload, uint8_t len)
bryantaylor 0:eafc3fd41f75 232 {
bryantaylor 0:eafc3fd41f75 233 /* Find field */
bryantaylor 0:eafc3fd41f75 234 uint8_t* field = findField(advDataType);
bryantaylor 0:eafc3fd41f75 235
bryantaylor 0:eafc3fd41f75 236 if (field) {
bryantaylor 0:eafc3fd41f75 237 /* Field type already exist, either add to field or replace */
bryantaylor 0:eafc3fd41f75 238 return addField(advDataType, payload, len, field);
bryantaylor 0:eafc3fd41f75 239 } else {
bryantaylor 0:eafc3fd41f75 240 /* Field doesn't exists, insert new */
bryantaylor 0:eafc3fd41f75 241 return appendField(advDataType, payload, len);
bryantaylor 0:eafc3fd41f75 242 }
bryantaylor 0:eafc3fd41f75 243 }
bryantaylor 0:eafc3fd41f75 244
bryantaylor 0:eafc3fd41f75 245 /**
bryantaylor 0:eafc3fd41f75 246 * Update a particular ADV field in the advertising payload (based on
bryantaylor 0:eafc3fd41f75 247 * matching type).
bryantaylor 0:eafc3fd41f75 248 *
bryantaylor 0:eafc3fd41f75 249 * @param[in] advDataType The Advertising 'DataType' to add.
bryantaylor 0:eafc3fd41f75 250 * @param[in] payload Pointer to the payload contents.
bryantaylor 0:eafc3fd41f75 251 * @param[in] len Size of the payload in bytes.
bryantaylor 0:eafc3fd41f75 252 *
bryantaylor 0:eafc3fd41f75 253 * @return BLE_ERROR_UNSPECIFIED if the specified field is not found,
bryantaylor 0:eafc3fd41f75 254 * BLE_ERROR_BUFFER_OVERFLOW if the new value causes the
bryantaylor 0:eafc3fd41f75 255 * advertising buffer to overflow. BLE_ERROR_NONE is returned
bryantaylor 0:eafc3fd41f75 256 * on success.
bryantaylor 0:eafc3fd41f75 257 */
bryantaylor 0:eafc3fd41f75 258 ble_error_t updateData(DataType_t advDataType, const uint8_t *payload, uint8_t len)
bryantaylor 0:eafc3fd41f75 259 {
bryantaylor 0:eafc3fd41f75 260 /* Find field */
bryantaylor 0:eafc3fd41f75 261 uint8_t* field = findField(advDataType);
bryantaylor 0:eafc3fd41f75 262
bryantaylor 0:eafc3fd41f75 263 if (field) {
bryantaylor 0:eafc3fd41f75 264 /* Field type already exist, replace field contents */
bryantaylor 0:eafc3fd41f75 265 return updateField(advDataType, payload, len, field);
bryantaylor 0:eafc3fd41f75 266 } else {
bryantaylor 0:eafc3fd41f75 267 /* field doesn't exists, return an error */
bryantaylor 0:eafc3fd41f75 268 return BLE_ERROR_UNSPECIFIED;
bryantaylor 0:eafc3fd41f75 269 }
bryantaylor 0:eafc3fd41f75 270 }
bryantaylor 0:eafc3fd41f75 271
bryantaylor 0:eafc3fd41f75 272 /**
bryantaylor 0:eafc3fd41f75 273 * Helper function to add APPEARANCE data to the advertising payload.
bryantaylor 0:eafc3fd41f75 274 *
bryantaylor 0:eafc3fd41f75 275 * @param appearance
bryantaylor 0:eafc3fd41f75 276 * The APPEARANCE value to add.
bryantaylor 0:eafc3fd41f75 277 *
bryantaylor 0:eafc3fd41f75 278 * @return BLE_ERROR_BUFFER_OVERFLOW if the specified data would cause the
bryantaylor 0:eafc3fd41f75 279 * advertising buffer to overflow, else BLE_ERROR_NONE.
bryantaylor 0:eafc3fd41f75 280 */
bryantaylor 0:eafc3fd41f75 281 ble_error_t addAppearance(Appearance appearance = GENERIC_TAG) {
bryantaylor 0:eafc3fd41f75 282 _appearance = appearance;
bryantaylor 0:eafc3fd41f75 283 return addData(GapAdvertisingData::APPEARANCE, (uint8_t *)&appearance, 2);
bryantaylor 0:eafc3fd41f75 284 }
bryantaylor 0:eafc3fd41f75 285
bryantaylor 0:eafc3fd41f75 286 /**
bryantaylor 0:eafc3fd41f75 287 * Helper function to add FLAGS data to the advertising payload.
bryantaylor 0:eafc3fd41f75 288 *
bryantaylor 0:eafc3fd41f75 289 * @param[in] flags
bryantaylor 0:eafc3fd41f75 290 * LE_LIMITED_DISCOVERABLE
bryantaylor 0:eafc3fd41f75 291 * The peripheral is discoverable for a limited period of time.
bryantaylor 0:eafc3fd41f75 292 * LE_GENERAL_DISCOVERABLE
bryantaylor 0:eafc3fd41f75 293 * The peripheral is permanently discoverable.
bryantaylor 0:eafc3fd41f75 294 * BREDR_NOT_SUPPORTED
bryantaylor 0:eafc3fd41f75 295 * This peripheral is a Bluetooth Low Energy only device (no EDR support).
bryantaylor 0:eafc3fd41f75 296 *
bryantaylor 0:eafc3fd41f75 297 * @return BLE_ERROR_BUFFER_OVERFLOW if the specified data would cause the
bryantaylor 0:eafc3fd41f75 298 * advertising buffer to overflow, else BLE_ERROR_NONE.
bryantaylor 0:eafc3fd41f75 299 */
bryantaylor 0:eafc3fd41f75 300 ble_error_t addFlags(uint8_t flags = LE_GENERAL_DISCOVERABLE) {
bryantaylor 0:eafc3fd41f75 301 return addData(GapAdvertisingData::FLAGS, &flags, 1);
bryantaylor 0:eafc3fd41f75 302 }
bryantaylor 0:eafc3fd41f75 303
bryantaylor 0:eafc3fd41f75 304 /**
bryantaylor 0:eafc3fd41f75 305 * Helper function to add TX_POWER_LEVEL data to the advertising payload.
bryantaylor 0:eafc3fd41f75 306 *
bryantaylor 0:eafc3fd41f75 307 * @return BLE_ERROR_BUFFER_OVERFLOW if the specified data would cause the
bryantaylor 0:eafc3fd41f75 308 * advertising buffer to overflow, else BLE_ERROR_NONE.
bryantaylor 0:eafc3fd41f75 309 */
bryantaylor 0:eafc3fd41f75 310 ble_error_t addTxPower(int8_t txPower) {
bryantaylor 0:eafc3fd41f75 311 /* To Do: Basic error checking to make sure txPower is in range. */
bryantaylor 0:eafc3fd41f75 312 return addData(GapAdvertisingData::TX_POWER_LEVEL, (uint8_t *)&txPower, 1);
bryantaylor 0:eafc3fd41f75 313 }
bryantaylor 0:eafc3fd41f75 314
bryantaylor 0:eafc3fd41f75 315 /**
bryantaylor 0:eafc3fd41f75 316 * Clears the payload and resets the payload length counter.
bryantaylor 0:eafc3fd41f75 317 */
bryantaylor 0:eafc3fd41f75 318 void clear(void) {
bryantaylor 0:eafc3fd41f75 319 memset(&_payload, 0, GAP_ADVERTISING_DATA_MAX_PAYLOAD);
bryantaylor 0:eafc3fd41f75 320 _payloadLen = 0;
bryantaylor 0:eafc3fd41f75 321 }
bryantaylor 0:eafc3fd41f75 322
bryantaylor 0:eafc3fd41f75 323 /**
bryantaylor 0:eafc3fd41f75 324 * Access the current payload.
bryantaylor 0:eafc3fd41f75 325 *
bryantaylor 0:eafc3fd41f75 326 * @return A pointer to the current payload.
bryantaylor 0:eafc3fd41f75 327 */
bryantaylor 0:eafc3fd41f75 328 const uint8_t *getPayload(void) const {
bryantaylor 0:eafc3fd41f75 329 return _payload;
bryantaylor 0:eafc3fd41f75 330 }
bryantaylor 0:eafc3fd41f75 331
bryantaylor 0:eafc3fd41f75 332 /**
bryantaylor 0:eafc3fd41f75 333 * Get the current payload length.
bryantaylor 0:eafc3fd41f75 334 *
bryantaylor 0:eafc3fd41f75 335 * @return The current payload length (0..31 bytes).
bryantaylor 0:eafc3fd41f75 336 */
bryantaylor 0:eafc3fd41f75 337 uint8_t getPayloadLen(void) const {
bryantaylor 0:eafc3fd41f75 338 return _payloadLen;
bryantaylor 0:eafc3fd41f75 339 }
bryantaylor 0:eafc3fd41f75 340
bryantaylor 0:eafc3fd41f75 341 /**
bryantaylor 0:eafc3fd41f75 342 * Get the current appearance value.
bryantaylor 0:eafc3fd41f75 343 *
bryantaylor 0:eafc3fd41f75 344 * @return The 16-bit appearance value for this device.
bryantaylor 0:eafc3fd41f75 345 */
bryantaylor 0:eafc3fd41f75 346 uint16_t getAppearance(void) const {
bryantaylor 0:eafc3fd41f75 347 return (uint16_t)_appearance;
bryantaylor 0:eafc3fd41f75 348 }
bryantaylor 0:eafc3fd41f75 349
bryantaylor 0:eafc3fd41f75 350 /**
bryantaylor 0:eafc3fd41f75 351 * Search advertisement data for a specific field.
bryantaylor 0:eafc3fd41f75 352 *
bryantaylor 0:eafc3fd41f75 353 * @param[in] type
bryantaylor 0:eafc3fd41f75 354 * The type of the field to find.
bryantaylor 0:eafc3fd41f75 355 *
bryantaylor 0:eafc3fd41f75 356 * @return A pointer to the first element in the field if found, NULL otherwise.
bryantaylor 0:eafc3fd41f75 357 * Where the first element is the length of the field.
bryantaylor 0:eafc3fd41f75 358 */
bryantaylor 0:eafc3fd41f75 359 const uint8_t* findField(DataType_t type) const {
bryantaylor 0:eafc3fd41f75 360 return findField(type);
bryantaylor 0:eafc3fd41f75 361 }
bryantaylor 0:eafc3fd41f75 362
bryantaylor 0:eafc3fd41f75 363 private:
bryantaylor 0:eafc3fd41f75 364 /**
bryantaylor 0:eafc3fd41f75 365 * Append advertising data based on the specified AD type (see
bryantaylor 0:eafc3fd41f75 366 * GapAdvertisingData::DataType_t).
bryantaylor 0:eafc3fd41f75 367 *
bryantaylor 0:eafc3fd41f75 368 * @param[in] advDataType
bryantaylor 0:eafc3fd41f75 369 * The type of the new data.
bryantaylor 0:eafc3fd41f75 370 * @param[in] payload
bryantaylor 0:eafc3fd41f75 371 * A pointer to the data to be appended to the advertising
bryantaylor 0:eafc3fd41f75 372 * payload.
bryantaylor 0:eafc3fd41f75 373 * @param[in] len
bryantaylor 0:eafc3fd41f75 374 * The length of th data pointed to by @p payload.
bryantaylor 0:eafc3fd41f75 375 *
bryantaylor 0:eafc3fd41f75 376 * @return BLE_ERROR_BUFFER_OVERFLOW if the specified data would cause the
bryantaylor 0:eafc3fd41f75 377 * advertising buffer to overflow, else BLE_ERROR_NONE.
bryantaylor 0:eafc3fd41f75 378 */
bryantaylor 0:eafc3fd41f75 379 ble_error_t appendField(DataType advDataType, const uint8_t *payload, uint8_t len)
bryantaylor 0:eafc3fd41f75 380 {
bryantaylor 0:eafc3fd41f75 381 /* Make sure we don't exceed the 31 byte payload limit */
bryantaylor 0:eafc3fd41f75 382 if (_payloadLen + len + 2 > GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
bryantaylor 0:eafc3fd41f75 383 return BLE_ERROR_BUFFER_OVERFLOW;
bryantaylor 0:eafc3fd41f75 384 }
bryantaylor 0:eafc3fd41f75 385
bryantaylor 0:eafc3fd41f75 386 /* Field length. */
bryantaylor 0:eafc3fd41f75 387 memset(&_payload[_payloadLen], len + 1, 1);
bryantaylor 0:eafc3fd41f75 388 _payloadLen++;
bryantaylor 0:eafc3fd41f75 389
bryantaylor 0:eafc3fd41f75 390 /* Field ID. */
bryantaylor 0:eafc3fd41f75 391 memset(&_payload[_payloadLen], (uint8_t)advDataType, 1);
bryantaylor 0:eafc3fd41f75 392 _payloadLen++;
bryantaylor 0:eafc3fd41f75 393
bryantaylor 0:eafc3fd41f75 394 /* Payload. */
bryantaylor 0:eafc3fd41f75 395 memcpy(&_payload[_payloadLen], payload, len);
bryantaylor 0:eafc3fd41f75 396 _payloadLen += len;
bryantaylor 0:eafc3fd41f75 397
bryantaylor 0:eafc3fd41f75 398 return BLE_ERROR_NONE;
bryantaylor 0:eafc3fd41f75 399 }
bryantaylor 0:eafc3fd41f75 400
bryantaylor 0:eafc3fd41f75 401 /**
bryantaylor 0:eafc3fd41f75 402 * Search advertisement data for field.
bryantaylor 0:eafc3fd41f75 403 *
bryantaylor 0:eafc3fd41f75 404 * @param[in] type
bryantaylor 0:eafc3fd41f75 405 * The type of the data to find.
bryantaylor 0:eafc3fd41f75 406 *
bryantaylor 0:eafc3fd41f75 407 * @return A pointer to the first element in the field if found, NULL
bryantaylor 0:eafc3fd41f75 408 * otherwise. Where the first element is the length of the field.
bryantaylor 0:eafc3fd41f75 409 */
bryantaylor 0:eafc3fd41f75 410 uint8_t* findField(DataType_t type) {
bryantaylor 0:eafc3fd41f75 411 /* Scan through advertisement data */
bryantaylor 0:eafc3fd41f75 412 for (uint8_t idx = 0; idx < _payloadLen; ) {
bryantaylor 0:eafc3fd41f75 413 uint8_t fieldType = _payload[idx + 1];
bryantaylor 0:eafc3fd41f75 414
bryantaylor 0:eafc3fd41f75 415 if (fieldType == type) {
bryantaylor 0:eafc3fd41f75 416 return &_payload[idx];
bryantaylor 0:eafc3fd41f75 417 }
bryantaylor 0:eafc3fd41f75 418
bryantaylor 0:eafc3fd41f75 419 /* Advance to next field */
bryantaylor 0:eafc3fd41f75 420 idx += _payload[idx] + 1;
bryantaylor 0:eafc3fd41f75 421 }
bryantaylor 0:eafc3fd41f75 422
bryantaylor 0:eafc3fd41f75 423 /* Field not found */
bryantaylor 0:eafc3fd41f75 424 return NULL;
bryantaylor 0:eafc3fd41f75 425 }
bryantaylor 0:eafc3fd41f75 426
bryantaylor 0:eafc3fd41f75 427 /**
bryantaylor 0:eafc3fd41f75 428 * Given the a pointer to a field in the advertising payload it replaces
bryantaylor 0:eafc3fd41f75 429 * the existing data in the field with the supplied data.
bryantaylor 0:eafc3fd41f75 430 *
bryantaylor 0:eafc3fd41f75 431 * @param[in] advDataType
bryantaylor 0:eafc3fd41f75 432 * The type of the new data.
bryantaylor 0:eafc3fd41f75 433 * @param[in] payload
bryantaylor 0:eafc3fd41f75 434 * A pointer to the data to be added to the advertising
bryantaylor 0:eafc3fd41f75 435 * payload.
bryantaylor 0:eafc3fd41f75 436 * @param[in] len
bryantaylor 0:eafc3fd41f75 437 * The length of th data pointed to by @p payload.
bryantaylor 0:eafc3fd41f75 438 * @param[in] field
bryantaylor 0:eafc3fd41f75 439 * A pointer to the field of type @p advDataType in the
bryantaylor 0:eafc3fd41f75 440 * advertising buffer.
bryantaylor 0:eafc3fd41f75 441 *
bryantaylor 0:eafc3fd41f75 442 * When the specified AD type is INCOMPLETE_LIST_16BIT_SERVICE_IDS,
bryantaylor 0:eafc3fd41f75 443 * COMPLETE_LIST_16BIT_SERVICE_IDS, INCOMPLETE_LIST_32BIT_SERVICE_IDS,
bryantaylor 0:eafc3fd41f75 444 * COMPLETE_LIST_32BIT_SERVICE_IDS, INCOMPLETE_LIST_128BIT_SERVICE_IDS,
bryantaylor 0:eafc3fd41f75 445 * COMPLETE_LIST_128BIT_SERVICE_IDS or LIST_128BIT_SOLICITATION_IDS the
bryantaylor 0:eafc3fd41f75 446 * supplied value is appended to the values previously added to the
bryantaylor 0:eafc3fd41f75 447 * payload.
bryantaylor 0:eafc3fd41f75 448 *
bryantaylor 0:eafc3fd41f75 449 * @return BLE_ERROR_NONE on success.
bryantaylor 0:eafc3fd41f75 450 */
bryantaylor 0:eafc3fd41f75 451 ble_error_t addField(DataType_t advDataType, const uint8_t *payload, uint8_t len, uint8_t* field)
bryantaylor 0:eafc3fd41f75 452 {
bryantaylor 0:eafc3fd41f75 453 ble_error_t result = BLE_ERROR_BUFFER_OVERFLOW;
bryantaylor 0:eafc3fd41f75 454
bryantaylor 0:eafc3fd41f75 455 switch(advDataType) {
bryantaylor 0:eafc3fd41f75 456 /* These fields will have the new data appended if there is sufficient space */
bryantaylor 0:eafc3fd41f75 457 case INCOMPLETE_LIST_16BIT_SERVICE_IDS:
bryantaylor 0:eafc3fd41f75 458 case COMPLETE_LIST_16BIT_SERVICE_IDS:
bryantaylor 0:eafc3fd41f75 459 case INCOMPLETE_LIST_32BIT_SERVICE_IDS:
bryantaylor 0:eafc3fd41f75 460 case COMPLETE_LIST_32BIT_SERVICE_IDS:
bryantaylor 0:eafc3fd41f75 461 case INCOMPLETE_LIST_128BIT_SERVICE_IDS:
bryantaylor 0:eafc3fd41f75 462 case COMPLETE_LIST_128BIT_SERVICE_IDS:
bryantaylor 0:eafc3fd41f75 463 case LIST_128BIT_SOLICITATION_IDS: {
bryantaylor 0:eafc3fd41f75 464 /* Check if data fits */
bryantaylor 0:eafc3fd41f75 465 if ((_payloadLen + len) <= GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
bryantaylor 0:eafc3fd41f75 466 /*
bryantaylor 0:eafc3fd41f75 467 * Make room for new field by moving the remainder of the
bryantaylor 0:eafc3fd41f75 468 * advertisement payload "to the right" starting after the
bryantaylor 0:eafc3fd41f75 469 * TYPE field.
bryantaylor 0:eafc3fd41f75 470 */
bryantaylor 0:eafc3fd41f75 471 uint8_t* end = &_payload[_payloadLen];
bryantaylor 0:eafc3fd41f75 472
bryantaylor 0:eafc3fd41f75 473 while (&field[1] < end) {
bryantaylor 0:eafc3fd41f75 474 end[len] = *end;
bryantaylor 0:eafc3fd41f75 475 end--;
bryantaylor 0:eafc3fd41f75 476 }
bryantaylor 0:eafc3fd41f75 477
bryantaylor 0:eafc3fd41f75 478 /* Insert new data */
bryantaylor 0:eafc3fd41f75 479 for (uint8_t idx = 0; idx < len; idx++) {
bryantaylor 0:eafc3fd41f75 480 field[2 + idx] = payload[idx];
bryantaylor 0:eafc3fd41f75 481 }
bryantaylor 0:eafc3fd41f75 482
bryantaylor 0:eafc3fd41f75 483 /* Increment lengths */
bryantaylor 0:eafc3fd41f75 484 field[0] += len;
bryantaylor 0:eafc3fd41f75 485 _payloadLen += len;
bryantaylor 0:eafc3fd41f75 486
bryantaylor 0:eafc3fd41f75 487 result = BLE_ERROR_NONE;
bryantaylor 0:eafc3fd41f75 488 }
bryantaylor 0:eafc3fd41f75 489
bryantaylor 0:eafc3fd41f75 490 break;
bryantaylor 0:eafc3fd41f75 491 }
bryantaylor 0:eafc3fd41f75 492 /* These fields will be overwritten with the new value */
bryantaylor 0:eafc3fd41f75 493 default: {
bryantaylor 0:eafc3fd41f75 494 result = updateField(advDataType, payload, len, field);
bryantaylor 0:eafc3fd41f75 495
bryantaylor 0:eafc3fd41f75 496 break;
bryantaylor 0:eafc3fd41f75 497 }
bryantaylor 0:eafc3fd41f75 498 }
bryantaylor 0:eafc3fd41f75 499
bryantaylor 0:eafc3fd41f75 500 return result;
bryantaylor 0:eafc3fd41f75 501 }
bryantaylor 0:eafc3fd41f75 502
bryantaylor 0:eafc3fd41f75 503 /**
bryantaylor 0:eafc3fd41f75 504 * Given the a pointer to a field in the advertising payload it replaces
bryantaylor 0:eafc3fd41f75 505 * the existing data in the field with the supplied data.
bryantaylor 0:eafc3fd41f75 506 *
bryantaylor 0:eafc3fd41f75 507 * @param[in] advDataType
bryantaylor 0:eafc3fd41f75 508 * The type of the data to be updated.
bryantaylor 0:eafc3fd41f75 509 * @param[in] payload
bryantaylor 0:eafc3fd41f75 510 * A pointer to the data to be updated to the advertising
bryantaylor 0:eafc3fd41f75 511 * payload.
bryantaylor 0:eafc3fd41f75 512 * @param[in] len
bryantaylor 0:eafc3fd41f75 513 * The length of th data pointed to by @p payload.
bryantaylor 0:eafc3fd41f75 514 * @param[in] field
bryantaylor 0:eafc3fd41f75 515 * A pointer to the field of type @p advDataType in the
bryantaylor 0:eafc3fd41f75 516 * advertising buffer.
bryantaylor 0:eafc3fd41f75 517 *
bryantaylor 0:eafc3fd41f75 518 * @return BLE_ERROR_NONE on success.
bryantaylor 0:eafc3fd41f75 519 */
bryantaylor 0:eafc3fd41f75 520 ble_error_t updateField(DataType_t advDataType, const uint8_t *payload, uint8_t len, uint8_t* field)
bryantaylor 0:eafc3fd41f75 521 {
bryantaylor 0:eafc3fd41f75 522 ble_error_t result = BLE_ERROR_BUFFER_OVERFLOW;
bryantaylor 0:eafc3fd41f75 523 uint8_t dataLength = field[0] - 1;
bryantaylor 0:eafc3fd41f75 524
bryantaylor 0:eafc3fd41f75 525 /* New data has same length, do in-order replacement */
bryantaylor 0:eafc3fd41f75 526 if (len == dataLength) {
bryantaylor 0:eafc3fd41f75 527 for (uint8_t idx = 0; idx < dataLength; idx++) {
bryantaylor 0:eafc3fd41f75 528 field[2 + idx] = payload[idx];
bryantaylor 0:eafc3fd41f75 529 }
bryantaylor 0:eafc3fd41f75 530
bryantaylor 0:eafc3fd41f75 531 result = BLE_ERROR_NONE;
bryantaylor 0:eafc3fd41f75 532 } else {
bryantaylor 0:eafc3fd41f75 533 /* Check if data fits */
bryantaylor 0:eafc3fd41f75 534 if ((_payloadLen - dataLength + len) <= GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
bryantaylor 0:eafc3fd41f75 535
bryantaylor 0:eafc3fd41f75 536 /* Remove old field */
bryantaylor 0:eafc3fd41f75 537 while ((field + dataLength + 2) < &_payload[_payloadLen]) {
bryantaylor 0:eafc3fd41f75 538 *field = field[dataLength + 2];
bryantaylor 0:eafc3fd41f75 539 field++;
bryantaylor 0:eafc3fd41f75 540 }
bryantaylor 0:eafc3fd41f75 541
bryantaylor 0:eafc3fd41f75 542 /* Reduce length */
bryantaylor 0:eafc3fd41f75 543 _payloadLen -= dataLength + 2;
bryantaylor 0:eafc3fd41f75 544
bryantaylor 0:eafc3fd41f75 545 /* Add new field */
bryantaylor 0:eafc3fd41f75 546 result = appendField(advDataType, payload, len);
bryantaylor 0:eafc3fd41f75 547 }
bryantaylor 0:eafc3fd41f75 548 }
bryantaylor 0:eafc3fd41f75 549
bryantaylor 0:eafc3fd41f75 550 return result;
bryantaylor 0:eafc3fd41f75 551 }
bryantaylor 0:eafc3fd41f75 552
bryantaylor 0:eafc3fd41f75 553 /**
bryantaylor 0:eafc3fd41f75 554 * The advertising data buffer
bryantaylor 0:eafc3fd41f75 555 */
bryantaylor 0:eafc3fd41f75 556 uint8_t _payload[GAP_ADVERTISING_DATA_MAX_PAYLOAD];
bryantaylor 0:eafc3fd41f75 557 /**
bryantaylor 0:eafc3fd41f75 558 * The length of the data added to the advertising buffer.
bryantaylor 0:eafc3fd41f75 559 */
bryantaylor 0:eafc3fd41f75 560 uint8_t _payloadLen;
bryantaylor 0:eafc3fd41f75 561 /**
bryantaylor 0:eafc3fd41f75 562 * Appearance value.
bryantaylor 0:eafc3fd41f75 563 */
bryantaylor 0:eafc3fd41f75 564 uint16_t _appearance;
bryantaylor 0:eafc3fd41f75 565 };
bryantaylor 0:eafc3fd41f75 566
bryantaylor 0:eafc3fd41f75 567 #endif /* ifndef __GAP_ADVERTISING_DATA_H__ */