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