士鈞 林 / Mbed OS 12_1

Dependencies:   X_NUCLEO_IKS01A2

Committer:
jim_lsj
Date:
Wed Apr 29 10:42:44 2020 +0000
Revision:
0:9c0e0ac79e75
12_1

Who changed what in which revision?

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