BLE
Fork of BLE_API by
public/BLE.h@557:34fa32a420f9, 2015-06-19 (annotated)
- Committer:
- rgrover1
- Date:
- Fri Jun 19 15:52:10 2015 +0100
- Revision:
- 557:34fa32a420f9
- Parent:
- 555:59e95a0efa37
- Child:
- 564:62cc3335df23
Synchronized with git rev b70e8f61
Author: Rohit Grover
drop GattServer::initializeGattDatabase()
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rgrover1 | 529:8d21604fe31d | 1 | /* mbed Microcontroller Library |
rgrover1 | 529:8d21604fe31d | 2 | * Copyright (c) 2006-2013 ARM Limited |
rgrover1 | 529:8d21604fe31d | 3 | * |
rgrover1 | 529:8d21604fe31d | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
rgrover1 | 529:8d21604fe31d | 5 | * you may not use this file except in compliance with the License. |
rgrover1 | 529:8d21604fe31d | 6 | * You may obtain a copy of the License at |
rgrover1 | 529:8d21604fe31d | 7 | * |
rgrover1 | 529:8d21604fe31d | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
rgrover1 | 529:8d21604fe31d | 9 | * |
rgrover1 | 529:8d21604fe31d | 10 | * Unless required by applicable law or agreed to in writing, software |
rgrover1 | 529:8d21604fe31d | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
rgrover1 | 529:8d21604fe31d | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
rgrover1 | 529:8d21604fe31d | 13 | * See the License for the specific language governing permissions and |
rgrover1 | 529:8d21604fe31d | 14 | * limitations under the License. |
rgrover1 | 529:8d21604fe31d | 15 | */ |
rgrover1 | 529:8d21604fe31d | 16 | |
rgrover1 | 529:8d21604fe31d | 17 | #ifndef __BLE_H__ |
rgrover1 | 529:8d21604fe31d | 18 | #define __BLE_H__ |
rgrover1 | 529:8d21604fe31d | 19 | |
rgrover1 | 529:8d21604fe31d | 20 | #include "blecommon.h" |
rgrover1 | 529:8d21604fe31d | 21 | #include "Gap.h" |
rgrover1 | 529:8d21604fe31d | 22 | #include "GattServer.h" |
rgrover1 | 529:8d21604fe31d | 23 | #include "GattClient.h" |
rgrover1 | 529:8d21604fe31d | 24 | #include "BLEInstanceBase.h" |
rgrover1 | 529:8d21604fe31d | 25 | |
rgrover1 | 529:8d21604fe31d | 26 | /** |
rgrover1 | 529:8d21604fe31d | 27 | * The base class used to abstract away BLE capable radio transceivers or SOCs, |
rgrover1 | 529:8d21604fe31d | 28 | * to enable this BLE API to work with any radio transparently. |
rgrover1 | 529:8d21604fe31d | 29 | */ |
rgrover1 | 529:8d21604fe31d | 30 | class BLE |
rgrover1 | 529:8d21604fe31d | 31 | { |
rgrover1 | 529:8d21604fe31d | 32 | public: |
rgrover1 | 529:8d21604fe31d | 33 | /** |
rgrover1 | 529:8d21604fe31d | 34 | * Initialize the BLE controller. This should be called before using |
rgrover1 | 529:8d21604fe31d | 35 | * anything else in the BLE_API. |
rgrover1 | 529:8d21604fe31d | 36 | * |
rgrover1 | 529:8d21604fe31d | 37 | * init() hands control to the underlying BLE module to accomplish |
rgrover1 | 529:8d21604fe31d | 38 | * initialization. This initialization may tacitly depend on other hardware |
rgrover1 | 529:8d21604fe31d | 39 | * setup (such as clocks or power-modes) which happens early on during |
rgrover1 | 529:8d21604fe31d | 40 | * system startup. It may not be safe to call init() from global static |
rgrover1 | 529:8d21604fe31d | 41 | * context where ordering is compiler specific and can't be guaranteed--it |
rgrover1 | 529:8d21604fe31d | 42 | * is safe to call BLE::init() from within main(). |
rgrover1 | 529:8d21604fe31d | 43 | */ |
rgrover1 | 529:8d21604fe31d | 44 | ble_error_t init(); |
rgrover1 | 529:8d21604fe31d | 45 | |
rgrover1 | 538:00d5affbb2b2 | 46 | /** |
rgrover1 | 538:00d5affbb2b2 | 47 | * Purge the BLE stack of GATT and GAP state. init() must be called |
rgrover1 | 538:00d5affbb2b2 | 48 | * afterwards to re-instate services and GAP state. This API offers a way to |
rgrover1 | 538:00d5affbb2b2 | 49 | * repopulate the GATT database with new services and characteristics. |
rgrover1 | 538:00d5affbb2b2 | 50 | */ |
rgrover1 | 538:00d5affbb2b2 | 51 | ble_error_t shutdown(void) { |
rgrover1 | 538:00d5affbb2b2 | 52 | clearAdvertisingPayload(); |
rgrover1 | 538:00d5affbb2b2 | 53 | return transport->shutdown(); |
rgrover1 | 538:00d5affbb2b2 | 54 | } |
rgrover1 | 529:8d21604fe31d | 55 | |
rgrover1 | 529:8d21604fe31d | 56 | /** |
rgrover1 | 538:00d5affbb2b2 | 57 | * This call allows the application to get the BLE stack version information. |
rgrover1 | 538:00d5affbb2b2 | 58 | * |
rgrover1 | 538:00d5affbb2b2 | 59 | * @return A pointer to a const string representing the version. |
rgrover1 | 538:00d5affbb2b2 | 60 | * Note: The string is owned by the BLE_API. |
rgrover1 | 529:8d21604fe31d | 61 | */ |
rgrover1 | 538:00d5affbb2b2 | 62 | const char *getVersion(void) { |
rgrover1 | 538:00d5affbb2b2 | 63 | return transport->getVersion(); |
rgrover1 | 538:00d5affbb2b2 | 64 | } |
rgrover1 | 529:8d21604fe31d | 65 | |
rgrover1 | 538:00d5affbb2b2 | 66 | /* |
rgrover1 | 538:00d5affbb2b2 | 67 | * Accessors to GAP. Please refer to Gap.h. All GAP related functionality requires |
rgrover1 | 538:00d5affbb2b2 | 68 | * going through this accessor. |
rgrover1 | 538:00d5affbb2b2 | 69 | */ |
rgrover1 | 530:ccfae9d8e56e | 70 | const Gap &gap() const { |
rgrover1 | 530:ccfae9d8e56e | 71 | return transport->getGap(); |
rgrover1 | 530:ccfae9d8e56e | 72 | } |
rgrover1 | 530:ccfae9d8e56e | 73 | Gap &gap() { |
rgrover1 | 530:ccfae9d8e56e | 74 | return transport->getGap(); |
rgrover1 | 530:ccfae9d8e56e | 75 | } |
rgrover1 | 530:ccfae9d8e56e | 76 | |
rgrover1 | 539:fff02872b62f | 77 | /* |
rgrover1 | 539:fff02872b62f | 78 | * Accessors to GATT Server. Please refer to GattServer.h. All GATTServer related |
rgrover1 | 539:fff02872b62f | 79 | * functionality requires going through this accessor. |
rgrover1 | 539:fff02872b62f | 80 | */ |
rgrover1 | 539:fff02872b62f | 81 | const GattServer& gattServer() const { |
rgrover1 | 539:fff02872b62f | 82 | return transport->getGattServer(); |
rgrover1 | 539:fff02872b62f | 83 | } |
rgrover1 | 539:fff02872b62f | 84 | GattServer& gattServer() { |
rgrover1 | 539:fff02872b62f | 85 | return transport->getGattServer(); |
rgrover1 | 539:fff02872b62f | 86 | } |
rgrover1 | 539:fff02872b62f | 87 | |
rgrover1 | 541:1fb1e0b809eb | 88 | /* |
rgrover1 | 541:1fb1e0b809eb | 89 | * Accessors to GATT Client. Please refer to GattClient.h. All GATTClient related |
rgrover1 | 541:1fb1e0b809eb | 90 | * functionality requires going through this accessor. |
rgrover1 | 541:1fb1e0b809eb | 91 | */ |
rgrover1 | 541:1fb1e0b809eb | 92 | const GattClient& gattClient() const { |
rgrover1 | 541:1fb1e0b809eb | 93 | return transport->getGattClient(); |
rgrover1 | 541:1fb1e0b809eb | 94 | } |
rgrover1 | 541:1fb1e0b809eb | 95 | GattClient& gattClient() { |
rgrover1 | 541:1fb1e0b809eb | 96 | return transport->getGattClient(); |
rgrover1 | 541:1fb1e0b809eb | 97 | } |
rgrover1 | 541:1fb1e0b809eb | 98 | |
rgrover1 | 547:9fdf3d960d12 | 99 | /* |
rgrover1 | 547:9fdf3d960d12 | 100 | * Accessors to Security Manager. Please refer to SecurityManager.h. All |
rgrover1 | 547:9fdf3d960d12 | 101 | * SecurityManager related functionality requires going through this |
rgrover1 | 547:9fdf3d960d12 | 102 | * accessor. |
rgrover1 | 547:9fdf3d960d12 | 103 | */ |
rgrover1 | 547:9fdf3d960d12 | 104 | const SecurityManager& securityManager() const { |
rgrover1 | 547:9fdf3d960d12 | 105 | return transport->getSecurityManager(); |
rgrover1 | 547:9fdf3d960d12 | 106 | } |
rgrover1 | 547:9fdf3d960d12 | 107 | SecurityManager& securityManager() { |
rgrover1 | 547:9fdf3d960d12 | 108 | return transport->getSecurityManager(); |
rgrover1 | 547:9fdf3d960d12 | 109 | } |
rgrover1 | 547:9fdf3d960d12 | 110 | |
rgrover1 | 538:00d5affbb2b2 | 111 | /** |
rgrover1 | 538:00d5affbb2b2 | 112 | * Yield control to the BLE stack or to other tasks waiting for events. This |
rgrover1 | 538:00d5affbb2b2 | 113 | * is a sleep function which will return when there is an application |
rgrover1 | 538:00d5affbb2b2 | 114 | * specific interrupt, but the MCU might wake up several times before |
rgrover1 | 538:00d5affbb2b2 | 115 | * returning (to service the stack). This is not always interchangeable with |
rgrover1 | 538:00d5affbb2b2 | 116 | * WFE(). |
rgrover1 | 538:00d5affbb2b2 | 117 | */ |
rgrover1 | 538:00d5affbb2b2 | 118 | void waitForEvent(void) { |
rgrover1 | 538:00d5affbb2b2 | 119 | transport->waitForEvent(); |
rgrover1 | 538:00d5affbb2b2 | 120 | } |
rgrover1 | 538:00d5affbb2b2 | 121 | |
rgrover1 | 538:00d5affbb2b2 | 122 | /* |
rgrover1 | 538:00d5affbb2b2 | 123 | * Deprecation alert! |
rgrover1 | 538:00d5affbb2b2 | 124 | * All of the following are deprecated and may be dropped in a future |
rgrover1 | 538:00d5affbb2b2 | 125 | * release. Documentation should refer to alternative APIs. |
rgrover1 | 538:00d5affbb2b2 | 126 | */ |
rgrover1 | 538:00d5affbb2b2 | 127 | |
rgrover1 | 538:00d5affbb2b2 | 128 | /* GAP specific APIs. */ |
rgrover1 | 532:bdcd44b03974 | 129 | public: |
rgrover1 | 529:8d21604fe31d | 130 | /** |
rgrover1 | 529:8d21604fe31d | 131 | * Set the BTLE MAC address and type. |
rgrover1 | 529:8d21604fe31d | 132 | * @return BLE_ERROR_NONE on success. |
rgrover1 | 538:00d5affbb2b2 | 133 | * |
rgrover1 | 538:00d5affbb2b2 | 134 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 135 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 136 | * ble.setAddress(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 137 | * ble.gap().setAddress(...). |
rgrover1 | 529:8d21604fe31d | 138 | */ |
rgrover1 | 538:00d5affbb2b2 | 139 | ble_error_t setAddress(Gap::AddressType_t type, const Gap::Address_t address) { |
rgrover1 | 538:00d5affbb2b2 | 140 | return gap().setAddress(type, address); |
rgrover1 | 538:00d5affbb2b2 | 141 | } |
rgrover1 | 529:8d21604fe31d | 142 | |
rgrover1 | 529:8d21604fe31d | 143 | /** |
rgrover1 | 529:8d21604fe31d | 144 | * Fetch the BTLE MAC address and type. |
rgrover1 | 529:8d21604fe31d | 145 | * @return BLE_ERROR_NONE on success. |
rgrover1 | 538:00d5affbb2b2 | 146 | * |
rgrover1 | 538:00d5affbb2b2 | 147 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 148 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 149 | * ble.getAddress(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 150 | * ble.gap().getAddress(...). |
rgrover1 | 529:8d21604fe31d | 151 | */ |
rgrover1 | 538:00d5affbb2b2 | 152 | ble_error_t getAddress(Gap::AddressType_t *typeP, Gap::Address_t address) { |
rgrover1 | 538:00d5affbb2b2 | 153 | return gap().getAddress(typeP, address); |
rgrover1 | 538:00d5affbb2b2 | 154 | } |
rgrover1 | 529:8d21604fe31d | 155 | |
rgrover1 | 529:8d21604fe31d | 156 | /** |
rgrover1 | 538:00d5affbb2b2 | 157 | * Set the GAP advertising mode to use for this device. |
rgrover1 | 529:8d21604fe31d | 158 | * |
rgrover1 | 538:00d5affbb2b2 | 159 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 160 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 161 | * ble.setAdvertisingType(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 162 | * ble.gap().setAdvertisingType(...). |
rgrover1 | 529:8d21604fe31d | 163 | */ |
rgrover1 | 538:00d5affbb2b2 | 164 | void setAdvertisingType(GapAdvertisingParams::AdvertisingType advType) { |
rgrover1 | 538:00d5affbb2b2 | 165 | gap().setAdvertisingType(advType); |
rgrover1 | 538:00d5affbb2b2 | 166 | } |
rgrover1 | 529:8d21604fe31d | 167 | |
rgrover1 | 529:8d21604fe31d | 168 | /** |
rgrover1 | 529:8d21604fe31d | 169 | * @param[in] interval |
rgrover1 | 529:8d21604fe31d | 170 | * Advertising interval in units of milliseconds. Advertising |
rgrover1 | 529:8d21604fe31d | 171 | * is disabled if interval is 0. If interval is smaller than |
rgrover1 | 529:8d21604fe31d | 172 | * the minimum supported value, then the minimum supported |
rgrover1 | 538:00d5affbb2b2 | 173 | * value is used instead. This minimum value can be discovered |
rgrover1 | 538:00d5affbb2b2 | 174 | * using getMinAdvertisingInterval(). |
rgrover1 | 529:8d21604fe31d | 175 | * |
rgrover1 | 538:00d5affbb2b2 | 176 | * This field must be set to 0 if connectionMode is equal |
rgrover1 | 538:00d5affbb2b2 | 177 | * to ADV_CONNECTABLE_DIRECTED. |
rgrover1 | 529:8d21604fe31d | 178 | * |
rgrover1 | 538:00d5affbb2b2 | 179 | * @note: Decreasing this value will allow central devices to detect a |
rgrover1 | 538:00d5affbb2b2 | 180 | * peripheral faster at the expense of more power being used by the radio |
rgrover1 | 538:00d5affbb2b2 | 181 | * due to the higher data transmit rate. |
rgrover1 | 529:8d21604fe31d | 182 | * |
rgrover1 | 538:00d5affbb2b2 | 183 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 184 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 185 | * ble.setAdvertisingInterval(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 186 | * ble.gap().setAdvertisingInterval(...). |
rgrover1 | 529:8d21604fe31d | 187 | * |
rgrover1 | 538:00d5affbb2b2 | 188 | * @note: [WARNING] This API previously used 0.625ms as the unit for its |
rgrover1 | 529:8d21604fe31d | 189 | * 'interval' argument. That required an explicit conversion from |
rgrover1 | 529:8d21604fe31d | 190 | * milliseconds using Gap::MSEC_TO_GAP_DURATION_UNITS(). This conversion is |
rgrover1 | 529:8d21604fe31d | 191 | * no longer required as the new units are milliseconds. Any application |
rgrover1 | 529:8d21604fe31d | 192 | * code depending on the old semantics would need to be updated accordingly. |
rgrover1 | 529:8d21604fe31d | 193 | */ |
rgrover1 | 538:00d5affbb2b2 | 194 | void setAdvertisingInterval(uint16_t interval) { |
rgrover1 | 538:00d5affbb2b2 | 195 | gap().setAdvertisingInterval(interval); |
rgrover1 | 538:00d5affbb2b2 | 196 | } |
rgrover1 | 529:8d21604fe31d | 197 | |
rgrover1 | 529:8d21604fe31d | 198 | /** |
rgrover1 | 529:8d21604fe31d | 199 | * @return Minimum Advertising interval in milliseconds. |
rgrover1 | 538:00d5affbb2b2 | 200 | * |
rgrover1 | 538:00d5affbb2b2 | 201 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 202 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 203 | * ble.getMinAdvertisingInterval(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 204 | * ble.gap().getMinAdvertisingInterval(...). |
rgrover1 | 529:8d21604fe31d | 205 | */ |
rgrover1 | 538:00d5affbb2b2 | 206 | uint16_t getMinAdvertisingInterval(void) const { |
rgrover1 | 538:00d5affbb2b2 | 207 | return gap().getMinAdvertisingInterval(); |
rgrover1 | 538:00d5affbb2b2 | 208 | } |
rgrover1 | 538:00d5affbb2b2 | 209 | |
rgrover1 | 529:8d21604fe31d | 210 | /** |
rgrover1 | 538:00d5affbb2b2 | 211 | * @return Minimum Advertising interval in milliseconds for non-connectible mode. |
rgrover1 | 538:00d5affbb2b2 | 212 | * |
rgrover1 | 538:00d5affbb2b2 | 213 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 214 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 215 | * ble.getMinNonConnectableAdvertisingInterval(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 216 | * ble.gap().getMinNonConnectableAdvertisingInterval(...). |
rgrover1 | 529:8d21604fe31d | 217 | */ |
rgrover1 | 538:00d5affbb2b2 | 218 | uint16_t getMinNonConnectableAdvertisingInterval(void) const { |
rgrover1 | 538:00d5affbb2b2 | 219 | return gap().getMinNonConnectableAdvertisingInterval(); |
rgrover1 | 538:00d5affbb2b2 | 220 | } |
rgrover1 | 538:00d5affbb2b2 | 221 | |
rgrover1 | 529:8d21604fe31d | 222 | /** |
rgrover1 | 529:8d21604fe31d | 223 | * @return Maximum Advertising interval in milliseconds. |
rgrover1 | 538:00d5affbb2b2 | 224 | * |
rgrover1 | 538:00d5affbb2b2 | 225 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 226 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 227 | * ble.getMaxAdvertisingInterval(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 228 | * ble.gap().getMaxAdvertisingInterval(...). |
rgrover1 | 529:8d21604fe31d | 229 | */ |
rgrover1 | 538:00d5affbb2b2 | 230 | uint16_t getMaxAdvertisingInterval(void) const { |
rgrover1 | 538:00d5affbb2b2 | 231 | return gap().getMaxAdvertisingInterval(); |
rgrover1 | 538:00d5affbb2b2 | 232 | } |
rgrover1 | 529:8d21604fe31d | 233 | |
rgrover1 | 529:8d21604fe31d | 234 | /** |
rgrover1 | 529:8d21604fe31d | 235 | * @param[in] timeout |
rgrover1 | 538:00d5affbb2b2 | 236 | * Advertising timeout (in seconds) between 0x1 and 0x3FFF (1 |
rgrover1 | 538:00d5affbb2b2 | 237 | * and 16383). Use 0 to disable the advertising timeout. |
rgrover1 | 538:00d5affbb2b2 | 238 | * |
rgrover1 | 538:00d5affbb2b2 | 239 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 240 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 241 | * ble.setAdvertisingTimeout(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 242 | * ble.gap().setAdvertisingTimeout(...). |
rgrover1 | 529:8d21604fe31d | 243 | */ |
rgrover1 | 538:00d5affbb2b2 | 244 | void setAdvertisingTimeout(uint16_t timeout) { |
rgrover1 | 538:00d5affbb2b2 | 245 | gap().setAdvertisingTimeout(timeout); |
rgrover1 | 538:00d5affbb2b2 | 246 | } |
rgrover1 | 529:8d21604fe31d | 247 | |
rgrover1 | 529:8d21604fe31d | 248 | /** |
rgrover1 | 538:00d5affbb2b2 | 249 | * Setup a particular, user-constructed set of advertisement parameters for |
rgrover1 | 538:00d5affbb2b2 | 250 | * the underlying stack. It would be uncommon for this API to be used |
rgrover1 | 538:00d5affbb2b2 | 251 | * directly; there are other APIs to tweak advertisement parameters |
rgrover1 | 538:00d5affbb2b2 | 252 | * individually (see above). |
rgrover1 | 538:00d5affbb2b2 | 253 | * |
rgrover1 | 538:00d5affbb2b2 | 254 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 255 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 256 | * ble.setAdvertisingParams(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 257 | * ble.gap().setAdvertisingParams(...). |
rgrover1 | 529:8d21604fe31d | 258 | */ |
rgrover1 | 538:00d5affbb2b2 | 259 | void setAdvertisingParams(const GapAdvertisingParams &advParams) { |
rgrover1 | 538:00d5affbb2b2 | 260 | gap().setAdvertisingParams(advParams); |
rgrover1 | 538:00d5affbb2b2 | 261 | } |
rgrover1 | 529:8d21604fe31d | 262 | |
rgrover1 | 529:8d21604fe31d | 263 | /** |
rgrover1 | 529:8d21604fe31d | 264 | * @return Read back advertising parameters. Useful for storing and |
rgrover1 | 529:8d21604fe31d | 265 | * restoring parameters rapidly. |
rgrover1 | 538:00d5affbb2b2 | 266 | * |
rgrover1 | 538:00d5affbb2b2 | 267 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 268 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 269 | * ble.getAdvertisingParams(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 270 | * ble.gap().getAdvertisingParams(...). |
rgrover1 | 529:8d21604fe31d | 271 | */ |
rgrover1 | 538:00d5affbb2b2 | 272 | const GapAdvertisingParams &getAdvertisingParams(void) const { |
rgrover1 | 538:00d5affbb2b2 | 273 | return gap().getAdvertisingParams(); |
rgrover1 | 538:00d5affbb2b2 | 274 | } |
rgrover1 | 529:8d21604fe31d | 275 | |
rgrover1 | 529:8d21604fe31d | 276 | /** |
rgrover1 | 529:8d21604fe31d | 277 | * Accumulate an AD structure in the advertising payload. Please note that |
rgrover1 | 529:8d21604fe31d | 278 | * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used |
rgrover1 | 529:8d21604fe31d | 279 | * as an additional 31 bytes if the advertising payload proves to be too |
rgrover1 | 529:8d21604fe31d | 280 | * small. |
rgrover1 | 529:8d21604fe31d | 281 | * |
rgrover1 | 538:00d5affbb2b2 | 282 | * @param[in] flags |
rgrover1 | 538:00d5affbb2b2 | 283 | * The flags to be added. Please refer to |
rgrover1 | 538:00d5affbb2b2 | 284 | * GapAdvertisingData::Flags for valid flags. Multiple |
rgrover1 | 538:00d5affbb2b2 | 285 | * flags may be specified in combination. |
rgrover1 | 538:00d5affbb2b2 | 286 | * |
rgrover1 | 538:00d5affbb2b2 | 287 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 288 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 289 | * ble.accumulateAdvertisingPayload(flags) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 290 | * ble.gap().accumulateAdvertisingPayload(flags). |
rgrover1 | 529:8d21604fe31d | 291 | */ |
rgrover1 | 538:00d5affbb2b2 | 292 | ble_error_t accumulateAdvertisingPayload(uint8_t flags) { |
rgrover1 | 538:00d5affbb2b2 | 293 | return gap().accumulateAdvertisingPayload(flags); |
rgrover1 | 538:00d5affbb2b2 | 294 | } |
rgrover1 | 529:8d21604fe31d | 295 | |
rgrover1 | 529:8d21604fe31d | 296 | /** |
rgrover1 | 529:8d21604fe31d | 297 | * Accumulate an AD structure in the advertising payload. Please note that |
rgrover1 | 529:8d21604fe31d | 298 | * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used |
rgrover1 | 529:8d21604fe31d | 299 | * as an additional 31 bytes if the advertising payload proves to be too |
rgrover1 | 529:8d21604fe31d | 300 | * small. |
rgrover1 | 529:8d21604fe31d | 301 | * |
rgrover1 | 538:00d5affbb2b2 | 302 | * @param[in] app |
rgrover1 | 538:00d5affbb2b2 | 303 | * The appearance of the peripheral. |
rgrover1 | 538:00d5affbb2b2 | 304 | * |
rgrover1 | 538:00d5affbb2b2 | 305 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 306 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 307 | * ble.accumulateAdvertisingPayload(appearance) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 308 | * ble.gap().accumulateAdvertisingPayload(appearance). |
rgrover1 | 529:8d21604fe31d | 309 | */ |
rgrover1 | 538:00d5affbb2b2 | 310 | ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::Appearance app) { |
rgrover1 | 538:00d5affbb2b2 | 311 | return gap().accumulateAdvertisingPayload(app); |
rgrover1 | 538:00d5affbb2b2 | 312 | } |
rgrover1 | 529:8d21604fe31d | 313 | |
rgrover1 | 529:8d21604fe31d | 314 | /** |
rgrover1 | 529:8d21604fe31d | 315 | * Accumulate an AD structure in the advertising payload. Please note that |
rgrover1 | 529:8d21604fe31d | 316 | * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used |
rgrover1 | 529:8d21604fe31d | 317 | * as an additional 31 bytes if the advertising payload proves to be too |
rgrover1 | 529:8d21604fe31d | 318 | * small. |
rgrover1 | 529:8d21604fe31d | 319 | * |
rgrover1 | 538:00d5affbb2b2 | 320 | * @param[in] app |
rgrover1 | 538:00d5affbb2b2 | 321 | * The max transmit power to be used by the controller. This |
rgrover1 | 538:00d5affbb2b2 | 322 | * is only a hint. |
rgrover1 | 538:00d5affbb2b2 | 323 | * |
rgrover1 | 538:00d5affbb2b2 | 324 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 325 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 326 | * ble.accumulateAdvertisingPayloadTxPower(txPower) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 327 | * ble.gap().accumulateAdvertisingPayloadTxPower(txPower). |
rgrover1 | 529:8d21604fe31d | 328 | */ |
rgrover1 | 538:00d5affbb2b2 | 329 | ble_error_t accumulateAdvertisingPayloadTxPower(int8_t power) { |
rgrover1 | 538:00d5affbb2b2 | 330 | return gap().accumulateAdvertisingPayloadTxPower(power); |
rgrover1 | 538:00d5affbb2b2 | 331 | } |
rgrover1 | 529:8d21604fe31d | 332 | |
rgrover1 | 529:8d21604fe31d | 333 | /** |
rgrover1 | 529:8d21604fe31d | 334 | * Accumulate a variable length byte-stream as an AD structure in the |
rgrover1 | 529:8d21604fe31d | 335 | * advertising payload. Please note that the payload is limited to 31 bytes. |
rgrover1 | 529:8d21604fe31d | 336 | * The SCAN_RESPONSE message may be used as an additional 31 bytes if the |
rgrover1 | 529:8d21604fe31d | 337 | * advertising payload proves to be too small. |
rgrover1 | 529:8d21604fe31d | 338 | * |
rgrover1 | 529:8d21604fe31d | 339 | * @param type The type which describes the variable length data. |
rgrover1 | 529:8d21604fe31d | 340 | * @param data data bytes. |
rgrover1 | 529:8d21604fe31d | 341 | * @param len length of data. |
rgrover1 | 538:00d5affbb2b2 | 342 | * |
rgrover1 | 538:00d5affbb2b2 | 343 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 344 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 345 | * ble.accumulateAdvertisingPayload(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 346 | * ble.gap().accumulateAdvertisingPayload(...). |
rgrover1 | 529:8d21604fe31d | 347 | */ |
rgrover1 | 538:00d5affbb2b2 | 348 | ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) { |
rgrover1 | 538:00d5affbb2b2 | 349 | return gap().accumulateAdvertisingPayload(type, data, len); |
rgrover1 | 538:00d5affbb2b2 | 350 | } |
rgrover1 | 538:00d5affbb2b2 | 351 | |
rgrover1 | 538:00d5affbb2b2 | 352 | /** |
rgrover1 | 538:00d5affbb2b2 | 353 | * Setup a particular, user-constructed advertisement payload for the |
rgrover1 | 538:00d5affbb2b2 | 354 | * underlying stack. It would be uncommon for this API to be used directly; |
rgrover1 | 538:00d5affbb2b2 | 355 | * there are other APIs to build an advertisement payload (see above). |
rgrover1 | 538:00d5affbb2b2 | 356 | * |
rgrover1 | 538:00d5affbb2b2 | 357 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 358 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 359 | * ble.setAdvertisingData(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 360 | * ble.gap().setAdvertisingPayload(...). |
rgrover1 | 538:00d5affbb2b2 | 361 | */ |
rgrover1 | 538:00d5affbb2b2 | 362 | ble_error_t setAdvertisingData(const GapAdvertisingData &advData) { |
rgrover1 | 538:00d5affbb2b2 | 363 | return gap().setAdvertisingPayload(advData); |
rgrover1 | 538:00d5affbb2b2 | 364 | } |
rgrover1 | 538:00d5affbb2b2 | 365 | |
rgrover1 | 538:00d5affbb2b2 | 366 | /** |
rgrover1 | 538:00d5affbb2b2 | 367 | * @return Read back advertising data. Useful for storing and |
rgrover1 | 538:00d5affbb2b2 | 368 | * restoring payload. |
rgrover1 | 538:00d5affbb2b2 | 369 | * |
rgrover1 | 538:00d5affbb2b2 | 370 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 371 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 372 | * ble.getAdvertisingData(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 373 | * ble.gap().getAdvertisingPayload()(...). |
rgrover1 | 538:00d5affbb2b2 | 374 | */ |
rgrover1 | 538:00d5affbb2b2 | 375 | const GapAdvertisingData &getAdvertisingData(void) const { |
rgrover1 | 538:00d5affbb2b2 | 376 | return gap().getAdvertisingPayload(); |
rgrover1 | 538:00d5affbb2b2 | 377 | } |
rgrover1 | 538:00d5affbb2b2 | 378 | |
rgrover1 | 538:00d5affbb2b2 | 379 | /** |
rgrover1 | 538:00d5affbb2b2 | 380 | * Reset any advertising payload prepared from prior calls to |
rgrover1 | 538:00d5affbb2b2 | 381 | * accumulateAdvertisingPayload(). This automatically propagates the re- |
rgrover1 | 538:00d5affbb2b2 | 382 | * initialized adv payload to the underlying stack. |
rgrover1 | 538:00d5affbb2b2 | 383 | * |
rgrover1 | 538:00d5affbb2b2 | 384 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 385 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 386 | * ble.clearAdvertisingPayload(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 387 | * ble.gap().clearAdvertisingPayload(...). |
rgrover1 | 538:00d5affbb2b2 | 388 | */ |
rgrover1 | 538:00d5affbb2b2 | 389 | void clearAdvertisingPayload(void) { |
rgrover1 | 538:00d5affbb2b2 | 390 | gap().clearAdvertisingPayload(); |
rgrover1 | 538:00d5affbb2b2 | 391 | } |
rgrover1 | 538:00d5affbb2b2 | 392 | |
rgrover1 | 538:00d5affbb2b2 | 393 | /** |
rgrover1 | 538:00d5affbb2b2 | 394 | * This API is *deprecated* and resolves to a no-operation. It is left here |
rgrover1 | 538:00d5affbb2b2 | 395 | * to allow older code to compile. Please avoid using this API in new code. |
rgrover1 | 538:00d5affbb2b2 | 396 | * This API will be dropped in a future release. |
rgrover1 | 538:00d5affbb2b2 | 397 | * |
rgrover1 | 538:00d5affbb2b2 | 398 | * Formerly, it would be used to dynamically reset the accumulated advertising |
rgrover1 | 538:00d5affbb2b2 | 399 | * payload and scanResponse; to do this, the application would clear and re- |
rgrover1 | 538:00d5affbb2b2 | 400 | * accumulate a new advertising payload (and scanResponse) before using this |
rgrover1 | 538:00d5affbb2b2 | 401 | * API. Updates to the underlying advertisement payload now happen |
rgrover1 | 538:00d5affbb2b2 | 402 | * implicitly. |
rgrover1 | 538:00d5affbb2b2 | 403 | */ |
rgrover1 | 538:00d5affbb2b2 | 404 | ble_error_t setAdvertisingPayload(void) { |
rgrover1 | 538:00d5affbb2b2 | 405 | return BLE_ERROR_NONE; |
rgrover1 | 538:00d5affbb2b2 | 406 | } |
rgrover1 | 529:8d21604fe31d | 407 | |
rgrover1 | 529:8d21604fe31d | 408 | /** |
rgrover1 | 529:8d21604fe31d | 409 | * Accumulate a variable length byte-stream as an AD structure in the |
rgrover1 | 529:8d21604fe31d | 410 | * scanResponse payload. |
rgrover1 | 529:8d21604fe31d | 411 | * |
rgrover1 | 538:00d5affbb2b2 | 412 | * @param[in] type The type which describes the variable length data. |
rgrover1 | 538:00d5affbb2b2 | 413 | * @param[in] data data bytes. |
rgrover1 | 538:00d5affbb2b2 | 414 | * @param[in] len length of data. |
rgrover1 | 538:00d5affbb2b2 | 415 | * |
rgrover1 | 538:00d5affbb2b2 | 416 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 417 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 418 | * ble.accumulateScanResponse(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 419 | * ble.gap().accumulateScanResponse(...). |
rgrover1 | 529:8d21604fe31d | 420 | */ |
rgrover1 | 538:00d5affbb2b2 | 421 | ble_error_t accumulateScanResponse(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) { |
rgrover1 | 538:00d5affbb2b2 | 422 | return gap().accumulateScanResponse(type, data, len); |
rgrover1 | 538:00d5affbb2b2 | 423 | } |
rgrover1 | 529:8d21604fe31d | 424 | |
rgrover1 | 529:8d21604fe31d | 425 | /** |
rgrover1 | 529:8d21604fe31d | 426 | * Reset any scan response prepared from prior calls to |
rgrover1 | 529:8d21604fe31d | 427 | * accumulateScanResponse(). |
rgrover1 | 529:8d21604fe31d | 428 | * |
rgrover1 | 538:00d5affbb2b2 | 429 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 430 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 431 | * ble.clearScanResponse(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 432 | * ble.gap().clearScanResponse(...). |
rgrover1 | 529:8d21604fe31d | 433 | */ |
rgrover1 | 538:00d5affbb2b2 | 434 | void clearScanResponse(void) { |
rgrover1 | 538:00d5affbb2b2 | 435 | gap().clearScanResponse(); |
rgrover1 | 538:00d5affbb2b2 | 436 | } |
rgrover1 | 529:8d21604fe31d | 437 | |
rgrover1 | 529:8d21604fe31d | 438 | /** |
rgrover1 | 538:00d5affbb2b2 | 439 | * Start advertising. |
rgrover1 | 538:00d5affbb2b2 | 440 | * |
rgrover1 | 538:00d5affbb2b2 | 441 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 442 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 443 | * ble.startAdvertising(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 444 | * ble.gap().startAdvertising(...). |
rgrover1 | 529:8d21604fe31d | 445 | */ |
rgrover1 | 538:00d5affbb2b2 | 446 | ble_error_t startAdvertising(void) { |
rgrover1 | 538:00d5affbb2b2 | 447 | return gap().startAdvertising(); |
rgrover1 | 538:00d5affbb2b2 | 448 | } |
rgrover1 | 529:8d21604fe31d | 449 | |
rgrover1 | 529:8d21604fe31d | 450 | /** |
rgrover1 | 538:00d5affbb2b2 | 451 | * Stop advertising. |
rgrover1 | 538:00d5affbb2b2 | 452 | * |
rgrover1 | 538:00d5affbb2b2 | 453 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 454 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 455 | * ble.stopAdvertising(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 456 | * ble.gap().stopAdvertising(...). |
rgrover1 | 529:8d21604fe31d | 457 | */ |
rgrover1 | 538:00d5affbb2b2 | 458 | ble_error_t stopAdvertising(void) { |
rgrover1 | 538:00d5affbb2b2 | 459 | return gap().stopAdvertising(); |
rgrover1 | 538:00d5affbb2b2 | 460 | } |
rgrover1 | 529:8d21604fe31d | 461 | |
rgrover1 | 529:8d21604fe31d | 462 | /** |
rgrover1 | 529:8d21604fe31d | 463 | * Setup parameters for GAP scanning--i.e. observer mode. |
rgrover1 | 538:00d5affbb2b2 | 464 | * @param[in] interval |
rgrover1 | 538:00d5affbb2b2 | 465 | * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
rgrover1 | 538:00d5affbb2b2 | 466 | * @param[in] window |
rgrover1 | 538:00d5affbb2b2 | 467 | * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
rgrover1 | 538:00d5affbb2b2 | 468 | * @param[in] timeout |
rgrover1 | 538:00d5affbb2b2 | 469 | * Scan timeout (in seconds) between 0x0001 and 0xFFFF, 0x0000 disables timeout. |
rgrover1 | 538:00d5affbb2b2 | 470 | * @param[in] activeScanning |
rgrover1 | 538:00d5affbb2b2 | 471 | * Set to True if active-scanning is required. This is used to fetch the |
rgrover1 | 538:00d5affbb2b2 | 472 | * scan response from a peer if possible. |
rgrover1 | 529:8d21604fe31d | 473 | * |
rgrover1 | 529:8d21604fe31d | 474 | * The scanning window divided by the interval determines the duty cycle for |
rgrover1 | 529:8d21604fe31d | 475 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
rgrover1 | 529:8d21604fe31d | 476 | * then the controller will scan for 10 percent of the time. It is possible |
rgrover1 | 529:8d21604fe31d | 477 | * to have the interval and window set to the same value. In this case, |
rgrover1 | 529:8d21604fe31d | 478 | * scanning is continuous, with a change of scanning frequency once every |
rgrover1 | 529:8d21604fe31d | 479 | * interval. |
rgrover1 | 529:8d21604fe31d | 480 | * |
rgrover1 | 529:8d21604fe31d | 481 | * Once the scanning parameters have been configured, scanning can be |
rgrover1 | 529:8d21604fe31d | 482 | * enabled by using startScan(). |
rgrover1 | 529:8d21604fe31d | 483 | * |
rgrover1 | 529:8d21604fe31d | 484 | * @Note: The scan interval and window are recommendations to the BLE stack. |
rgrover1 | 538:00d5affbb2b2 | 485 | * |
rgrover1 | 538:00d5affbb2b2 | 486 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 487 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 488 | * ble.setScanParams(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 489 | * ble.gap().setScanParams(...). |
rgrover1 | 529:8d21604fe31d | 490 | */ |
rgrover1 | 529:8d21604fe31d | 491 | ble_error_t setScanParams(uint16_t interval = GapScanningParams::SCAN_INTERVAL_MAX, |
rgrover1 | 529:8d21604fe31d | 492 | uint16_t window = GapScanningParams::SCAN_WINDOW_MAX, |
rgrover1 | 529:8d21604fe31d | 493 | uint16_t timeout = 0, |
rgrover1 | 538:00d5affbb2b2 | 494 | bool activeScanning = false) { |
rgrover1 | 538:00d5affbb2b2 | 495 | return gap().setScanParams(interval, window, timeout, activeScanning); |
rgrover1 | 538:00d5affbb2b2 | 496 | } |
rgrover1 | 538:00d5affbb2b2 | 497 | |
rgrover1 | 538:00d5affbb2b2 | 498 | /** |
rgrover1 | 538:00d5affbb2b2 | 499 | * Setup the scanInterval parameter for GAP scanning--i.e. observer mode. |
rgrover1 | 538:00d5affbb2b2 | 500 | * @param[in] interval |
rgrover1 | 538:00d5affbb2b2 | 501 | * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
rgrover1 | 538:00d5affbb2b2 | 502 | * |
rgrover1 | 538:00d5affbb2b2 | 503 | * The scanning window divided by the interval determines the duty cycle for |
rgrover1 | 538:00d5affbb2b2 | 504 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
rgrover1 | 538:00d5affbb2b2 | 505 | * then the controller will scan for 10 percent of the time. It is possible |
rgrover1 | 538:00d5affbb2b2 | 506 | * to have the interval and window set to the same value. In this case, |
rgrover1 | 538:00d5affbb2b2 | 507 | * scanning is continuous, with a change of scanning frequency once every |
rgrover1 | 538:00d5affbb2b2 | 508 | * interval. |
rgrover1 | 538:00d5affbb2b2 | 509 | * |
rgrover1 | 538:00d5affbb2b2 | 510 | * Once the scanning parameters have been configured, scanning can be |
rgrover1 | 538:00d5affbb2b2 | 511 | * enabled by using startScan(). |
rgrover1 | 538:00d5affbb2b2 | 512 | * |
rgrover1 | 538:00d5affbb2b2 | 513 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 514 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 515 | * ble.setScanInterval(interval) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 516 | * ble.gap().setScanInterval(interval). |
rgrover1 | 538:00d5affbb2b2 | 517 | */ |
rgrover1 | 538:00d5affbb2b2 | 518 | ble_error_t setScanInterval(uint16_t interval) { |
rgrover1 | 538:00d5affbb2b2 | 519 | return gap().setScanInterval(interval); |
rgrover1 | 538:00d5affbb2b2 | 520 | } |
rgrover1 | 538:00d5affbb2b2 | 521 | |
rgrover1 | 538:00d5affbb2b2 | 522 | /** |
rgrover1 | 538:00d5affbb2b2 | 523 | * Setup the scanWindow parameter for GAP scanning--i.e. observer mode. |
rgrover1 | 538:00d5affbb2b2 | 524 | * @param[in] window |
rgrover1 | 538:00d5affbb2b2 | 525 | * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
rgrover1 | 538:00d5affbb2b2 | 526 | * |
rgrover1 | 538:00d5affbb2b2 | 527 | * The scanning window divided by the interval determines the duty cycle for |
rgrover1 | 538:00d5affbb2b2 | 528 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
rgrover1 | 538:00d5affbb2b2 | 529 | * then the controller will scan for 10 percent of the time. It is possible |
rgrover1 | 538:00d5affbb2b2 | 530 | * to have the interval and window set to the same value. In this case, |
rgrover1 | 538:00d5affbb2b2 | 531 | * scanning is continuous, with a change of scanning frequency once every |
rgrover1 | 538:00d5affbb2b2 | 532 | * interval. |
rgrover1 | 538:00d5affbb2b2 | 533 | * |
rgrover1 | 538:00d5affbb2b2 | 534 | * Once the scanning parameters have been configured, scanning can be |
rgrover1 | 538:00d5affbb2b2 | 535 | * enabled by using startScan(). |
rgrover1 | 538:00d5affbb2b2 | 536 | * |
rgrover1 | 538:00d5affbb2b2 | 537 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 538 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 539 | * ble.setScanWindow(window) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 540 | * ble.gap().setScanWindow(window). |
rgrover1 | 538:00d5affbb2b2 | 541 | */ |
rgrover1 | 538:00d5affbb2b2 | 542 | ble_error_t setScanWindow(uint16_t window) { |
rgrover1 | 538:00d5affbb2b2 | 543 | return gap().setScanWindow(window); |
rgrover1 | 538:00d5affbb2b2 | 544 | } |
rgrover1 | 529:8d21604fe31d | 545 | |
rgrover1 | 529:8d21604fe31d | 546 | /** |
rgrover1 | 538:00d5affbb2b2 | 547 | * Setup parameters for GAP scanning--i.e. observer mode. |
rgrover1 | 538:00d5affbb2b2 | 548 | * @param[in] timeout |
rgrover1 | 538:00d5affbb2b2 | 549 | * Scan timeout (in seconds) between 0x0001 and 0xFFFF, 0x0000 disables timeout. |
rgrover1 | 538:00d5affbb2b2 | 550 | * |
rgrover1 | 538:00d5affbb2b2 | 551 | * The scanning window divided by the interval determines the duty cycle for |
rgrover1 | 538:00d5affbb2b2 | 552 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
rgrover1 | 538:00d5affbb2b2 | 553 | * then the controller will scan for 10 percent of the time. It is possible |
rgrover1 | 538:00d5affbb2b2 | 554 | * to have the interval and window set to the same value. In this case, |
rgrover1 | 538:00d5affbb2b2 | 555 | * scanning is continuous, with a change of scanning frequency once every |
rgrover1 | 538:00d5affbb2b2 | 556 | * interval. |
rgrover1 | 529:8d21604fe31d | 557 | * |
rgrover1 | 538:00d5affbb2b2 | 558 | * Once the scanning parameters have been configured, scanning can be |
rgrover1 | 538:00d5affbb2b2 | 559 | * enabled by using startScan(). |
rgrover1 | 538:00d5affbb2b2 | 560 | * |
rgrover1 | 538:00d5affbb2b2 | 561 | * @Note: The scan interval and window are recommendations to the BLE stack. |
rgrover1 | 538:00d5affbb2b2 | 562 | * |
rgrover1 | 538:00d5affbb2b2 | 563 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 564 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 565 | * ble.setScanTimeout(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 566 | * ble.gap().setScanTimeout(...). |
rgrover1 | 529:8d21604fe31d | 567 | */ |
rgrover1 | 538:00d5affbb2b2 | 568 | ble_error_t setScanTimeout(uint16_t timeout) { |
rgrover1 | 538:00d5affbb2b2 | 569 | return gap().setScanTimeout(timeout); |
rgrover1 | 538:00d5affbb2b2 | 570 | } |
rgrover1 | 529:8d21604fe31d | 571 | |
rgrover1 | 529:8d21604fe31d | 572 | /** |
rgrover1 | 538:00d5affbb2b2 | 573 | * Setup parameters for GAP scanning--i.e. observer mode. |
rgrover1 | 538:00d5affbb2b2 | 574 | * @param[in] activeScanning |
rgrover1 | 538:00d5affbb2b2 | 575 | * Set to True if active-scanning is required. This is used to fetch the |
rgrover1 | 538:00d5affbb2b2 | 576 | * scan response from a peer if possible. |
rgrover1 | 538:00d5affbb2b2 | 577 | * |
rgrover1 | 538:00d5affbb2b2 | 578 | * Once the scanning parameters have been configured, scanning can be |
rgrover1 | 538:00d5affbb2b2 | 579 | * enabled by using startScan(). |
rgrover1 | 538:00d5affbb2b2 | 580 | * |
rgrover1 | 538:00d5affbb2b2 | 581 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 582 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 583 | * ble.setActiveScan(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 584 | * ble.gap().setActiveScanning(...). |
rgrover1 | 538:00d5affbb2b2 | 585 | */ |
rgrover1 | 538:00d5affbb2b2 | 586 | void setActiveScan(bool activeScanning) { |
rgrover1 | 538:00d5affbb2b2 | 587 | gap().setActiveScanning(activeScanning); |
rgrover1 | 538:00d5affbb2b2 | 588 | } |
rgrover1 | 538:00d5affbb2b2 | 589 | |
rgrover1 | 538:00d5affbb2b2 | 590 | /** |
rgrover1 | 538:00d5affbb2b2 | 591 | * Start scanning (Observer Procedure) based on the parameters currently in |
rgrover1 | 538:00d5affbb2b2 | 592 | * effect. |
rgrover1 | 529:8d21604fe31d | 593 | * |
rgrover1 | 538:00d5affbb2b2 | 594 | * @param[in] callback |
rgrover1 | 538:00d5affbb2b2 | 595 | * The application specific callback to be invoked upon |
rgrover1 | 538:00d5affbb2b2 | 596 | * receiving every advertisement report. This can be passed in |
rgrover1 | 538:00d5affbb2b2 | 597 | * as NULL, in which case scanning may not be enabled at all. |
rgrover1 | 538:00d5affbb2b2 | 598 | * |
rgrover1 | 538:00d5affbb2b2 | 599 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 600 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 601 | * ble.startScan(callback) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 602 | * ble.gap().startScan(callback). |
rgrover1 | 538:00d5affbb2b2 | 603 | */ |
rgrover1 | 538:00d5affbb2b2 | 604 | ble_error_t startScan(void (*callback)(const Gap::AdvertisementCallbackParams_t *params)) { |
rgrover1 | 538:00d5affbb2b2 | 605 | return gap().startScan(callback); |
rgrover1 | 538:00d5affbb2b2 | 606 | } |
rgrover1 | 538:00d5affbb2b2 | 607 | |
rgrover1 | 538:00d5affbb2b2 | 608 | /** |
rgrover1 | 538:00d5affbb2b2 | 609 | * Same as above, but this takes an (object, method) pair for a callback. |
rgrover1 | 538:00d5affbb2b2 | 610 | * |
rgrover1 | 538:00d5affbb2b2 | 611 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 612 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 613 | * ble.startScan(callback) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 614 | * ble.gap().startScan(object, callback). |
rgrover1 | 529:8d21604fe31d | 615 | */ |
rgrover1 | 529:8d21604fe31d | 616 | template<typename T> |
rgrover1 | 529:8d21604fe31d | 617 | ble_error_t startScan(T *object, void (T::*memberCallback)(const Gap::AdvertisementCallbackParams_t *params)); |
rgrover1 | 529:8d21604fe31d | 618 | |
rgrover1 | 529:8d21604fe31d | 619 | /** |
rgrover1 | 529:8d21604fe31d | 620 | * Stop scanning. The current scanning parameters remain in effect. |
rgrover1 | 529:8d21604fe31d | 621 | * |
rgrover1 | 529:8d21604fe31d | 622 | * @retval BLE_ERROR_NONE if successfully stopped scanning procedure. |
rgrover1 | 538:00d5affbb2b2 | 623 | * |
rgrover1 | 538:00d5affbb2b2 | 624 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 625 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 626 | * ble.stopScan() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 627 | * ble.gap().stopScan(). |
rgrover1 | 529:8d21604fe31d | 628 | */ |
rgrover1 | 538:00d5affbb2b2 | 629 | ble_error_t stopScan(void) { |
rgrover1 | 538:00d5affbb2b2 | 630 | return gap().stopScan(); |
rgrover1 | 538:00d5affbb2b2 | 631 | } |
rgrover1 | 529:8d21604fe31d | 632 | |
rgrover1 | 529:8d21604fe31d | 633 | /** |
rgrover1 | 529:8d21604fe31d | 634 | * Create a connection (GAP Link Establishment). |
rgrover1 | 529:8d21604fe31d | 635 | * @param peerAddr |
rgrover1 | 529:8d21604fe31d | 636 | * 48-bit address, LSB format. |
rgrover1 | 529:8d21604fe31d | 637 | * @param peerAddrType |
rgrover1 | 529:8d21604fe31d | 638 | * Address type of the peer. |
rgrover1 | 529:8d21604fe31d | 639 | * @param connectionParams |
rgrover1 | 529:8d21604fe31d | 640 | * Connection parameters. |
rgrover1 | 529:8d21604fe31d | 641 | * @param scanParams |
rgrover1 | 529:8d21604fe31d | 642 | * Paramters to be used while scanning for the peer. |
rgrover1 | 529:8d21604fe31d | 643 | * @return BLE_ERROR_NONE if connection establishment procedure is started |
rgrover1 | 529:8d21604fe31d | 644 | * successfully. The onConnection callback (if set) will be invoked upon |
rgrover1 | 529:8d21604fe31d | 645 | * a connection event. |
rgrover1 | 538:00d5affbb2b2 | 646 | * |
rgrover1 | 538:00d5affbb2b2 | 647 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 648 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 649 | * ble.connect(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 650 | * ble.gap().connect(...). |
rgrover1 | 529:8d21604fe31d | 651 | */ |
rgrover1 | 529:8d21604fe31d | 652 | ble_error_t connect(const Gap::Address_t peerAddr, |
rgrover1 | 529:8d21604fe31d | 653 | Gap::AddressType_t peerAddrType = Gap::ADDR_TYPE_RANDOM_STATIC, |
rgrover1 | 529:8d21604fe31d | 654 | const Gap::ConnectionParams_t *connectionParams = NULL, |
rgrover1 | 538:00d5affbb2b2 | 655 | const GapScanningParams *scanParams = NULL) { |
rgrover1 | 538:00d5affbb2b2 | 656 | return gap().connect(peerAddr, peerAddrType, connectionParams, scanParams); |
rgrover1 | 538:00d5affbb2b2 | 657 | } |
rgrover1 | 529:8d21604fe31d | 658 | |
rgrover1 | 529:8d21604fe31d | 659 | /** |
rgrover1 | 529:8d21604fe31d | 660 | * This call initiates the disconnection procedure, and its completion will |
rgrover1 | 529:8d21604fe31d | 661 | * be communicated to the application with an invocation of the |
rgrover1 | 529:8d21604fe31d | 662 | * onDisconnection callback. |
rgrover1 | 529:8d21604fe31d | 663 | * |
rgrover1 | 529:8d21604fe31d | 664 | * @param reason |
rgrover1 | 529:8d21604fe31d | 665 | * The reason for disconnection to be sent back to the peer. |
rgrover1 | 538:00d5affbb2b2 | 666 | * |
rgrover1 | 538:00d5affbb2b2 | 667 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 668 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 669 | * ble.disconnect(reason) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 670 | * ble.gap().disconnect(reason). |
rgrover1 | 529:8d21604fe31d | 671 | */ |
rgrover1 | 538:00d5affbb2b2 | 672 | ble_error_t disconnect(Gap::DisconnectionReason_t reason) { |
rgrover1 | 538:00d5affbb2b2 | 673 | return gap().disconnect(reason); |
rgrover1 | 538:00d5affbb2b2 | 674 | } |
rgrover1 | 538:00d5affbb2b2 | 675 | |
rgrover1 | 538:00d5affbb2b2 | 676 | /** |
rgrover1 | 538:00d5affbb2b2 | 677 | * Returns the current GAP state of the device using a bitmask which |
rgrover1 | 538:00d5affbb2b2 | 678 | * describes whether the device is advertising and/or connected. |
rgrover1 | 538:00d5affbb2b2 | 679 | * |
rgrover1 | 538:00d5affbb2b2 | 680 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 681 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 682 | * ble.getGapState() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 683 | * ble.gap().getState(). |
rgrover1 | 538:00d5affbb2b2 | 684 | */ |
rgrover1 | 538:00d5affbb2b2 | 685 | Gap::GapState_t getGapState(void) const { |
rgrover1 | 538:00d5affbb2b2 | 686 | return gap().getState(); |
rgrover1 | 538:00d5affbb2b2 | 687 | } |
rgrover1 | 538:00d5affbb2b2 | 688 | |
rgrover1 | 538:00d5affbb2b2 | 689 | /** |
rgrover1 | 538:00d5affbb2b2 | 690 | * Get the GAP peripheral preferred connection parameters. These are the |
rgrover1 | 538:00d5affbb2b2 | 691 | * defaults that the peripheral would like to have in a connection. The |
rgrover1 | 538:00d5affbb2b2 | 692 | * choice of the connection parameters is eventually up to the central. |
rgrover1 | 538:00d5affbb2b2 | 693 | * |
rgrover1 | 538:00d5affbb2b2 | 694 | * @param[out] params |
rgrover1 | 538:00d5affbb2b2 | 695 | * The structure where the parameters will be stored. Memory |
rgrover1 | 538:00d5affbb2b2 | 696 | * for this is owned by the caller. |
rgrover1 | 538:00d5affbb2b2 | 697 | * |
rgrover1 | 538:00d5affbb2b2 | 698 | * @return BLE_ERROR_NONE if the parameters were successfully filled into |
rgrover1 | 538:00d5affbb2b2 | 699 | * the given structure pointed to by params. |
rgrover1 | 538:00d5affbb2b2 | 700 | * |
rgrover1 | 538:00d5affbb2b2 | 701 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 702 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 703 | * ble.getPreferredConnectionParams() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 704 | * ble.gap().getPreferredConnectionParams(). |
rgrover1 | 538:00d5affbb2b2 | 705 | */ |
rgrover1 | 538:00d5affbb2b2 | 706 | ble_error_t getPreferredConnectionParams(Gap::ConnectionParams_t *params) { |
rgrover1 | 538:00d5affbb2b2 | 707 | return gap().getPreferredConnectionParams(params); |
rgrover1 | 538:00d5affbb2b2 | 708 | } |
rgrover1 | 538:00d5affbb2b2 | 709 | |
rgrover1 | 538:00d5affbb2b2 | 710 | /** |
rgrover1 | 538:00d5affbb2b2 | 711 | * Set the GAP peripheral preferred connection parameters. These are the |
rgrover1 | 538:00d5affbb2b2 | 712 | * defaults that the peripheral would like to have in a connection. The |
rgrover1 | 538:00d5affbb2b2 | 713 | * choice of the connection parameters is eventually up to the central. |
rgrover1 | 538:00d5affbb2b2 | 714 | * |
rgrover1 | 538:00d5affbb2b2 | 715 | * @param[in] params |
rgrover1 | 538:00d5affbb2b2 | 716 | * The structure containing the desired parameters. |
rgrover1 | 538:00d5affbb2b2 | 717 | * |
rgrover1 | 538:00d5affbb2b2 | 718 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 719 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 720 | * ble.setPreferredConnectionParams() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 721 | * ble.gap().setPreferredConnectionParams(). |
rgrover1 | 538:00d5affbb2b2 | 722 | */ |
rgrover1 | 538:00d5affbb2b2 | 723 | ble_error_t setPreferredConnectionParams(const Gap::ConnectionParams_t *params) { |
rgrover1 | 538:00d5affbb2b2 | 724 | return gap().setPreferredConnectionParams(params); |
rgrover1 | 538:00d5affbb2b2 | 725 | } |
rgrover1 | 538:00d5affbb2b2 | 726 | |
rgrover1 | 538:00d5affbb2b2 | 727 | /** |
rgrover1 | 538:00d5affbb2b2 | 728 | * Update connection parameters while in the peripheral role. |
rgrover1 | 538:00d5affbb2b2 | 729 | * @details In the peripheral role, this will send the corresponding L2CAP request to the connected peer and wait for |
rgrover1 | 538:00d5affbb2b2 | 730 | * the central to perform the procedure. |
rgrover1 | 538:00d5affbb2b2 | 731 | * @param[in] handle |
rgrover1 | 538:00d5affbb2b2 | 732 | * Connection Handle |
rgrover1 | 538:00d5affbb2b2 | 733 | * @param[in] params |
rgrover1 | 538:00d5affbb2b2 | 734 | * Pointer to desired connection parameters. If NULL is provided on a peripheral role, |
rgrover1 | 538:00d5affbb2b2 | 735 | * the parameters in the PPCP characteristic of the GAP service will be used instead. |
rgrover1 | 538:00d5affbb2b2 | 736 | * |
rgrover1 | 538:00d5affbb2b2 | 737 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 738 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 739 | * ble.updateConnectionParams() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 740 | * ble.gap().updateConnectionParams(). |
rgrover1 | 538:00d5affbb2b2 | 741 | */ |
rgrover1 | 538:00d5affbb2b2 | 742 | ble_error_t updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) { |
rgrover1 | 538:00d5affbb2b2 | 743 | return gap().updateConnectionParams(handle, params); |
rgrover1 | 538:00d5affbb2b2 | 744 | } |
rgrover1 | 538:00d5affbb2b2 | 745 | |
rgrover1 | 538:00d5affbb2b2 | 746 | /** |
rgrover1 | 538:00d5affbb2b2 | 747 | * Set the device name characteristic in the GAP service. |
rgrover1 | 538:00d5affbb2b2 | 748 | * @param[in] deviceName |
rgrover1 | 538:00d5affbb2b2 | 749 | * The new value for the device-name. This is a UTF-8 encoded, <b>NULL-terminated</b> string. |
rgrover1 | 538:00d5affbb2b2 | 750 | * |
rgrover1 | 538:00d5affbb2b2 | 751 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 752 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 753 | * ble.setDeviceName() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 754 | * ble.gap().setDeviceName(). |
rgrover1 | 538:00d5affbb2b2 | 755 | */ |
rgrover1 | 538:00d5affbb2b2 | 756 | ble_error_t setDeviceName(const uint8_t *deviceName) { |
rgrover1 | 538:00d5affbb2b2 | 757 | return gap().setDeviceName(deviceName); |
rgrover1 | 538:00d5affbb2b2 | 758 | } |
rgrover1 | 538:00d5affbb2b2 | 759 | |
rgrover1 | 538:00d5affbb2b2 | 760 | /** |
rgrover1 | 538:00d5affbb2b2 | 761 | * Get the value of the device name characteristic in the GAP service. |
rgrover1 | 538:00d5affbb2b2 | 762 | * @param[out] deviceName |
rgrover1 | 538:00d5affbb2b2 | 763 | * Pointer to an empty buffer where the UTF-8 *non NULL- |
rgrover1 | 538:00d5affbb2b2 | 764 | * terminated* string will be placed. Set this |
rgrover1 | 538:00d5affbb2b2 | 765 | * value to NULL in order to obtain the deviceName-length |
rgrover1 | 538:00d5affbb2b2 | 766 | * from the 'length' parameter. |
rgrover1 | 538:00d5affbb2b2 | 767 | * |
rgrover1 | 538:00d5affbb2b2 | 768 | * @param[in/out] lengthP |
rgrover1 | 538:00d5affbb2b2 | 769 | * (on input) Length of the buffer pointed to by deviceName; |
rgrover1 | 538:00d5affbb2b2 | 770 | * (on output) the complete device name length (without the |
rgrover1 | 538:00d5affbb2b2 | 771 | * null terminator). |
rgrover1 | 538:00d5affbb2b2 | 772 | * |
rgrover1 | 538:00d5affbb2b2 | 773 | * @note If the device name is longer than the size of the supplied buffer, |
rgrover1 | 538:00d5affbb2b2 | 774 | * length will return the complete device name length, and not the |
rgrover1 | 538:00d5affbb2b2 | 775 | * number of bytes actually returned in deviceName. The application may |
rgrover1 | 538:00d5affbb2b2 | 776 | * use this information to retry with a suitable buffer size. |
rgrover1 | 538:00d5affbb2b2 | 777 | * |
rgrover1 | 538:00d5affbb2b2 | 778 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 779 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 780 | * ble.getDeviceName() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 781 | * ble.gap().getDeviceName(). |
rgrover1 | 538:00d5affbb2b2 | 782 | */ |
rgrover1 | 538:00d5affbb2b2 | 783 | ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP) { |
rgrover1 | 538:00d5affbb2b2 | 784 | return gap().getDeviceName(deviceName, lengthP); |
rgrover1 | 538:00d5affbb2b2 | 785 | } |
rgrover1 | 538:00d5affbb2b2 | 786 | |
rgrover1 | 538:00d5affbb2b2 | 787 | /** |
rgrover1 | 538:00d5affbb2b2 | 788 | * Set the appearance characteristic in the GAP service. |
rgrover1 | 538:00d5affbb2b2 | 789 | * @param[in] appearance |
rgrover1 | 538:00d5affbb2b2 | 790 | * The new value for the device-appearance. |
rgrover1 | 538:00d5affbb2b2 | 791 | * |
rgrover1 | 538:00d5affbb2b2 | 792 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 793 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 794 | * ble.setAppearance() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 795 | * ble.gap().setAppearance(). |
rgrover1 | 538:00d5affbb2b2 | 796 | */ |
rgrover1 | 538:00d5affbb2b2 | 797 | ble_error_t setAppearance(GapAdvertisingData::Appearance appearance) { |
rgrover1 | 538:00d5affbb2b2 | 798 | return gap().setAppearance(appearance); |
rgrover1 | 538:00d5affbb2b2 | 799 | } |
rgrover1 | 538:00d5affbb2b2 | 800 | |
rgrover1 | 538:00d5affbb2b2 | 801 | /** |
rgrover1 | 538:00d5affbb2b2 | 802 | * Get the appearance characteristic in the GAP service. |
rgrover1 | 538:00d5affbb2b2 | 803 | * @param[out] appearance |
rgrover1 | 538:00d5affbb2b2 | 804 | * The new value for the device-appearance. |
rgrover1 | 538:00d5affbb2b2 | 805 | * |
rgrover1 | 538:00d5affbb2b2 | 806 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 807 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 808 | * ble.getAppearance() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 809 | * ble.gap().getAppearance(). |
rgrover1 | 538:00d5affbb2b2 | 810 | */ |
rgrover1 | 538:00d5affbb2b2 | 811 | ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP) { |
rgrover1 | 538:00d5affbb2b2 | 812 | return gap().getAppearance(appearanceP); |
rgrover1 | 538:00d5affbb2b2 | 813 | } |
rgrover1 | 538:00d5affbb2b2 | 814 | |
rgrover1 | 538:00d5affbb2b2 | 815 | /** |
rgrover1 | 538:00d5affbb2b2 | 816 | * Set the radio's transmit power. |
rgrover1 | 538:00d5affbb2b2 | 817 | * @param[in] txPower Radio transmit power in dBm. |
rgrover1 | 538:00d5affbb2b2 | 818 | * |
rgrover1 | 538:00d5affbb2b2 | 819 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 820 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 821 | * ble.setTxPower() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 822 | * ble.gap().setTxPower(). |
rgrover1 | 538:00d5affbb2b2 | 823 | */ |
rgrover1 | 538:00d5affbb2b2 | 824 | ble_error_t setTxPower(int8_t txPower) { |
rgrover1 | 538:00d5affbb2b2 | 825 | return gap().setTxPower(txPower); |
rgrover1 | 538:00d5affbb2b2 | 826 | } |
rgrover1 | 538:00d5affbb2b2 | 827 | |
rgrover1 | 538:00d5affbb2b2 | 828 | /** |
rgrover1 | 538:00d5affbb2b2 | 829 | * Query the underlying stack for permitted arguments for setTxPower(). |
rgrover1 | 538:00d5affbb2b2 | 830 | * |
rgrover1 | 538:00d5affbb2b2 | 831 | * @param[out] valueArrayPP |
rgrover1 | 538:00d5affbb2b2 | 832 | * Out parameter to receive the immutable array of Tx values. |
rgrover1 | 538:00d5affbb2b2 | 833 | * @param[out] countP |
rgrover1 | 538:00d5affbb2b2 | 834 | * Out parameter to receive the array's size. |
rgrover1 | 538:00d5affbb2b2 | 835 | * |
rgrover1 | 538:00d5affbb2b2 | 836 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 837 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 838 | * ble.getPermittedTxPowerValues() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 839 | * ble.gap().getPermittedTxPowerValues(). |
rgrover1 | 538:00d5affbb2b2 | 840 | */ |
rgrover1 | 538:00d5affbb2b2 | 841 | void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP) { |
rgrover1 | 538:00d5affbb2b2 | 842 | gap().getPermittedTxPowerValues(valueArrayPP, countP); |
rgrover1 | 538:00d5affbb2b2 | 843 | } |
rgrover1 | 529:8d21604fe31d | 844 | |
rgrover1 | 529:8d21604fe31d | 845 | /** |
rgrover1 | 529:8d21604fe31d | 846 | * Add a service declaration to the local server ATT table. Also add the |
rgrover1 | 529:8d21604fe31d | 847 | * characteristics contained within. |
rgrover1 | 540:0b6e82025358 | 848 | * |
rgrover1 | 540:0b6e82025358 | 849 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 540:0b6e82025358 | 850 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 540:0b6e82025358 | 851 | * to ble.addService() should be replaced with |
rgrover1 | 540:0b6e82025358 | 852 | * ble.gattServer().addService(). |
rgrover1 | 529:8d21604fe31d | 853 | */ |
rgrover1 | 540:0b6e82025358 | 854 | ble_error_t addService(GattService &service) { |
rgrover1 | 540:0b6e82025358 | 855 | return gattServer().addService(service); |
rgrover1 | 540:0b6e82025358 | 856 | } |
rgrover1 | 540:0b6e82025358 | 857 | |
rgrover1 | 540:0b6e82025358 | 858 | /** |
rgrover1 | 540:0b6e82025358 | 859 | * Read the value of a characteristic from the local GattServer |
rgrover1 | 540:0b6e82025358 | 860 | * @param[in] attributeHandle |
rgrover1 | 540:0b6e82025358 | 861 | * Attribute handle for the value attribute of the characteristic. |
rgrover1 | 540:0b6e82025358 | 862 | * @param[out] buffer |
rgrover1 | 540:0b6e82025358 | 863 | * A buffer to hold the value being read. |
rgrover1 | 540:0b6e82025358 | 864 | * @param[in/out] lengthP |
rgrover1 | 540:0b6e82025358 | 865 | * Length of the buffer being supplied. If the attribute |
rgrover1 | 540:0b6e82025358 | 866 | * value is longer than the size of the supplied buffer, |
rgrover1 | 540:0b6e82025358 | 867 | * this variable will hold upon return the total attribute value length |
rgrover1 | 540:0b6e82025358 | 868 | * (excluding offset). The application may use this |
rgrover1 | 540:0b6e82025358 | 869 | * information to allocate a suitable buffer size. |
rgrover1 | 540:0b6e82025358 | 870 | * |
rgrover1 | 540:0b6e82025358 | 871 | * @return BLE_ERROR_NONE if a value was read successfully into the buffer. |
rgrover1 | 540:0b6e82025358 | 872 | * |
rgrover1 | 540:0b6e82025358 | 873 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 540:0b6e82025358 | 874 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 540:0b6e82025358 | 875 | * to ble.readCharacteristicValue() should be replaced with |
rgrover1 | 540:0b6e82025358 | 876 | * ble.gattServer().read(). |
rgrover1 | 540:0b6e82025358 | 877 | */ |
rgrover1 | 540:0b6e82025358 | 878 | ble_error_t readCharacteristicValue(GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) { |
rgrover1 | 540:0b6e82025358 | 879 | return gattServer().read(attributeHandle, buffer, lengthP); |
rgrover1 | 540:0b6e82025358 | 880 | } |
rgrover1 | 529:8d21604fe31d | 881 | |
rgrover1 | 529:8d21604fe31d | 882 | /** |
rgrover1 | 540:0b6e82025358 | 883 | * Read the value of a characteristic from the local GattServer |
rgrover1 | 540:0b6e82025358 | 884 | * @param[in] connectionHandle |
rgrover1 | 540:0b6e82025358 | 885 | * Connection Handle. |
rgrover1 | 540:0b6e82025358 | 886 | * @param[in] attributeHandle |
rgrover1 | 540:0b6e82025358 | 887 | * Attribute handle for the value attribute of the characteristic. |
rgrover1 | 540:0b6e82025358 | 888 | * @param[out] buffer |
rgrover1 | 540:0b6e82025358 | 889 | * A buffer to hold the value being read. |
rgrover1 | 540:0b6e82025358 | 890 | * @param[in/out] lengthP |
rgrover1 | 540:0b6e82025358 | 891 | * Length of the buffer being supplied. If the attribute |
rgrover1 | 540:0b6e82025358 | 892 | * value is longer than the size of the supplied buffer, |
rgrover1 | 540:0b6e82025358 | 893 | * this variable will hold upon return the total attribute value length |
rgrover1 | 540:0b6e82025358 | 894 | * (excluding offset). The application may use this |
rgrover1 | 540:0b6e82025358 | 895 | * information to allocate a suitable buffer size. |
rgrover1 | 540:0b6e82025358 | 896 | * |
rgrover1 | 540:0b6e82025358 | 897 | * @return BLE_ERROR_NONE if a value was read successfully into the buffer. |
rgrover1 | 540:0b6e82025358 | 898 | * |
rgrover1 | 540:0b6e82025358 | 899 | * @note This API is a version of above with an additional connection handle |
rgrover1 | 540:0b6e82025358 | 900 | * parameter to allow fetches for connection-specific multivalued |
rgrover1 | 540:0b6e82025358 | 901 | * attribtues (such as the CCCDs). |
rgrover1 | 540:0b6e82025358 | 902 | * |
rgrover1 | 540:0b6e82025358 | 903 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 540:0b6e82025358 | 904 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 540:0b6e82025358 | 905 | * to ble.readCharacteristicValue() should be replaced with |
rgrover1 | 540:0b6e82025358 | 906 | * ble.gattServer().read(). |
rgrover1 | 529:8d21604fe31d | 907 | */ |
rgrover1 | 540:0b6e82025358 | 908 | ble_error_t readCharacteristicValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) { |
rgrover1 | 540:0b6e82025358 | 909 | return gattServer().read(connectionHandle, attributeHandle, buffer, lengthP); |
rgrover1 | 540:0b6e82025358 | 910 | } |
rgrover1 | 529:8d21604fe31d | 911 | |
rgrover1 | 529:8d21604fe31d | 912 | /** |
rgrover1 | 540:0b6e82025358 | 913 | * Update the value of a characteristic on the local GattServer. |
rgrover1 | 540:0b6e82025358 | 914 | * |
rgrover1 | 540:0b6e82025358 | 915 | * @param[in] attributeHandle |
rgrover1 | 540:0b6e82025358 | 916 | * Handle for the value attribute of the Characteristic. |
rgrover1 | 540:0b6e82025358 | 917 | * @param[in] value |
rgrover1 | 540:0b6e82025358 | 918 | * A pointer to a buffer holding the new value |
rgrover1 | 540:0b6e82025358 | 919 | * @param[in] size |
rgrover1 | 540:0b6e82025358 | 920 | * Size of the new value (in bytes). |
rgrover1 | 540:0b6e82025358 | 921 | * @param[in] localOnly |
rgrover1 | 540:0b6e82025358 | 922 | * Should this update be kept on the local |
rgrover1 | 540:0b6e82025358 | 923 | * GattServer regardless of the state of the |
rgrover1 | 540:0b6e82025358 | 924 | * notify/indicate flag in the CCCD for this |
rgrover1 | 540:0b6e82025358 | 925 | * Characteristic? If set to true, no notification |
rgrover1 | 540:0b6e82025358 | 926 | * or indication is generated. |
rgrover1 | 540:0b6e82025358 | 927 | * |
rgrover1 | 540:0b6e82025358 | 928 | * @return BLE_ERROR_NONE if we have successfully set the value of the attribute. |
rgrover1 | 540:0b6e82025358 | 929 | * |
rgrover1 | 540:0b6e82025358 | 930 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 540:0b6e82025358 | 931 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 540:0b6e82025358 | 932 | * to ble.updateCharacteristicValue() should be replaced with |
rgrover1 | 540:0b6e82025358 | 933 | * ble.gattServer().write(). |
rgrover1 | 529:8d21604fe31d | 934 | */ |
rgrover1 | 540:0b6e82025358 | 935 | ble_error_t updateCharacteristicValue(GattAttribute::Handle_t attributeHandle, |
rgrover1 | 540:0b6e82025358 | 936 | const uint8_t *value, |
rgrover1 | 540:0b6e82025358 | 937 | uint16_t size, |
rgrover1 | 540:0b6e82025358 | 938 | bool localOnly = false) { |
rgrover1 | 540:0b6e82025358 | 939 | return gattServer().write(attributeHandle, value, size, localOnly); |
rgrover1 | 540:0b6e82025358 | 940 | } |
rgrover1 | 540:0b6e82025358 | 941 | |
rgrover1 | 529:8d21604fe31d | 942 | /** |
rgrover1 | 540:0b6e82025358 | 943 | * Update the value of a characteristic on the local GattServer. A version |
rgrover1 | 540:0b6e82025358 | 944 | * of the same as above with connection handle parameter to allow updates |
rgrover1 | 540:0b6e82025358 | 945 | * for connection-specific multivalued attribtues (such as the CCCDs). |
rgrover1 | 540:0b6e82025358 | 946 | * |
rgrover1 | 540:0b6e82025358 | 947 | * @param[in] connectionHandle |
rgrover1 | 540:0b6e82025358 | 948 | * Connection Handle. |
rgrover1 | 540:0b6e82025358 | 949 | * @param[in] attributeHandle |
rgrover1 | 540:0b6e82025358 | 950 | * Handle for the value attribute of the Characteristic. |
rgrover1 | 540:0b6e82025358 | 951 | * @param[in] value |
rgrover1 | 540:0b6e82025358 | 952 | * A pointer to a buffer holding the new value |
rgrover1 | 540:0b6e82025358 | 953 | * @param[in] size |
rgrover1 | 540:0b6e82025358 | 954 | * Size of the new value (in bytes). |
rgrover1 | 540:0b6e82025358 | 955 | * @param[in] localOnly |
rgrover1 | 540:0b6e82025358 | 956 | * Should this update be kept on the local |
rgrover1 | 540:0b6e82025358 | 957 | * GattServer regardless of the state of the |
rgrover1 | 540:0b6e82025358 | 958 | * notify/indicate flag in the CCCD for this |
rgrover1 | 540:0b6e82025358 | 959 | * Characteristic? If set to true, no notification |
rgrover1 | 540:0b6e82025358 | 960 | * or indication is generated. |
rgrover1 | 540:0b6e82025358 | 961 | * |
rgrover1 | 540:0b6e82025358 | 962 | * @return BLE_ERROR_NONE if we have successfully set the value of the attribute. |
rgrover1 | 540:0b6e82025358 | 963 | * |
rgrover1 | 540:0b6e82025358 | 964 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 540:0b6e82025358 | 965 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 540:0b6e82025358 | 966 | * to ble.updateCharacteristicValue() should be replaced with |
rgrover1 | 540:0b6e82025358 | 967 | * ble.gattServer().write(). |
rgrover1 | 529:8d21604fe31d | 968 | */ |
rgrover1 | 529:8d21604fe31d | 969 | ble_error_t updateCharacteristicValue(Gap::Handle_t connectionHandle, |
rgrover1 | 529:8d21604fe31d | 970 | GattAttribute::Handle_t attributeHandle, |
rgrover1 | 529:8d21604fe31d | 971 | const uint8_t *value, |
rgrover1 | 529:8d21604fe31d | 972 | uint16_t size, |
rgrover1 | 540:0b6e82025358 | 973 | bool localOnly = false) { |
rgrover1 | 540:0b6e82025358 | 974 | return gattServer().write(connectionHandle, attributeHandle, value, size, localOnly); |
rgrover1 | 540:0b6e82025358 | 975 | } |
rgrover1 | 529:8d21604fe31d | 976 | |
rgrover1 | 542:aa30f63e7b3f | 977 | /** |
rgrover1 | 547:9fdf3d960d12 | 978 | * Enable the BLE stack's Security Manager. The Security Manager implements |
rgrover1 | 547:9fdf3d960d12 | 979 | * the actual cryptographic algorithms and protocol exchanges that allow two |
rgrover1 | 547:9fdf3d960d12 | 980 | * devices to securely exchange data and privately detect each other. |
rgrover1 | 547:9fdf3d960d12 | 981 | * Calling this API is a prerequisite for encryption and pairing (bonding). |
rgrover1 | 547:9fdf3d960d12 | 982 | * |
rgrover1 | 547:9fdf3d960d12 | 983 | * @param[in] enableBonding Allow for bonding. |
rgrover1 | 547:9fdf3d960d12 | 984 | * @param[in] requireMITM Require protection for man-in-the-middle attacks. |
rgrover1 | 547:9fdf3d960d12 | 985 | * @param[in] iocaps To specify IO capabilities of this peripheral, |
rgrover1 | 547:9fdf3d960d12 | 986 | * such as availability of a display or keyboard to |
rgrover1 | 547:9fdf3d960d12 | 987 | * support out-of-band exchanges of security data. |
rgrover1 | 547:9fdf3d960d12 | 988 | * @param[in] passkey To specify a static passkey. |
rgrover1 | 547:9fdf3d960d12 | 989 | * |
rgrover1 | 547:9fdf3d960d12 | 990 | * @return BLE_ERROR_NONE on success. |
rgrover1 | 547:9fdf3d960d12 | 991 | * |
rgrover1 | 547:9fdf3d960d12 | 992 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 993 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 994 | * call to ble.initializeSecurity(...) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 995 | * ble.securityManager().init(...). |
rgrover1 | 547:9fdf3d960d12 | 996 | */ |
rgrover1 | 547:9fdf3d960d12 | 997 | ble_error_t initializeSecurity(bool enableBonding = true, |
rgrover1 | 547:9fdf3d960d12 | 998 | bool requireMITM = true, |
rgrover1 | 547:9fdf3d960d12 | 999 | SecurityManager::SecurityIOCapabilities_t iocaps = SecurityManager::IO_CAPS_NONE, |
rgrover1 | 547:9fdf3d960d12 | 1000 | const SecurityManager::Passkey_t passkey = NULL) { |
rgrover1 | 547:9fdf3d960d12 | 1001 | return securityManager().init(enableBonding, requireMITM, iocaps, passkey); |
rgrover1 | 547:9fdf3d960d12 | 1002 | } |
rgrover1 | 547:9fdf3d960d12 | 1003 | |
rgrover1 | 547:9fdf3d960d12 | 1004 | /** |
rgrover1 | 547:9fdf3d960d12 | 1005 | * Get the security status of a connection. |
rgrover1 | 547:9fdf3d960d12 | 1006 | * |
rgrover1 | 547:9fdf3d960d12 | 1007 | * @param[in] connectionHandle Handle to identify the connection. |
rgrover1 | 547:9fdf3d960d12 | 1008 | * @param[out] securityStatusP security status. |
rgrover1 | 547:9fdf3d960d12 | 1009 | * |
rgrover1 | 547:9fdf3d960d12 | 1010 | * @return BLE_SUCCESS Or appropriate error code indicating reason for failure. |
rgrover1 | 547:9fdf3d960d12 | 1011 | * |
rgrover1 | 547:9fdf3d960d12 | 1012 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1013 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1014 | * call to ble.getLinkSecurity(...) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1015 | * ble.securityManager().getLinkSecurity(...). |
rgrover1 | 547:9fdf3d960d12 | 1016 | */ |
rgrover1 | 547:9fdf3d960d12 | 1017 | ble_error_t getLinkSecurity(Gap::Handle_t connectionHandle, SecurityManager::LinkSecurityStatus_t *securityStatusP) { |
rgrover1 | 547:9fdf3d960d12 | 1018 | return securityManager().getLinkSecurity(connectionHandle, securityStatusP); |
rgrover1 | 547:9fdf3d960d12 | 1019 | } |
rgrover1 | 547:9fdf3d960d12 | 1020 | |
rgrover1 | 547:9fdf3d960d12 | 1021 | /** |
rgrover1 | 547:9fdf3d960d12 | 1022 | * Delete all peer device context and all related bonding information from |
rgrover1 | 547:9fdf3d960d12 | 1023 | * the database within the security manager. |
rgrover1 | 547:9fdf3d960d12 | 1024 | * |
rgrover1 | 547:9fdf3d960d12 | 1025 | * @retval BLE_ERROR_NONE On success, else an error code indicating reason for failure. |
rgrover1 | 547:9fdf3d960d12 | 1026 | * @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization and/or |
rgrover1 | 547:9fdf3d960d12 | 1027 | * application registration. |
rgrover1 | 547:9fdf3d960d12 | 1028 | * |
rgrover1 | 547:9fdf3d960d12 | 1029 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1030 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1031 | * call to ble.purgeAllBondingState() should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1032 | * ble.securityManager().purgeAllBondingState(). |
rgrover1 | 547:9fdf3d960d12 | 1033 | */ |
rgrover1 | 547:9fdf3d960d12 | 1034 | ble_error_t purgeAllBondingState(void) { |
rgrover1 | 547:9fdf3d960d12 | 1035 | return securityManager().purgeAllBondingState(); |
rgrover1 | 547:9fdf3d960d12 | 1036 | } |
rgrover1 | 547:9fdf3d960d12 | 1037 | |
rgrover1 | 547:9fdf3d960d12 | 1038 | /** |
rgrover1 | 542:aa30f63e7b3f | 1039 | * Setup a callback for timeout events. Refer to Gap::TimeoutSource_t for |
rgrover1 | 542:aa30f63e7b3f | 1040 | * possible event types. |
rgrover1 | 542:aa30f63e7b3f | 1041 | * |
rgrover1 | 542:aa30f63e7b3f | 1042 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 542:aa30f63e7b3f | 1043 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 542:aa30f63e7b3f | 1044 | * to ble.onTimeout(callback) should be replaced with |
rgrover1 | 542:aa30f63e7b3f | 1045 | * ble.gap().onTimeout(callback). |
rgrover1 | 542:aa30f63e7b3f | 1046 | */ |
rgrover1 | 542:aa30f63e7b3f | 1047 | void onTimeout(Gap::TimeoutEventCallback_t timeoutCallback) { |
rgrover1 | 542:aa30f63e7b3f | 1048 | gap().onTimeout(timeoutCallback); |
rgrover1 | 542:aa30f63e7b3f | 1049 | } |
rgrover1 | 529:8d21604fe31d | 1050 | |
rgrover1 | 544:4defb791aa94 | 1051 | /** |
rgrover1 | 544:4defb791aa94 | 1052 | * Setup a callback for connection events. Refer to Gap::ConnectionEventCallback_t. |
rgrover1 | 544:4defb791aa94 | 1053 | * |
rgrover1 | 544:4defb791aa94 | 1054 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 544:4defb791aa94 | 1055 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 544:4defb791aa94 | 1056 | * to ble.onConnection(callback) should be replaced with |
rgrover1 | 544:4defb791aa94 | 1057 | * ble.gap().onConnection(callback). |
rgrover1 | 544:4defb791aa94 | 1058 | */ |
rgrover1 | 544:4defb791aa94 | 1059 | void onConnection(Gap::ConnectionEventCallback_t connectionCallback) { |
rgrover1 | 544:4defb791aa94 | 1060 | gap().onConnection(connectionCallback); |
rgrover1 | 544:4defb791aa94 | 1061 | } |
rgrover1 | 544:4defb791aa94 | 1062 | |
rgrover1 | 529:8d21604fe31d | 1063 | /** |
rgrover1 | 541:1fb1e0b809eb | 1064 | * Used to setup a callback for GAP disconnection. |
rgrover1 | 545:840f428d18c7 | 1065 | * |
rgrover1 | 545:840f428d18c7 | 1066 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 545:840f428d18c7 | 1067 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 545:840f428d18c7 | 1068 | * to ble.onDisconnection(callback) should be replaced with |
rgrover1 | 545:840f428d18c7 | 1069 | * ble.gap().onDisconnection(callback). |
rgrover1 | 529:8d21604fe31d | 1070 | */ |
rgrover1 | 545:840f428d18c7 | 1071 | void onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback) { |
rgrover1 | 545:840f428d18c7 | 1072 | gap().onDisconnection(disconnectionCallback); |
rgrover1 | 545:840f428d18c7 | 1073 | } |
rgrover1 | 529:8d21604fe31d | 1074 | |
rgrover1 | 529:8d21604fe31d | 1075 | /** |
rgrover1 | 541:1fb1e0b809eb | 1076 | * Append to a chain of callbacks to be invoked upon disconnection; these |
rgrover1 | 541:1fb1e0b809eb | 1077 | * callbacks receive no context and are therefore different from the |
rgrover1 | 541:1fb1e0b809eb | 1078 | * onDisconnection callback. |
rgrover1 | 545:840f428d18c7 | 1079 | * |
rgrover1 | 545:840f428d18c7 | 1080 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 545:840f428d18c7 | 1081 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 545:840f428d18c7 | 1082 | * to ble.addToDisconnectionCallchain(...) should be replaced with |
rgrover1 | 545:840f428d18c7 | 1083 | * ble.gap().addToDisconnectionCallchain(...). |
rgrover1 | 529:8d21604fe31d | 1084 | */ |
rgrover1 | 541:1fb1e0b809eb | 1085 | template<typename T> |
rgrover1 | 545:840f428d18c7 | 1086 | void addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)) { |
rgrover1 | 545:840f428d18c7 | 1087 | gap().addToDisconnectionCallChain(tptr, mptr); |
rgrover1 | 545:840f428d18c7 | 1088 | } |
rgrover1 | 529:8d21604fe31d | 1089 | |
rgrover1 | 529:8d21604fe31d | 1090 | /** |
rgrover1 | 546:45bbdb1d5eca | 1091 | * Radio Notification is a feature that enables ACTIVE and INACTIVE |
rgrover1 | 546:45bbdb1d5eca | 1092 | * (nACTIVE) signals from the stack that notify the application when the |
rgrover1 | 546:45bbdb1d5eca | 1093 | * radio is in use. The signal is sent using software interrupt. |
rgrover1 | 546:45bbdb1d5eca | 1094 | * |
rgrover1 | 546:45bbdb1d5eca | 1095 | * The ACTIVE signal is sent before the Radio Event starts. The nACTIVE |
rgrover1 | 546:45bbdb1d5eca | 1096 | * signal is sent at the end of the Radio Event. These signals can be used |
rgrover1 | 546:45bbdb1d5eca | 1097 | * by the application programmer to synchronize application logic with radio |
rgrover1 | 546:45bbdb1d5eca | 1098 | * activity. For example, the ACTIVE signal can be used to shut off external |
rgrover1 | 546:45bbdb1d5eca | 1099 | * devices to manage peak current drawn during periods when the radio is on, |
rgrover1 | 546:45bbdb1d5eca | 1100 | * or to trigger sensor data collection for transmission in the Radio Event. |
rgrover1 | 546:45bbdb1d5eca | 1101 | * |
rgrover1 | 546:45bbdb1d5eca | 1102 | * @param callback |
rgrover1 | 546:45bbdb1d5eca | 1103 | * The application handler to be invoked in response to a radio |
rgrover1 | 546:45bbdb1d5eca | 1104 | * ACTIVE/INACTIVE event. |
rgrover1 | 546:45bbdb1d5eca | 1105 | * |
rgrover1 | 546:45bbdb1d5eca | 1106 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 546:45bbdb1d5eca | 1107 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 546:45bbdb1d5eca | 1108 | * to ble.onRadioNotification(...) should be replaced with |
rgrover1 | 546:45bbdb1d5eca | 1109 | * ble.gap().onRadioNotification(...). |
rgrover1 | 546:45bbdb1d5eca | 1110 | */ |
rgrover1 | 546:45bbdb1d5eca | 1111 | void onRadioNotification(Gap::RadioNotificationEventCallback_t callback) { |
rgrover1 | 546:45bbdb1d5eca | 1112 | gap().onRadioNotification(callback); |
rgrover1 | 546:45bbdb1d5eca | 1113 | } |
rgrover1 | 546:45bbdb1d5eca | 1114 | |
rgrover1 | 546:45bbdb1d5eca | 1115 | /** |
rgrover1 | 541:1fb1e0b809eb | 1116 | * Add a callback for the GATT event DATA_SENT (which is triggered when |
rgrover1 | 541:1fb1e0b809eb | 1117 | * updates are sent out by GATT in the form of notifications). |
rgrover1 | 529:8d21604fe31d | 1118 | * |
rgrover1 | 541:1fb1e0b809eb | 1119 | * @Note: it is possible to chain together multiple onDataSent callbacks |
rgrover1 | 541:1fb1e0b809eb | 1120 | * (potentially from different modules of an application) to receive updates |
rgrover1 | 541:1fb1e0b809eb | 1121 | * to characteristics. |
rgrover1 | 529:8d21604fe31d | 1122 | * |
rgrover1 | 541:1fb1e0b809eb | 1123 | * @Note: it is also possible to setup a callback into a member function of |
rgrover1 | 541:1fb1e0b809eb | 1124 | * some object. |
rgrover1 | 548:f84c514eee35 | 1125 | * |
rgrover1 | 548:f84c514eee35 | 1126 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 548:f84c514eee35 | 1127 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 548:f84c514eee35 | 1128 | * to ble.onDataSent(...) should be replaced with |
rgrover1 | 550:0ade048a19a3 | 1129 | * ble.gattServer().onDataSent(...). |
rgrover1 | 529:8d21604fe31d | 1130 | */ |
rgrover1 | 548:f84c514eee35 | 1131 | void onDataSent(void (*callback)(unsigned count)) { |
rgrover1 | 548:f84c514eee35 | 1132 | gattServer().onDataSent(callback); |
rgrover1 | 548:f84c514eee35 | 1133 | } |
rgrover1 | 548:f84c514eee35 | 1134 | template <typename T> void onDataSent(T * objPtr, void (T::*memberPtr)(unsigned count)) { |
rgrover1 | 548:f84c514eee35 | 1135 | gattServer().onDataSent(objPtr, memberPtr); |
rgrover1 | 548:f84c514eee35 | 1136 | } |
rgrover1 | 529:8d21604fe31d | 1137 | |
rgrover1 | 529:8d21604fe31d | 1138 | /** |
rgrover1 | 549:623e4c0f0b6e | 1139 | * Setup a callback for when an attribute has its value updated by or at the |
rgrover1 | 549:623e4c0f0b6e | 1140 | * connected peer. For a peripheral, this callback triggered when the local |
rgrover1 | 549:623e4c0f0b6e | 1141 | * GATT server has an attribute updated by a write command from the peer. |
rgrover1 | 549:623e4c0f0b6e | 1142 | * For a Central, this callback is triggered when a response is received for |
rgrover1 | 549:623e4c0f0b6e | 1143 | * a write request. |
rgrover1 | 529:8d21604fe31d | 1144 | * |
rgrover1 | 541:1fb1e0b809eb | 1145 | * @Note: it is possible to chain together multiple onDataWritten callbacks |
rgrover1 | 541:1fb1e0b809eb | 1146 | * (potentially from different modules of an application) to receive updates |
rgrover1 | 541:1fb1e0b809eb | 1147 | * to characteristics. Many services, such as DFU and UART add their own |
rgrover1 | 541:1fb1e0b809eb | 1148 | * onDataWritten callbacks behind the scenes to trap interesting events. |
rgrover1 | 529:8d21604fe31d | 1149 | * |
rgrover1 | 541:1fb1e0b809eb | 1150 | * @Note: it is also possible to setup a callback into a member function of |
rgrover1 | 541:1fb1e0b809eb | 1151 | * some object. |
rgrover1 | 549:623e4c0f0b6e | 1152 | * |
rgrover1 | 549:623e4c0f0b6e | 1153 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 549:623e4c0f0b6e | 1154 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 549:623e4c0f0b6e | 1155 | * to ble.onDataWritten(...) should be replaced with |
rgrover1 | 550:0ade048a19a3 | 1156 | * ble.gattServer().onDataWritten(...). |
rgrover1 | 529:8d21604fe31d | 1157 | */ |
rgrover1 | 549:623e4c0f0b6e | 1158 | void onDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP)) { |
rgrover1 | 549:623e4c0f0b6e | 1159 | gattServer().onDataWritten(callback); |
rgrover1 | 549:623e4c0f0b6e | 1160 | } |
rgrover1 | 549:623e4c0f0b6e | 1161 | template <typename T> void onDataWritten(T * objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context)) { |
rgrover1 | 549:623e4c0f0b6e | 1162 | gattServer().onDataWritten(objPtr, memberPtr); |
rgrover1 | 549:623e4c0f0b6e | 1163 | } |
rgrover1 | 529:8d21604fe31d | 1164 | |
rgrover1 | 529:8d21604fe31d | 1165 | /** |
rgrover1 | 552:d79a7933a6d1 | 1166 | * Setup a callback to be invoked on the peripheral when an attribute is |
rgrover1 | 552:d79a7933a6d1 | 1167 | * being read by a remote client. |
rgrover1 | 541:1fb1e0b809eb | 1168 | * |
rgrover1 | 541:1fb1e0b809eb | 1169 | * @Note: this functionality may not be available on all underlying stacks. |
rgrover1 | 541:1fb1e0b809eb | 1170 | * You could use GattCharacteristic::setReadAuthorizationCallback() as an |
rgrover1 | 541:1fb1e0b809eb | 1171 | * alternative. |
rgrover1 | 541:1fb1e0b809eb | 1172 | * |
rgrover1 | 541:1fb1e0b809eb | 1173 | * @Note: it is possible to chain together multiple onDataRead callbacks |
rgrover1 | 541:1fb1e0b809eb | 1174 | * (potentially from different modules of an application) to receive updates |
rgrover1 | 541:1fb1e0b809eb | 1175 | * to characteristics. Services may add their own onDataRead callbacks |
rgrover1 | 541:1fb1e0b809eb | 1176 | * behind the scenes to trap interesting events. |
rgrover1 | 541:1fb1e0b809eb | 1177 | * |
rgrover1 | 541:1fb1e0b809eb | 1178 | * @Note: it is also possible to setup a callback into a member function of |
rgrover1 | 541:1fb1e0b809eb | 1179 | * some object. |
rgrover1 | 541:1fb1e0b809eb | 1180 | * |
rgrover1 | 541:1fb1e0b809eb | 1181 | * @return BLE_ERROR_NOT_IMPLEMENTED if this functionality isn't available; |
rgrover1 | 541:1fb1e0b809eb | 1182 | * else BLE_ERROR_NONE. |
rgrover1 | 552:d79a7933a6d1 | 1183 | * |
rgrover1 | 552:d79a7933a6d1 | 1184 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 552:d79a7933a6d1 | 1185 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 552:d79a7933a6d1 | 1186 | * to ble.onDataRead(...) should be replaced with |
rgrover1 | 552:d79a7933a6d1 | 1187 | * ble.gattServer().onDataRead(...). |
rgrover1 | 529:8d21604fe31d | 1188 | */ |
rgrover1 | 552:d79a7933a6d1 | 1189 | ble_error_t onDataRead(void (*callback)(const GattReadCallbackParams *eventDataP)) { |
rgrover1 | 552:d79a7933a6d1 | 1190 | return gattServer().onDataRead(callback); |
rgrover1 | 552:d79a7933a6d1 | 1191 | } |
rgrover1 | 552:d79a7933a6d1 | 1192 | template <typename T> ble_error_t onDataRead(T * objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context)) { |
rgrover1 | 552:d79a7933a6d1 | 1193 | return gattServer().onDataRead(objPtr, memberPtr); |
rgrover1 | 552:d79a7933a6d1 | 1194 | } |
rgrover1 | 541:1fb1e0b809eb | 1195 | |
rgrover1 | 551:35b3962903af | 1196 | /** |
rgrover1 | 551:35b3962903af | 1197 | * Setup a callback for when notifications/indications are enabled for a |
rgrover1 | 551:35b3962903af | 1198 | * characteristic on the local GattServer. |
rgrover1 | 551:35b3962903af | 1199 | * |
rgrover1 | 551:35b3962903af | 1200 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 551:35b3962903af | 1201 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 554:434770194877 | 1202 | * to ble.onUpdatesEnabled(callback) should be replaced with |
rgrover1 | 554:434770194877 | 1203 | * ble.gattServer().onUpdatesEnabled(callback). |
rgrover1 | 551:35b3962903af | 1204 | */ |
rgrover1 | 551:35b3962903af | 1205 | void onUpdatesEnabled(GattServer::EventCallback_t callback) { |
rgrover1 | 551:35b3962903af | 1206 | gattServer().onUpdatesEnabled(callback); |
rgrover1 | 551:35b3962903af | 1207 | } |
rgrover1 | 551:35b3962903af | 1208 | |
rgrover1 | 553:9bf985a8a49b | 1209 | /** |
rgrover1 | 553:9bf985a8a49b | 1210 | * Setup a callback for when notifications/indications are disabled for a |
rgrover1 | 553:9bf985a8a49b | 1211 | * characteristic on the local GattServer. |
rgrover1 | 553:9bf985a8a49b | 1212 | * |
rgrover1 | 553:9bf985a8a49b | 1213 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 553:9bf985a8a49b | 1214 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 554:434770194877 | 1215 | * to ble.onUpdatesEnabled(callback) should be replaced with |
rgrover1 | 554:434770194877 | 1216 | * ble.gattServer().onUpdatesEnabled(callback). |
rgrover1 | 553:9bf985a8a49b | 1217 | */ |
rgrover1 | 553:9bf985a8a49b | 1218 | void onUpdatesDisabled(GattServer::EventCallback_t callback) { |
rgrover1 | 553:9bf985a8a49b | 1219 | gattServer().onUpdatesDisabled(callback); |
rgrover1 | 553:9bf985a8a49b | 1220 | } |
rgrover1 | 553:9bf985a8a49b | 1221 | |
rgrover1 | 555:59e95a0efa37 | 1222 | /** |
rgrover1 | 555:59e95a0efa37 | 1223 | * Setup a callback for when the GATT server receives a response for an |
rgrover1 | 555:59e95a0efa37 | 1224 | * indication event sent previously. |
rgrover1 | 555:59e95a0efa37 | 1225 | * |
rgrover1 | 555:59e95a0efa37 | 1226 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 555:59e95a0efa37 | 1227 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 555:59e95a0efa37 | 1228 | * to ble.onConfirmationReceived(callback) should be replaced with |
rgrover1 | 555:59e95a0efa37 | 1229 | * ble.gattServer().onConfirmationReceived(callback). |
rgrover1 | 555:59e95a0efa37 | 1230 | */ |
rgrover1 | 555:59e95a0efa37 | 1231 | void onConfirmationReceived(GattServer::EventCallback_t callback) { |
rgrover1 | 555:59e95a0efa37 | 1232 | gattServer().onConfirmationReceived(callback); |
rgrover1 | 555:59e95a0efa37 | 1233 | } |
rgrover1 | 529:8d21604fe31d | 1234 | |
rgrover1 | 547:9fdf3d960d12 | 1235 | /** |
rgrover1 | 547:9fdf3d960d12 | 1236 | * Setup a callback for when the security setup procedure (key generation |
rgrover1 | 547:9fdf3d960d12 | 1237 | * and exchange) for a link has started. This will be skipped for bonded |
rgrover1 | 547:9fdf3d960d12 | 1238 | * devices. The callback is passed in parameters received from the peer's |
rgrover1 | 547:9fdf3d960d12 | 1239 | * security request: bool allowBonding, bool requireMITM, and |
rgrover1 | 547:9fdf3d960d12 | 1240 | * SecurityIOCapabilities_t. |
rgrover1 | 547:9fdf3d960d12 | 1241 | * |
rgrover1 | 547:9fdf3d960d12 | 1242 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1243 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1244 | * call to ble.onSecuritySetupInitiated(callback) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1245 | * ble.securityManager().onSecuritySetupInitiated(callback). |
rgrover1 | 547:9fdf3d960d12 | 1246 | */ |
rgrover1 | 547:9fdf3d960d12 | 1247 | void onSecuritySetupInitiated(SecurityManager::SecuritySetupInitiatedCallback_t callback) { |
rgrover1 | 547:9fdf3d960d12 | 1248 | securityManager().onSecuritySetupInitiated(callback); |
rgrover1 | 547:9fdf3d960d12 | 1249 | } |
rgrover1 | 547:9fdf3d960d12 | 1250 | |
rgrover1 | 547:9fdf3d960d12 | 1251 | /** |
rgrover1 | 547:9fdf3d960d12 | 1252 | * Setup a callback for when the security setup procedure (key generation |
rgrover1 | 547:9fdf3d960d12 | 1253 | * and exchange) for a link has completed. This will be skipped for bonded |
rgrover1 | 547:9fdf3d960d12 | 1254 | * devices. The callback is passed in the success/failure status of the |
rgrover1 | 547:9fdf3d960d12 | 1255 | * security setup procedure. |
rgrover1 | 547:9fdf3d960d12 | 1256 | * |
rgrover1 | 547:9fdf3d960d12 | 1257 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1258 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1259 | * call to ble.onSecuritySetupCompleted(callback) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1260 | * ble.securityManager().onSecuritySetupCompleted(callback). |
rgrover1 | 547:9fdf3d960d12 | 1261 | */ |
rgrover1 | 547:9fdf3d960d12 | 1262 | void onSecuritySetupCompleted(SecurityManager::SecuritySetupCompletedCallback_t callback) { |
rgrover1 | 547:9fdf3d960d12 | 1263 | securityManager().onSecuritySetupCompleted(callback); |
rgrover1 | 547:9fdf3d960d12 | 1264 | } |
rgrover1 | 547:9fdf3d960d12 | 1265 | |
rgrover1 | 547:9fdf3d960d12 | 1266 | /** |
rgrover1 | 547:9fdf3d960d12 | 1267 | * Setup a callback for when a link with the peer is secured. For bonded |
rgrover1 | 547:9fdf3d960d12 | 1268 | * devices, subsequent reconnections with bonded peer will result only in |
rgrover1 | 547:9fdf3d960d12 | 1269 | * this callback when the link is secured and setup procedures will not |
rgrover1 | 547:9fdf3d960d12 | 1270 | * occur unless the bonding information is either lost or deleted on either |
rgrover1 | 547:9fdf3d960d12 | 1271 | * or both sides. The callback is passed in a SecurityManager::SecurityMode_t according |
rgrover1 | 547:9fdf3d960d12 | 1272 | * to the level of security in effect for the secured link. |
rgrover1 | 547:9fdf3d960d12 | 1273 | * |
rgrover1 | 547:9fdf3d960d12 | 1274 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1275 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1276 | * call to ble.onLinkSecured(callback) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1277 | * ble.securityManager().onLinkSecured(callback). |
rgrover1 | 547:9fdf3d960d12 | 1278 | */ |
rgrover1 | 547:9fdf3d960d12 | 1279 | void onLinkSecured(SecurityManager::LinkSecuredCallback_t callback) { |
rgrover1 | 547:9fdf3d960d12 | 1280 | securityManager().onLinkSecured(callback); |
rgrover1 | 547:9fdf3d960d12 | 1281 | } |
rgrover1 | 547:9fdf3d960d12 | 1282 | |
rgrover1 | 547:9fdf3d960d12 | 1283 | /** |
rgrover1 | 547:9fdf3d960d12 | 1284 | * Setup a callback for successful bonding; i.e. that link-specific security |
rgrover1 | 547:9fdf3d960d12 | 1285 | * context is stored persistently for a peer device. |
rgrover1 | 547:9fdf3d960d12 | 1286 | * |
rgrover1 | 547:9fdf3d960d12 | 1287 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1288 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1289 | * call to ble.onSecurityContextStored(callback) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1290 | * ble.securityManager().onSecurityContextStored(callback). |
rgrover1 | 547:9fdf3d960d12 | 1291 | */ |
rgrover1 | 547:9fdf3d960d12 | 1292 | void onSecurityContextStored(SecurityManager::HandleSpecificEvent_t callback) { |
rgrover1 | 547:9fdf3d960d12 | 1293 | securityManager().onSecurityContextStored(callback); |
rgrover1 | 547:9fdf3d960d12 | 1294 | } |
rgrover1 | 547:9fdf3d960d12 | 1295 | |
rgrover1 | 547:9fdf3d960d12 | 1296 | /** |
rgrover1 | 547:9fdf3d960d12 | 1297 | * Setup a callback for when the passkey needs to be displayed on a |
rgrover1 | 547:9fdf3d960d12 | 1298 | * peripheral with DISPLAY capability. This happens when security is |
rgrover1 | 547:9fdf3d960d12 | 1299 | * configured to prevent Man-In-The-Middle attacks, and a PIN (or passkey) |
rgrover1 | 547:9fdf3d960d12 | 1300 | * needs to be exchanged between the peers to authenticate the connection |
rgrover1 | 547:9fdf3d960d12 | 1301 | * attempt. |
rgrover1 | 547:9fdf3d960d12 | 1302 | * |
rgrover1 | 547:9fdf3d960d12 | 1303 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1304 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1305 | * call to ble.onPasskeyDisplay(callback) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1306 | * ble.securityManager().onPasskeyDisplay(callback). |
rgrover1 | 547:9fdf3d960d12 | 1307 | */ |
rgrover1 | 547:9fdf3d960d12 | 1308 | void onPasskeyDisplay(SecurityManager::PasskeyDisplayCallback_t callback) { |
rgrover1 | 547:9fdf3d960d12 | 1309 | return securityManager().onPasskeyDisplay(callback); |
rgrover1 | 547:9fdf3d960d12 | 1310 | } |
rgrover1 | 547:9fdf3d960d12 | 1311 | |
rgrover1 | 529:8d21604fe31d | 1312 | public: |
rgrover1 | 532:bdcd44b03974 | 1313 | BLE() : transport(createBLEInstance()) { |
rgrover1 | 532:bdcd44b03974 | 1314 | /* empty */ |
rgrover1 | 529:8d21604fe31d | 1315 | } |
rgrover1 | 529:8d21604fe31d | 1316 | |
rgrover1 | 529:8d21604fe31d | 1317 | private: |
rgrover1 | 529:8d21604fe31d | 1318 | BLEInstanceBase *const transport; /* the device specific backend */ |
rgrover1 | 529:8d21604fe31d | 1319 | }; |
rgrover1 | 529:8d21604fe31d | 1320 | |
rgrover1 | 538:00d5affbb2b2 | 1321 | typedef BLE BLEDevice; /* DEPRECATED. This type alias is retained for the sake of compatibility with older |
rgrover1 | 529:8d21604fe31d | 1322 | * code. Will be dropped at some point soon.*/ |
rgrover1 | 529:8d21604fe31d | 1323 | |
rgrover1 | 529:8d21604fe31d | 1324 | #endif // ifndef __BLE_H__ |