BLE_API_Tiny_BLE

Dependents:   CSSE4011_BLE_IMU

Fork of BLE_API by Bluetooth Low Energy

Committer:
rgrover1
Date:
Thu Dec 11 11:52:32 2014 +0000
Revision:
244:aa639ef2f290
Parent:
230:2c414d3240a8
Child:
257:7a50601356cc
Synchronized with git rev 709abe6a
Author: Rohit Grover
add BLEDevice::addToDisconnectionCallChain()

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rohit Grover 106:a20be740075d 1 /* mbed Microcontroller Library
Rohit Grover 106:a20be740075d 2 * Copyright (c) 2006-2013 ARM Limited
Rohit Grover 106:a20be740075d 3 *
Rohit Grover 106:a20be740075d 4 * Licensed under the Apache License, Version 2.0 (the "License");
Rohit Grover 106:a20be740075d 5 * you may not use this file except in compliance with the License.
Rohit Grover 106:a20be740075d 6 * You may obtain a copy of the License at
Rohit Grover 106:a20be740075d 7 *
Rohit Grover 106:a20be740075d 8 * http://www.apache.org/licenses/LICENSE-2.0
Rohit Grover 106:a20be740075d 9 *
Rohit Grover 106:a20be740075d 10 * Unless required by applicable law or agreed to in writing, software
Rohit Grover 106:a20be740075d 11 * distributed under the License is distributed on an "AS IS" BASIS,
Rohit Grover 106:a20be740075d 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Rohit Grover 106:a20be740075d 13 * See the License for the specific language governing permissions and
Rohit Grover 106:a20be740075d 14 * limitations under the License.
Rohit Grover 106:a20be740075d 15 */
Rohit Grover 106:a20be740075d 16
Rohit Grover 110:d5a824cee1d3 17 #ifndef __BLE_DEVICE__
Rohit Grover 110:d5a824cee1d3 18 #define __BLE_DEVICE__
Rohit Grover 110:d5a824cee1d3 19
rgrover1 227:5c4cb4553821 20 #include "blecommon.h"
Rohit Grover 106:a20be740075d 21 #include "Gap.h"
Rohit Grover 106:a20be740075d 22 #include "GattServer.h"
Rohit Grover 111:189ff241dae1 23 #include "BLEDeviceInstanceBase.h"
Rohit Grover 106:a20be740075d 24
Rohit Grover 106:a20be740075d 25 /**
Rohit Grover 106:a20be740075d 26 * The base class used to abstract away BLE capable radio transceivers or SOCs,
Rohit Grover 106:a20be740075d 27 * to enable this BLE API to work with any radio transparently.
Rohit Grover 106:a20be740075d 28 */
Rohit Grover 106:a20be740075d 29 class BLEDevice
Rohit Grover 106:a20be740075d 30 {
Rohit Grover 106:a20be740075d 31 public:
Rohit Grover 106:a20be740075d 32 /**
Rohit Grover 106:a20be740075d 33 * Initialize the BLE controller. This should be called before using
Rohit Grover 106:a20be740075d 34 * anything else in the BLE_API.
Rohit Grover 106:a20be740075d 35 */
Rohit Grover 106:a20be740075d 36 ble_error_t init();
Rohit Grover 106:a20be740075d 37 ble_error_t reset(void);
Rohit Grover 106:a20be740075d 38
rgrover1 230:2c414d3240a8 39 /**
rgrover1 230:2c414d3240a8 40 * Purge the BLE stack of GATT and GAP state. init() must be called afterwards to re-instate services and GAP state.
rgrover1 230:2c414d3240a8 41 */
rgrover1 230:2c414d3240a8 42 ble_error_t shutdown(void);
rgrover1 230:2c414d3240a8 43
Rohit Grover 106:a20be740075d 44 /* GAP specific APIs */
Rohit Grover 106:a20be740075d 45 public:
Rohit Grover 106:a20be740075d 46 /**
Rohit Grover 106:a20be740075d 47 * Set the BTLE MAC address and type.
Rohit Grover 123:fede41ce9407 48 * @return BLE_ERROR_NONE on success.
Rohit Grover 106:a20be740075d 49 */
rgrover1 140:407d134c179d 50 ble_error_t setAddress(Gap::addr_type_t type, const Gap::address_t address);
Rohit Grover 123:fede41ce9407 51
Rohit Grover 123:fede41ce9407 52 /**
Rohit Grover 123:fede41ce9407 53 * Fetch the BTLE MAC address and type.
Rohit Grover 123:fede41ce9407 54 * @return BLE_ERROR_NONE on success.
Rohit Grover 123:fede41ce9407 55 */
rgrover1 140:407d134c179d 56 ble_error_t getAddress(Gap::addr_type_t *typeP, Gap::address_t address);
Rohit Grover 106:a20be740075d 57
Rohit Grover 106:a20be740075d 58 /**
Rohit Grover 106:a20be740075d 59 * @param[in] advType
Rohit Grover 106:a20be740075d 60 * The GAP advertising mode to use for this device. Valid
Rohit Grover 106:a20be740075d 61 * values are defined in AdvertisingType:
Rohit Grover 106:a20be740075d 62 *
Rohit Grover 106:a20be740075d 63 * \par ADV_NON_CONNECTABLE_UNDIRECTED
Rohit Grover 106:a20be740075d 64 * All connections to the peripheral device will be refused.
Rohit Grover 106:a20be740075d 65 *
Rohit Grover 106:a20be740075d 66 * \par ADV_CONNECTABLE_DIRECTED
Rohit Grover 106:a20be740075d 67 * Only connections from a pre-defined central device will be
Rohit Grover 106:a20be740075d 68 * accepted.
Rohit Grover 106:a20be740075d 69 *
Rohit Grover 106:a20be740075d 70 * \par ADV_CONNECTABLE_UNDIRECTED
Rohit Grover 106:a20be740075d 71 * Any central device can connect to this peripheral.
Rohit Grover 106:a20be740075d 72 *
Rohit Grover 106:a20be740075d 73 * \par ADV_SCANNABLE_UNDIRECTED
Rohit Grover 106:a20be740075d 74 * Any central device can connect to this peripheral, and
Rohit Grover 106:a20be740075d 75 * the secondary Scan Response payload will be included or
Rohit Grover 106:a20be740075d 76 * available to central devices.
Rohit Grover 106:a20be740075d 77 *
Rohit Grover 106:a20be740075d 78 * \par
Rohit Grover 106:a20be740075d 79 * See Bluetooth Core Specification 4.0 (Vol. 3), Part C,
Rohit Grover 106:a20be740075d 80 * Section 9.3 and Core Specification 4.0 (Vol. 6), Part B,
Rohit Grover 106:a20be740075d 81 * Section 2.3.1 for further information on GAP connection
Rohit Grover 106:a20be740075d 82 * modes
Rohit Grover 106:a20be740075d 83 */
Rohit Grover 106:a20be740075d 84 void setAdvertisingType(GapAdvertisingParams::AdvertisingType);
Rohit Grover 106:a20be740075d 85
Rohit Grover 106:a20be740075d 86 /**
Rohit Grover 106:a20be740075d 87 * @param[in] interval
Rohit Grover 106:a20be740075d 88 * Advertising interval between 0x0020 and 0x4000 in 0.625ms
Rohit Grover 106:a20be740075d 89 * units (20ms to 10.24s). If using non-connectable mode
Rohit Grover 106:a20be740075d 90 * (ADV_NON_CONNECTABLE_UNDIRECTED) this min value is
Rohit Grover 106:a20be740075d 91 * 0x00A0 (100ms). To reduce the likelihood of collisions, the
Rohit Grover 106:a20be740075d 92 * link layer perturbs this interval by a pseudo-random delay
Rohit Grover 106:a20be740075d 93 * with a range of 0 ms to 10 ms for each advertising event.
Rohit Grover 106:a20be740075d 94 *
Rohit Grover 106:a20be740075d 95 * \par
Rohit Grover 106:a20be740075d 96 * Decreasing this value will allow central devices to detect
Rohit Grover 106:a20be740075d 97 * your peripheral faster at the expense of more power being
Rohit Grover 106:a20be740075d 98 * used by the radio due to the higher data transmit rate.
Rohit Grover 106:a20be740075d 99 *
Rohit Grover 106:a20be740075d 100 * \par
Rohit Grover 106:a20be740075d 101 * This field must be set to 0 if connectionMode is equal
Rohit Grover 106:a20be740075d 102 * to ADV_CONNECTABLE_DIRECTED
Rohit Grover 106:a20be740075d 103 *
Rohit Grover 106:a20be740075d 104 * \par
Rohit Grover 106:a20be740075d 105 * See Bluetooth Core Specification, Vol 3., Part C,
Rohit Grover 106:a20be740075d 106 * Appendix A for suggested advertising intervals.
Rohit Grover 106:a20be740075d 107 */
Rohit Grover 106:a20be740075d 108 void setAdvertisingInterval(uint16_t interval);
Rohit Grover 106:a20be740075d 109
Rohit Grover 106:a20be740075d 110 /**
Rohit Grover 106:a20be740075d 111 * @param[in] timeout
Rohit Grover 106:a20be740075d 112 * Advertising timeout between 0x1 and 0x3FFF (1 and 16383)
Rohit Grover 106:a20be740075d 113 * in seconds. Enter 0 to disable the advertising timeout.
Rohit Grover 106:a20be740075d 114 */
Rohit Grover 106:a20be740075d 115 void setAdvertisingTimeout(uint16_t timeout);
Rohit Grover 106:a20be740075d 116
Rohit Grover 106:a20be740075d 117 /**
Rohit Grover 106:a20be740075d 118 * Please refer to the APIs above.
Rohit Grover 106:a20be740075d 119 */
Rohit Grover 106:a20be740075d 120 void setAdvertisingParams(const GapAdvertisingParams &advParams);
Rohit Grover 106:a20be740075d 121
Rohit Grover 106:a20be740075d 122 /**
Rohit Grover 106:a20be740075d 123 * This API is typically used as an internal helper to udpate the transport
Rohit Grover 106:a20be740075d 124 * backend with advertising data before starting to advertise. It may also
Rohit Grover 106:a20be740075d 125 * be explicity used to dynamically reset the accumulated advertising
Rohit Grover 106:a20be740075d 126 * payload and scanResponse; to do this, the application can clear and re-
Rohit Grover 106:a20be740075d 127 * accumulate a new advertising payload (and scanResponse) before using this
Rohit Grover 106:a20be740075d 128 * API.
Rohit Grover 106:a20be740075d 129 */
Rohit Grover 106:a20be740075d 130 ble_error_t setAdvertisingPayload(void);
Rohit Grover 106:a20be740075d 131
Rohit Grover 106:a20be740075d 132 /**
Rohit Grover 106:a20be740075d 133 * Reset any advertising payload prepared from prior calls to
Rohit Grover 106:a20be740075d 134 * accumulateAdvertisingPayload().
Rohit Grover 106:a20be740075d 135 */
Rohit Grover 106:a20be740075d 136 void clearAdvertisingPayload(void);
Rohit Grover 106:a20be740075d 137
Rohit Grover 106:a20be740075d 138 /**
Rohit Grover 106:a20be740075d 139 * Accumulate an AD structure in the advertising payload. Please note that
Rohit Grover 106:a20be740075d 140 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
Rohit Grover 106:a20be740075d 141 * as an additional 31 bytes if the advertising payload proves to be too
Rohit Grover 106:a20be740075d 142 * small.
Rohit Grover 106:a20be740075d 143 *
Rohit Grover 106:a20be740075d 144 * @param flags
Rohit Grover 106:a20be740075d 145 * The flags to be added. Multiple flags may be specified in
Rohit Grover 106:a20be740075d 146 * combination.
Rohit Grover 106:a20be740075d 147 */
Rohit Grover 106:a20be740075d 148 ble_error_t accumulateAdvertisingPayload(uint8_t flags);
Rohit Grover 106:a20be740075d 149
Rohit Grover 106:a20be740075d 150 /**
Rohit Grover 106:a20be740075d 151 * Accumulate an AD structure in the advertising payload. Please note that
Rohit Grover 106:a20be740075d 152 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
Rohit Grover 106:a20be740075d 153 * as an additional 31 bytes if the advertising payload proves to be too
Rohit Grover 106:a20be740075d 154 * small.
Rohit Grover 106:a20be740075d 155 *
Rohit Grover 106:a20be740075d 156 * @param app
Rohit Grover 106:a20be740075d 157 * The appearance of the peripheral.
Rohit Grover 106:a20be740075d 158 */
Rohit Grover 106:a20be740075d 159 ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::Appearance app);
Rohit Grover 106:a20be740075d 160
Rohit Grover 106:a20be740075d 161 /**
Rohit Grover 106:a20be740075d 162 * Accumulate an AD structure in the advertising payload. Please note that
Rohit Grover 106:a20be740075d 163 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
Rohit Grover 106:a20be740075d 164 * as an additional 31 bytes if the advertising payload proves to be too
Rohit Grover 106:a20be740075d 165 * small.
Rohit Grover 106:a20be740075d 166 *
Rohit Grover 106:a20be740075d 167 * @param app
Rohit Grover 106:a20be740075d 168 * The max transmit power to be used by the controller. This is
Rohit Grover 106:a20be740075d 169 * only a hint.
Rohit Grover 106:a20be740075d 170 */
Rohit Grover 106:a20be740075d 171 ble_error_t accumulateAdvertisingPayloadTxPower(int8_t power);
Rohit Grover 106:a20be740075d 172
Rohit Grover 106:a20be740075d 173 /**
Rohit Grover 106:a20be740075d 174 * Accumulate a variable length byte-stream as an AD structure in the
Rohit Grover 106:a20be740075d 175 * advertising payload. Please note that the payload is limited to 31 bytes.
Rohit Grover 106:a20be740075d 176 * The SCAN_RESPONSE message may be used as an additional 31 bytes if the
Rohit Grover 106:a20be740075d 177 * advertising payload proves to be too small.
Rohit Grover 106:a20be740075d 178 *
Rohit Grover 106:a20be740075d 179 * @param type The type which describes the variable length data.
Rohit Grover 106:a20be740075d 180 * @param data data bytes.
Rohit Grover 106:a20be740075d 181 * @param len length of data.
Rohit Grover 106:a20be740075d 182 */
Rohit Grover 106:a20be740075d 183 ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len);
Rohit Grover 106:a20be740075d 184
Rohit Grover 106:a20be740075d 185 /**
Rohit Grover 106:a20be740075d 186 * Accumulate a variable length byte-stream as an AD structure in the
Rohit Grover 106:a20be740075d 187 * scanResponse payload.
Rohit Grover 106:a20be740075d 188 *
Rohit Grover 106:a20be740075d 189 * @param type The type which describes the variable length data.
Rohit Grover 106:a20be740075d 190 * @param data data bytes.
Rohit Grover 106:a20be740075d 191 * @param len length of data.
Rohit Grover 106:a20be740075d 192 */
Rohit Grover 106:a20be740075d 193 ble_error_t accumulateScanResponse(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len);
Rohit Grover 106:a20be740075d 194
Rohit Grover 106:a20be740075d 195 /**
Rohit Grover 106:a20be740075d 196 * Start advertising (GAP Discoverable, Connectable modes, Broadcast
Rohit Grover 106:a20be740075d 197 * Procedure).
Rohit Grover 106:a20be740075d 198 */
Rohit Grover 106:a20be740075d 199 ble_error_t startAdvertising(void);
Rohit Grover 106:a20be740075d 200
Rohit Grover 106:a20be740075d 201 /**
Rohit Grover 106:a20be740075d 202 * Stop advertising (GAP Discoverable, Connectable modes, Broadcast
Rohit Grover 106:a20be740075d 203 * Procedure).
Rohit Grover 106:a20be740075d 204 */
Rohit Grover 106:a20be740075d 205 ble_error_t stopAdvertising(void);
Rohit Grover 106:a20be740075d 206
Rohit Grover 116:ca826083980e 207 ble_error_t disconnect(Gap::DisconnectionReason_t reason);
Rohit Grover 106:a20be740075d 208
Rohit Grover 106:a20be740075d 209 /* APIs to set GAP callbacks. */
Rohit Grover 106:a20be740075d 210 void onTimeout(Gap::EventCallback_t timeoutCallback);
Rohit Grover 106:a20be740075d 211
Rohit Grover 116:ca826083980e 212 void onConnection(Gap::ConnectionEventCallback_t connectionCallback);
Rohit Grover 106:a20be740075d 213 /**
Rohit Grover 106:a20be740075d 214 * Used to setup a callback for GAP disconnection.
Rohit Grover 106:a20be740075d 215 */
Rohit Grover 116:ca826083980e 216 void onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback);
Rohit Grover 106:a20be740075d 217
Rohit Grover 106:a20be740075d 218 /**
rgrover1 244:aa639ef2f290 219 * Append to a chain of callbacks to be invoked upon disconnection; these
rgrover1 244:aa639ef2f290 220 * callbacks receive no context and are therefore different from the
rgrover1 244:aa639ef2f290 221 * onDisconnection callback.
rgrover1 244:aa639ef2f290 222 */
rgrover1 244:aa639ef2f290 223 template<typename T>
rgrover1 244:aa639ef2f290 224 void addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void));
rgrover1 244:aa639ef2f290 225
rgrover1 244:aa639ef2f290 226 /**
Rohit Grover 106:a20be740075d 227 * Setup a callback for the GATT event DATA_SENT.
Rohit Grover 106:a20be740075d 228 */
Rohit Grover 116:ca826083980e 229 void onDataSent(GattServer::ServerEventCallbackWithCount_t callback);
Rohit Grover 106:a20be740075d 230
Rohit Grover 106:a20be740075d 231 /**
Rohit Grover 106:a20be740075d 232 * Setup a callback for when a characteristic has its value updated by a
Rohit Grover 106:a20be740075d 233 * client.
Rohit Grover 118:620d28e7a1ba 234 *
Rohit Grover 118:620d28e7a1ba 235 * @Note: it is possible to chain together multiple onDataWritten callbacks
Rohit Grover 118:620d28e7a1ba 236 * (potentially from different modules of an application) to receive updates
Rohit Grover 118:620d28e7a1ba 237 * to characteristics. Many services, such as DFU and UART add their own
Rohit Grover 118:620d28e7a1ba 238 * onDataWritten callbacks behind the scenes to trap interesting events.
Rohit Grover 118:620d28e7a1ba 239 *
Rohit Grover 118:620d28e7a1ba 240 * @Note: it is also possible to setup a callback into a member function of
Rohit Grover 118:620d28e7a1ba 241 * some object.
Rohit Grover 106:a20be740075d 242 */
Rohit Grover 118:620d28e7a1ba 243 void onDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP));
rgrover1 140:407d134c179d 244 template <typename T> void onDataWritten(T * objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context));
Rohit Grover 118:620d28e7a1ba 245
Rohit Grover 106:a20be740075d 246 void onUpdatesEnabled(GattServer::EventCallback_t callback);
Rohit Grover 106:a20be740075d 247 void onUpdatesDisabled(GattServer::EventCallback_t callback);
Rohit Grover 106:a20be740075d 248 void onConfirmationReceived(GattServer::EventCallback_t callback);
Rohit Grover 106:a20be740075d 249
Rohit Grover 106:a20be740075d 250 /**
Rohit Grover 106:a20be740075d 251 * Add a service declaration to the local server ATT table. Also add the
Rohit Grover 106:a20be740075d 252 * characteristics contained within.
Rohit Grover 106:a20be740075d 253 */
Rohit Grover 106:a20be740075d 254 ble_error_t addService(GattService &service);
Rohit Grover 106:a20be740075d 255
Rohit Grover 106:a20be740075d 256 Gap::GapState_t getGapState(void) const;
Rohit Grover 106:a20be740075d 257
Rohit Grover 118:620d28e7a1ba 258 /**
Rohit Grover 118:620d28e7a1ba 259 * @param[in/out] lengthP
Rohit Grover 118:620d28e7a1ba 260 * input: Length in bytes to be read,
Rohit Grover 118:620d28e7a1ba 261 * output: Total length of attribute value upon successful return.
Rohit Grover 118:620d28e7a1ba 262 */
Rohit Grover 106:a20be740075d 263 ble_error_t readCharacteristicValue(uint16_t handle, uint8_t *const buffer, uint16_t *const lengthP);
Rohit Grover 118:620d28e7a1ba 264
Rohit Grover 118:620d28e7a1ba 265 /**
Rohit Grover 118:620d28e7a1ba 266 * @param localOnly
Rohit Grover 118:620d28e7a1ba 267 * Only update the characteristic locally regardless of notify/indicate flags in the CCCD.
Rohit Grover 118:620d28e7a1ba 268 */
rgrover1 140:407d134c179d 269 ble_error_t updateCharacteristicValue(uint16_t handle, const uint8_t *value, uint16_t size, bool localOnly = false);
Rohit Grover 106:a20be740075d 270
Rohit Grover 106:a20be740075d 271 /**
Rohit Grover 106:a20be740075d 272 * Yield control to the BLE stack or to other tasks waiting for events. This
Rohit Grover 106:a20be740075d 273 * is a sleep function which will return when there is an application
Rohit Grover 106:a20be740075d 274 * specific interrupt, but the MCU might wake up several times before
Rohit Grover 106:a20be740075d 275 * returning (to service the stack). This is not always interchangeable with
Rohit Grover 106:a20be740075d 276 * WFE().
Rohit Grover 106:a20be740075d 277 */
Rohit Grover 106:a20be740075d 278 void waitForEvent(void);
Rohit Grover 106:a20be740075d 279
Rohit Grover 106:a20be740075d 280 ble_error_t getPreferredConnectionParams(Gap::ConnectionParams_t *params);
Rohit Grover 106:a20be740075d 281 ble_error_t setPreferredConnectionParams(const Gap::ConnectionParams_t *params);
Rohit Grover 106:a20be740075d 282 ble_error_t updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params);
Rohit Grover 108:c85ab5f1eca0 283
Rohit Grover 108:c85ab5f1eca0 284 /**
Rohit Grover 108:c85ab5f1eca0 285 * This call allows the application to get the BLE stack version information.
Rohit Grover 108:c85ab5f1eca0 286 *
Rohit Grover 108:c85ab5f1eca0 287 * @return A pointer to a const string representing the version.
Rohit Grover 108:c85ab5f1eca0 288 * Note: The string is owned by the BLE_API.
Rohit Grover 108:c85ab5f1eca0 289 */
Rohit Grover 108:c85ab5f1eca0 290 const char *getVersion(void);
Rohit Grover 108:c85ab5f1eca0 291
rgrover1 140:407d134c179d 292 /**
rgrover1 140:407d134c179d 293 * Set the device name characteristic in the GAP service.
rgrover1 140:407d134c179d 294 * @param deviceName The new value for the device-name. This is a UTF-8 encoded, <b>NULL-terminated</b> string.
rgrover1 140:407d134c179d 295 */
rgrover1 140:407d134c179d 296 ble_error_t setDeviceName(const uint8_t *deviceName);
Rohit Grover 108:c85ab5f1eca0 297
rgrover1 140:407d134c179d 298 /**
rgrover1 140:407d134c179d 299 * Get the value of the device name characteristic in the GAP service.
rgrover1 140:407d134c179d 300 * @param[out] deviceName Pointer to an empty buffer where the UTF-8 *non NULL-
rgrover1 140:407d134c179d 301 * terminated* string will be placed. Set this
rgrover1 140:407d134c179d 302 * value to NULL in order to obtain the deviceName-length
rgrover1 140:407d134c179d 303 * from the 'length' parameter.
rgrover1 140:407d134c179d 304 *
rgrover1 140:407d134c179d 305 * @param[in/out] lengthP (on input) Length of the buffer pointed to by deviceName;
rgrover1 140:407d134c179d 306 * (on output) the complete device name length (without the
rgrover1 140:407d134c179d 307 * null terminator).
rgrover1 140:407d134c179d 308 *
rgrover1 140:407d134c179d 309 * @note If the device name is longer than the size of the supplied buffer,
rgrover1 140:407d134c179d 310 * length will return the complete device name length,
rgrover1 140:407d134c179d 311 * and not the number of bytes actually returned in deviceName.
rgrover1 140:407d134c179d 312 * The application may use this information to retry with a suitable buffer size.
rgrover1 140:407d134c179d 313 *
rgrover1 140:407d134c179d 314 * Sample use:
rgrover1 140:407d134c179d 315 * uint8_t deviceName[20];
rgrover1 140:407d134c179d 316 * unsigned length = sizeof(deviceName);
rgrover1 140:407d134c179d 317 * ble.getDeviceName(deviceName, &length);
rgrover1 140:407d134c179d 318 * if (length < sizeof(deviceName)) {
rgrover1 140:407d134c179d 319 * deviceName[length] = 0;
rgrover1 140:407d134c179d 320 * }
rgrover1 140:407d134c179d 321 * DEBUG("length: %u, deviceName: %s\r\n", length, deviceName);
rgrover1 140:407d134c179d 322 */
rgrover1 140:407d134c179d 323 ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP);
Rohit Grover 108:c85ab5f1eca0 324
rgrover1 140:407d134c179d 325 /**
rgrover1 140:407d134c179d 326 * Set the appearance characteristic in the GAP service.
rgrover1 140:407d134c179d 327 * @param[in] appearance The new value for the device-appearance.
rgrover1 140:407d134c179d 328 */
rgrover1 140:407d134c179d 329 ble_error_t setAppearance(uint16_t appearance);
Rohit Grover 108:c85ab5f1eca0 330
rgrover1 140:407d134c179d 331 /**
rgrover1 140:407d134c179d 332 * Set the appearance characteristic in the GAP service.
rgrover1 140:407d134c179d 333 * @param[out] appearance The new value for the device-appearance.
rgrover1 140:407d134c179d 334 */
rgrover1 140:407d134c179d 335 ble_error_t getAppearance(uint16_t *appearanceP);
Rohit Grover 108:c85ab5f1eca0 336
rgrover1 140:407d134c179d 337 /**
rgrover1 140:407d134c179d 338 * Set the radio's transmit power.
rgrover1 140:407d134c179d 339 * @param[in] txPower Radio transmit power in dBm.
rgrover1 140:407d134c179d 340 */
rgrover1 140:407d134c179d 341 ble_error_t setTxPower(int8_t txPower);
Rohit Grover 106:a20be740075d 342
Rohit Grover 106:a20be740075d 343 public:
Rohit Grover 106:a20be740075d 344 BLEDevice() : transport(createBLEDeviceInstance()), advParams(), advPayload(), scanResponse(), needToSetAdvPayload(true) {
Rohit Grover 106:a20be740075d 345 advPayload.clear();
Rohit Grover 106:a20be740075d 346 scanResponse.clear();
Rohit Grover 106:a20be740075d 347 }
Rohit Grover 106:a20be740075d 348
Rohit Grover 106:a20be740075d 349 private:
Rohit Grover 106:a20be740075d 350 BLEDeviceInstanceBase *const transport; /* the device specific backend */
Rohit Grover 106:a20be740075d 351
Rohit Grover 106:a20be740075d 352 GapAdvertisingParams advParams;
Rohit Grover 106:a20be740075d 353 GapAdvertisingData advPayload;
Rohit Grover 106:a20be740075d 354 GapAdvertisingData scanResponse;
Rohit Grover 106:a20be740075d 355
Rohit Grover 106:a20be740075d 356 /* Accumulation of AD structures in the advertisement payload should
Rohit Grover 106:a20be740075d 357 * eventually result in a call to the target's setAdvertisingData() before
Rohit Grover 106:a20be740075d 358 * the server begins advertising. This flag marks the status of the pending update.*/
Rohit Grover 106:a20be740075d 359 bool needToSetAdvPayload;
Rohit Grover 106:a20be740075d 360
Rohit Grover 106:a20be740075d 361 /**
Rohit Grover 106:a20be740075d 362 * DEPRECATED
Rohit Grover 106:a20be740075d 363 */
Rohit Grover 106:a20be740075d 364 public:
Rohit Grover 106:a20be740075d 365 ble_error_t setAdvertisingData(const GapAdvertisingData &ADStructures, const GapAdvertisingData &scanResponse);
Rohit Grover 106:a20be740075d 366 ble_error_t setAdvertisingData(const GapAdvertisingData &ADStructures);
Rohit Grover 106:a20be740075d 367
Rohit Grover 106:a20be740075d 368 ble_error_t startAdvertising(const GapAdvertisingParams &advParams);
Rohit Grover 106:a20be740075d 369 };
Rohit Grover 106:a20be740075d 370
Rohit Grover 106:a20be740075d 371 /* BLEDevice methods. Most of these simply forward the calls to the underlying
Rohit Grover 106:a20be740075d 372 * transport.*/
Rohit Grover 106:a20be740075d 373
Rohit Grover 106:a20be740075d 374 inline ble_error_t
Rohit Grover 106:a20be740075d 375 BLEDevice::reset(void)
Rohit Grover 106:a20be740075d 376 {
Rohit Grover 106:a20be740075d 377 return transport->reset();
Rohit Grover 106:a20be740075d 378 }
Rohit Grover 106:a20be740075d 379
Rohit Grover 106:a20be740075d 380 inline ble_error_t
rgrover1 230:2c414d3240a8 381 BLEDevice::shutdown(void)
rgrover1 230:2c414d3240a8 382 {
rgrover1 230:2c414d3240a8 383 clearAdvertisingPayload();
rgrover1 230:2c414d3240a8 384 return transport->shutdown();
rgrover1 230:2c414d3240a8 385 }
rgrover1 230:2c414d3240a8 386
rgrover1 230:2c414d3240a8 387 inline ble_error_t
rgrover1 140:407d134c179d 388 BLEDevice::setAddress(Gap::addr_type_t type, const Gap::address_t address)
Rohit Grover 106:a20be740075d 389 {
Rohit Grover 106:a20be740075d 390 return transport->getGap().setAddress(type, address);
Rohit Grover 106:a20be740075d 391 }
Rohit Grover 106:a20be740075d 392
Rohit Grover 123:fede41ce9407 393 inline ble_error_t
rgrover1 140:407d134c179d 394 BLEDevice::getAddress(Gap::addr_type_t *typeP, Gap::address_t address)
Rohit Grover 123:fede41ce9407 395 {
Rohit Grover 123:fede41ce9407 396 return transport->getGap().getAddress(typeP, address);
Rohit Grover 123:fede41ce9407 397 }
Rohit Grover 123:fede41ce9407 398
Rohit Grover 106:a20be740075d 399 inline void
Rohit Grover 106:a20be740075d 400 BLEDevice::setAdvertisingType(GapAdvertisingParams::AdvertisingType advType)
Rohit Grover 106:a20be740075d 401 {
Rohit Grover 106:a20be740075d 402 advParams.setAdvertisingType(advType);
Rohit Grover 106:a20be740075d 403 }
Rohit Grover 106:a20be740075d 404
Rohit Grover 106:a20be740075d 405 inline void
Rohit Grover 106:a20be740075d 406 BLEDevice::setAdvertisingInterval(uint16_t interval)
Rohit Grover 106:a20be740075d 407 {
Rohit Grover 106:a20be740075d 408 advParams.setInterval(interval);
Rohit Grover 106:a20be740075d 409 }
Rohit Grover 106:a20be740075d 410
Rohit Grover 106:a20be740075d 411 inline void
Rohit Grover 106:a20be740075d 412 BLEDevice::setAdvertisingTimeout(uint16_t timeout)
Rohit Grover 106:a20be740075d 413 {
Rohit Grover 106:a20be740075d 414 advParams.setTimeout(timeout);
Rohit Grover 106:a20be740075d 415 }
Rohit Grover 106:a20be740075d 416
Rohit Grover 106:a20be740075d 417 inline void
Rohit Grover 106:a20be740075d 418 BLEDevice::setAdvertisingParams(const GapAdvertisingParams &newAdvParams)
Rohit Grover 106:a20be740075d 419 {
Rohit Grover 106:a20be740075d 420 advParams = newAdvParams;
Rohit Grover 106:a20be740075d 421 }
Rohit Grover 106:a20be740075d 422
Rohit Grover 106:a20be740075d 423 inline void
Rohit Grover 106:a20be740075d 424 BLEDevice::clearAdvertisingPayload(void)
Rohit Grover 106:a20be740075d 425 {
Rohit Grover 106:a20be740075d 426 needToSetAdvPayload = true;
Rohit Grover 106:a20be740075d 427 advPayload.clear();
Rohit Grover 106:a20be740075d 428 }
Rohit Grover 106:a20be740075d 429
Rohit Grover 106:a20be740075d 430 inline ble_error_t
Rohit Grover 106:a20be740075d 431 BLEDevice::accumulateAdvertisingPayload(uint8_t flags)
Rohit Grover 106:a20be740075d 432 {
Rohit Grover 106:a20be740075d 433 needToSetAdvPayload = true;
Rohit Grover 106:a20be740075d 434 return advPayload.addFlags(flags);
Rohit Grover 106:a20be740075d 435 }
Rohit Grover 106:a20be740075d 436
Rohit Grover 106:a20be740075d 437 inline ble_error_t
Rohit Grover 106:a20be740075d 438 BLEDevice::accumulateAdvertisingPayload(GapAdvertisingData::Appearance app)
Rohit Grover 106:a20be740075d 439 {
Rohit Grover 106:a20be740075d 440 needToSetAdvPayload = true;
rgrover1 140:407d134c179d 441 transport->getGap().setAppearance(app);
Rohit Grover 106:a20be740075d 442 return advPayload.addAppearance(app);
Rohit Grover 106:a20be740075d 443 }
Rohit Grover 106:a20be740075d 444
Rohit Grover 106:a20be740075d 445 inline ble_error_t
Rohit Grover 106:a20be740075d 446 BLEDevice::accumulateAdvertisingPayloadTxPower(int8_t txPower)
Rohit Grover 106:a20be740075d 447 {
Rohit Grover 106:a20be740075d 448 needToSetAdvPayload = true;
Rohit Grover 106:a20be740075d 449 return advPayload.addTxPower(txPower);
Rohit Grover 106:a20be740075d 450 }
Rohit Grover 106:a20be740075d 451
Rohit Grover 106:a20be740075d 452 inline ble_error_t
Rohit Grover 106:a20be740075d 453 BLEDevice::accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len)
Rohit Grover 106:a20be740075d 454 {
Rohit Grover 106:a20be740075d 455 needToSetAdvPayload = true;
rgrover1 140:407d134c179d 456 if (type == GapAdvertisingData::COMPLETE_LOCAL_NAME) {
rgrover1 140:407d134c179d 457 transport->getGap().setDeviceName(data);
rgrover1 140:407d134c179d 458 }
Rohit Grover 106:a20be740075d 459 return advPayload.addData(type, data, len);
Rohit Grover 106:a20be740075d 460 }
Rohit Grover 106:a20be740075d 461
Rohit Grover 106:a20be740075d 462 inline ble_error_t
Rohit Grover 106:a20be740075d 463 BLEDevice::accumulateScanResponse(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len)
Rohit Grover 106:a20be740075d 464 {
Rohit Grover 106:a20be740075d 465 needToSetAdvPayload = true;
Rohit Grover 106:a20be740075d 466 return scanResponse.addData(type, data, len);
Rohit Grover 106:a20be740075d 467 }
Rohit Grover 106:a20be740075d 468
Rohit Grover 106:a20be740075d 469 inline ble_error_t
Rohit Grover 106:a20be740075d 470 BLEDevice::setAdvertisingPayload(void) {
Rohit Grover 106:a20be740075d 471 needToSetAdvPayload = false;
Rohit Grover 106:a20be740075d 472 return transport->getGap().setAdvertisingData(advPayload, scanResponse);
Rohit Grover 106:a20be740075d 473 }
Rohit Grover 106:a20be740075d 474
Rohit Grover 106:a20be740075d 475 inline ble_error_t
Rohit Grover 106:a20be740075d 476 BLEDevice::startAdvertising(void)
Rohit Grover 106:a20be740075d 477 {
rgrover1 140:407d134c179d 478 ble_error_t rc;
rgrover1 140:407d134c179d 479 if ((rc = transport->getGattServer().initializeGATTDatabase()) != BLE_ERROR_NONE) {
rgrover1 140:407d134c179d 480 return rc;
rgrover1 140:407d134c179d 481 }
Rohit Grover 106:a20be740075d 482 if (needToSetAdvPayload) {
Rohit Grover 106:a20be740075d 483 if ((rc = setAdvertisingPayload()) != BLE_ERROR_NONE) {
Rohit Grover 106:a20be740075d 484 return rc;
Rohit Grover 106:a20be740075d 485 }
Rohit Grover 106:a20be740075d 486 }
Rohit Grover 106:a20be740075d 487
Rohit Grover 106:a20be740075d 488 return transport->getGap().startAdvertising(advParams);
Rohit Grover 106:a20be740075d 489 }
Rohit Grover 106:a20be740075d 490
Rohit Grover 106:a20be740075d 491 inline ble_error_t
Rohit Grover 106:a20be740075d 492 BLEDevice::stopAdvertising(void)
Rohit Grover 106:a20be740075d 493 {
Rohit Grover 106:a20be740075d 494 return transport->getGap().stopAdvertising();
Rohit Grover 106:a20be740075d 495 }
Rohit Grover 106:a20be740075d 496
Rohit Grover 106:a20be740075d 497 inline ble_error_t
Rohit Grover 116:ca826083980e 498 BLEDevice::disconnect(Gap::DisconnectionReason_t reason)
Rohit Grover 106:a20be740075d 499 {
Rohit Grover 116:ca826083980e 500 return transport->getGap().disconnect(reason);
Rohit Grover 106:a20be740075d 501 }
Rohit Grover 106:a20be740075d 502
Rohit Grover 106:a20be740075d 503 inline void
Rohit Grover 106:a20be740075d 504 BLEDevice::onTimeout(Gap::EventCallback_t timeoutCallback)
Rohit Grover 106:a20be740075d 505 {
Rohit Grover 106:a20be740075d 506 transport->getGap().setOnTimeout(timeoutCallback);
Rohit Grover 106:a20be740075d 507 }
Rohit Grover 106:a20be740075d 508
Rohit Grover 106:a20be740075d 509 inline void
Rohit Grover 116:ca826083980e 510 BLEDevice::onConnection(Gap::ConnectionEventCallback_t connectionCallback)
Rohit Grover 106:a20be740075d 511 {
Rohit Grover 106:a20be740075d 512 transport->getGap().setOnConnection(connectionCallback);
Rohit Grover 106:a20be740075d 513 }
Rohit Grover 106:a20be740075d 514
Rohit Grover 106:a20be740075d 515 inline void
Rohit Grover 116:ca826083980e 516 BLEDevice::onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback)
Rohit Grover 106:a20be740075d 517 {
Rohit Grover 106:a20be740075d 518 transport->getGap().setOnDisconnection(disconnectionCallback);
Rohit Grover 106:a20be740075d 519 }
Rohit Grover 106:a20be740075d 520
rgrover1 244:aa639ef2f290 521 template<typename T>
rgrover1 244:aa639ef2f290 522 inline void
rgrover1 244:aa639ef2f290 523 BLEDevice::addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)) {
rgrover1 244:aa639ef2f290 524 transport->getGap().addToDisconnectionCallChain(tptr, mptr);
rgrover1 244:aa639ef2f290 525 }
rgrover1 244:aa639ef2f290 526
Rohit Grover 106:a20be740075d 527 inline void
Rohit Grover 116:ca826083980e 528 BLEDevice::onDataSent(GattServer::ServerEventCallbackWithCount_t callback)
Rohit Grover 106:a20be740075d 529 {
Rohit Grover 106:a20be740075d 530 transport->getGattServer().setOnDataSent(callback);
Rohit Grover 106:a20be740075d 531 }
Rohit Grover 106:a20be740075d 532
Rohit Grover 106:a20be740075d 533 inline void
Rohit Grover 118:620d28e7a1ba 534 BLEDevice::onDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP)) {
Rohit Grover 106:a20be740075d 535 transport->getGattServer().setOnDataWritten(callback);
Rohit Grover 106:a20be740075d 536 }
Rohit Grover 106:a20be740075d 537
Rohit Grover 118:620d28e7a1ba 538 template <typename T> inline void
Rohit Grover 118:620d28e7a1ba 539 BLEDevice::onDataWritten(T *objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context)) {
Rohit Grover 118:620d28e7a1ba 540 transport->getGattServer().setOnDataWritten(objPtr, memberPtr);
Rohit Grover 118:620d28e7a1ba 541 }
Rohit Grover 118:620d28e7a1ba 542
Rohit Grover 106:a20be740075d 543 inline void
Rohit Grover 106:a20be740075d 544 BLEDevice::onUpdatesEnabled(GattServer::EventCallback_t callback)
Rohit Grover 106:a20be740075d 545 {
Rohit Grover 106:a20be740075d 546 transport->getGattServer().setOnUpdatesEnabled(callback);
Rohit Grover 106:a20be740075d 547 }
Rohit Grover 106:a20be740075d 548
Rohit Grover 106:a20be740075d 549 inline void
Rohit Grover 106:a20be740075d 550 BLEDevice::onUpdatesDisabled(GattServer::EventCallback_t callback)
Rohit Grover 106:a20be740075d 551 {
Rohit Grover 106:a20be740075d 552 transport->getGattServer().setOnUpdatesDisabled(callback);
Rohit Grover 106:a20be740075d 553 }
Rohit Grover 106:a20be740075d 554
Rohit Grover 106:a20be740075d 555 inline void
Rohit Grover 106:a20be740075d 556 BLEDevice::onConfirmationReceived(GattServer::EventCallback_t callback)
Rohit Grover 106:a20be740075d 557 {
Rohit Grover 106:a20be740075d 558 transport->getGattServer().setOnConfirmationReceived(callback);
Rohit Grover 106:a20be740075d 559 }
Rohit Grover 106:a20be740075d 560
Rohit Grover 106:a20be740075d 561 inline ble_error_t
Rohit Grover 106:a20be740075d 562 BLEDevice::addService(GattService &service)
Rohit Grover 106:a20be740075d 563 {
Rohit Grover 106:a20be740075d 564 return transport->getGattServer().addService(service);
Rohit Grover 106:a20be740075d 565 }
Rohit Grover 106:a20be740075d 566
Rohit Grover 106:a20be740075d 567 inline Gap::GapState_t
Rohit Grover 106:a20be740075d 568 BLEDevice::getGapState(void) const
Rohit Grover 106:a20be740075d 569 {
Rohit Grover 106:a20be740075d 570 return transport->getGap().getState();
Rohit Grover 106:a20be740075d 571 }
Rohit Grover 106:a20be740075d 572
Rohit Grover 106:a20be740075d 573 inline ble_error_t BLEDevice::readCharacteristicValue(uint16_t handle, uint8_t *const buffer, uint16_t *const lengthP)
Rohit Grover 106:a20be740075d 574 {
Rohit Grover 106:a20be740075d 575 return transport->getGattServer().readValue(handle, buffer, lengthP);
Rohit Grover 106:a20be740075d 576 }
Rohit Grover 106:a20be740075d 577
Rohit Grover 106:a20be740075d 578 inline ble_error_t
rgrover1 140:407d134c179d 579 BLEDevice::updateCharacteristicValue(uint16_t handle, const uint8_t *value, uint16_t size, bool localOnly)
Rohit Grover 106:a20be740075d 580 {
Rohit Grover 106:a20be740075d 581 return transport->getGattServer().updateValue(handle, const_cast<uint8_t *>(value), size, localOnly);
Rohit Grover 106:a20be740075d 582 }
Rohit Grover 106:a20be740075d 583
Rohit Grover 106:a20be740075d 584 inline void
Rohit Grover 106:a20be740075d 585 BLEDevice::waitForEvent(void)
Rohit Grover 106:a20be740075d 586 {
Rohit Grover 106:a20be740075d 587 transport->waitForEvent();
Rohit Grover 106:a20be740075d 588 }
Rohit Grover 106:a20be740075d 589
Rohit Grover 106:a20be740075d 590 inline ble_error_t
Rohit Grover 106:a20be740075d 591 BLEDevice::getPreferredConnectionParams(Gap::ConnectionParams_t *params)
Rohit Grover 106:a20be740075d 592 {
Rohit Grover 106:a20be740075d 593 return transport->getGap().getPreferredConnectionParams(params);
Rohit Grover 106:a20be740075d 594 }
Rohit Grover 106:a20be740075d 595
Rohit Grover 106:a20be740075d 596 inline ble_error_t
Rohit Grover 106:a20be740075d 597 BLEDevice::setPreferredConnectionParams(const Gap::ConnectionParams_t *params)
Rohit Grover 106:a20be740075d 598 {
Rohit Grover 106:a20be740075d 599 return transport->getGap().setPreferredConnectionParams(params);
Rohit Grover 106:a20be740075d 600 }
Rohit Grover 106:a20be740075d 601
Rohit Grover 106:a20be740075d 602 inline ble_error_t
Rohit Grover 106:a20be740075d 603 BLEDevice::updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) {
Rohit Grover 106:a20be740075d 604 return transport->getGap().updateConnectionParams(handle, params);
Rohit Grover 106:a20be740075d 605 }
Rohit Grover 106:a20be740075d 606
Rohit Grover 108:c85ab5f1eca0 607 inline const char *
Rohit Grover 108:c85ab5f1eca0 608 BLEDevice::getVersion(void)
Rohit Grover 108:c85ab5f1eca0 609 {
Rohit Grover 108:c85ab5f1eca0 610 return transport->getVersion();
Rohit Grover 108:c85ab5f1eca0 611 }
Rohit Grover 108:c85ab5f1eca0 612
Rohit Grover 108:c85ab5f1eca0 613 inline ble_error_t
Rohit Grover 108:c85ab5f1eca0 614 BLEDevice::setDeviceName(const uint8_t *deviceName)
Rohit Grover 108:c85ab5f1eca0 615 {
Rohit Grover 116:ca826083980e 616 return transport->getGap().setDeviceName(deviceName);
Rohit Grover 108:c85ab5f1eca0 617 }
Rohit Grover 108:c85ab5f1eca0 618
Rohit Grover 108:c85ab5f1eca0 619 inline ble_error_t
Rohit Grover 108:c85ab5f1eca0 620 BLEDevice::getDeviceName(uint8_t *deviceName, unsigned *lengthP)
Rohit Grover 108:c85ab5f1eca0 621 {
Rohit Grover 116:ca826083980e 622 return transport->getGap().getDeviceName(deviceName, lengthP);
Rohit Grover 108:c85ab5f1eca0 623 }
Rohit Grover 108:c85ab5f1eca0 624
Rohit Grover 108:c85ab5f1eca0 625 inline ble_error_t
Rohit Grover 108:c85ab5f1eca0 626 BLEDevice::setAppearance(uint16_t appearance)
Rohit Grover 108:c85ab5f1eca0 627 {
Rohit Grover 116:ca826083980e 628 return transport->getGap().setAppearance(appearance);
Rohit Grover 108:c85ab5f1eca0 629 }
Rohit Grover 108:c85ab5f1eca0 630
Rohit Grover 108:c85ab5f1eca0 631 inline ble_error_t
Rohit Grover 108:c85ab5f1eca0 632 BLEDevice::getAppearance(uint16_t *appearanceP)
Rohit Grover 108:c85ab5f1eca0 633 {
Rohit Grover 116:ca826083980e 634 return transport->getGap().getAppearance(appearanceP);
Rohit Grover 108:c85ab5f1eca0 635 }
Rohit Grover 108:c85ab5f1eca0 636
Rohit Grover 108:c85ab5f1eca0 637 inline ble_error_t
Rohit Grover 108:c85ab5f1eca0 638 BLEDevice::setTxPower(int8_t txPower)
Rohit Grover 108:c85ab5f1eca0 639 {
Rohit Grover 108:c85ab5f1eca0 640 return transport->setTxPower(txPower);
Rohit Grover 108:c85ab5f1eca0 641 }
Rohit Grover 108:c85ab5f1eca0 642
Rohit Grover 106:a20be740075d 643 /*
Rohit Grover 106:a20be740075d 644 * ALL OF THE FOLLOWING METHODS ARE DEPRECATED
Rohit Grover 106:a20be740075d 645 */
Rohit Grover 106:a20be740075d 646
Rohit Grover 106:a20be740075d 647 inline ble_error_t
Rohit Grover 106:a20be740075d 648 BLEDevice::setAdvertisingData(const GapAdvertisingData &ADStructures, const GapAdvertisingData &scanResponse)
Rohit Grover 106:a20be740075d 649 {
Rohit Grover 106:a20be740075d 650 needToSetAdvPayload = false;
Rohit Grover 106:a20be740075d 651 return transport->getGap().setAdvertisingData(ADStructures, scanResponse);
Rohit Grover 106:a20be740075d 652 }
Rohit Grover 106:a20be740075d 653
Rohit Grover 106:a20be740075d 654 inline ble_error_t
Rohit Grover 106:a20be740075d 655 BLEDevice::setAdvertisingData(const GapAdvertisingData &ADStructures)
Rohit Grover 106:a20be740075d 656 {
Rohit Grover 106:a20be740075d 657 GapAdvertisingData scanResponse;
Rohit Grover 106:a20be740075d 658
Rohit Grover 106:a20be740075d 659 needToSetAdvPayload = false;
Rohit Grover 106:a20be740075d 660 return transport->getGap().setAdvertisingData(ADStructures, scanResponse);
Rohit Grover 106:a20be740075d 661 }
Rohit Grover 106:a20be740075d 662
Rohit Grover 106:a20be740075d 663 inline ble_error_t
Rohit Grover 106:a20be740075d 664 BLEDevice::startAdvertising(const GapAdvertisingParams &_advParams)
Rohit Grover 106:a20be740075d 665 {
Rohit Grover 106:a20be740075d 666 return transport->getGap().startAdvertising(_advParams);
Rohit Grover 106:a20be740075d 667 }
Rohit Grover 106:a20be740075d 668
rgrover1 126:fdebe4d5d62f 669 #endif // ifndef __BLE_DEVICE__