BLE
Fork of BLE_API by
public/BLE.h@549:623e4c0f0b6e, 2015-06-19 (annotated)
- Committer:
- rgrover1
- Date:
- Fri Jun 19 15:52:09 2015 +0100
- Revision:
- 549:623e4c0f0b6e
- Parent:
- 548:f84c514eee35
- Child:
- 550:0ade048a19a3
Synchronized with git rev 962533e3
Author: Rohit Grover
fix GattServer::onDataWritten()
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 | /* HACK ALERT! the following bit with initializeGATTDatabase() is additional to |
rgrover1 | 538:00d5affbb2b2 | 448 | * gap().startAdvertising(). This was put in place to get some stacks to |
rgrover1 | 538:00d5affbb2b2 | 449 | * work--like CSR. We need to reach a point where this shouldn't be |
rgrover1 | 538:00d5affbb2b2 | 450 | * necessary. */ |
rgrover1 | 538:00d5affbb2b2 | 451 | ble_error_t rc; |
rgrover1 | 538:00d5affbb2b2 | 452 | if ((rc = transport->getGattServer().initializeGATTDatabase()) != BLE_ERROR_NONE) { |
rgrover1 | 538:00d5affbb2b2 | 453 | return rc; |
rgrover1 | 538:00d5affbb2b2 | 454 | } |
rgrover1 | 538:00d5affbb2b2 | 455 | |
rgrover1 | 538:00d5affbb2b2 | 456 | return gap().startAdvertising(); |
rgrover1 | 538:00d5affbb2b2 | 457 | } |
rgrover1 | 529:8d21604fe31d | 458 | |
rgrover1 | 529:8d21604fe31d | 459 | /** |
rgrover1 | 538:00d5affbb2b2 | 460 | * Stop advertising. |
rgrover1 | 538:00d5affbb2b2 | 461 | * |
rgrover1 | 538:00d5affbb2b2 | 462 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 463 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 464 | * ble.stopAdvertising(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 465 | * ble.gap().stopAdvertising(...). |
rgrover1 | 529:8d21604fe31d | 466 | */ |
rgrover1 | 538:00d5affbb2b2 | 467 | ble_error_t stopAdvertising(void) { |
rgrover1 | 538:00d5affbb2b2 | 468 | return gap().stopAdvertising(); |
rgrover1 | 538:00d5affbb2b2 | 469 | } |
rgrover1 | 529:8d21604fe31d | 470 | |
rgrover1 | 529:8d21604fe31d | 471 | /** |
rgrover1 | 529:8d21604fe31d | 472 | * Setup parameters for GAP scanning--i.e. observer mode. |
rgrover1 | 538:00d5affbb2b2 | 473 | * @param[in] interval |
rgrover1 | 538:00d5affbb2b2 | 474 | * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
rgrover1 | 538:00d5affbb2b2 | 475 | * @param[in] window |
rgrover1 | 538:00d5affbb2b2 | 476 | * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
rgrover1 | 538:00d5affbb2b2 | 477 | * @param[in] timeout |
rgrover1 | 538:00d5affbb2b2 | 478 | * Scan timeout (in seconds) between 0x0001 and 0xFFFF, 0x0000 disables timeout. |
rgrover1 | 538:00d5affbb2b2 | 479 | * @param[in] activeScanning |
rgrover1 | 538:00d5affbb2b2 | 480 | * Set to True if active-scanning is required. This is used to fetch the |
rgrover1 | 538:00d5affbb2b2 | 481 | * scan response from a peer if possible. |
rgrover1 | 529:8d21604fe31d | 482 | * |
rgrover1 | 529:8d21604fe31d | 483 | * The scanning window divided by the interval determines the duty cycle for |
rgrover1 | 529:8d21604fe31d | 484 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
rgrover1 | 529:8d21604fe31d | 485 | * then the controller will scan for 10 percent of the time. It is possible |
rgrover1 | 529:8d21604fe31d | 486 | * to have the interval and window set to the same value. In this case, |
rgrover1 | 529:8d21604fe31d | 487 | * scanning is continuous, with a change of scanning frequency once every |
rgrover1 | 529:8d21604fe31d | 488 | * interval. |
rgrover1 | 529:8d21604fe31d | 489 | * |
rgrover1 | 529:8d21604fe31d | 490 | * Once the scanning parameters have been configured, scanning can be |
rgrover1 | 529:8d21604fe31d | 491 | * enabled by using startScan(). |
rgrover1 | 529:8d21604fe31d | 492 | * |
rgrover1 | 529:8d21604fe31d | 493 | * @Note: The scan interval and window are recommendations to the BLE stack. |
rgrover1 | 538:00d5affbb2b2 | 494 | * |
rgrover1 | 538:00d5affbb2b2 | 495 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 496 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 497 | * ble.setScanParams(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 498 | * ble.gap().setScanParams(...). |
rgrover1 | 529:8d21604fe31d | 499 | */ |
rgrover1 | 529:8d21604fe31d | 500 | ble_error_t setScanParams(uint16_t interval = GapScanningParams::SCAN_INTERVAL_MAX, |
rgrover1 | 529:8d21604fe31d | 501 | uint16_t window = GapScanningParams::SCAN_WINDOW_MAX, |
rgrover1 | 529:8d21604fe31d | 502 | uint16_t timeout = 0, |
rgrover1 | 538:00d5affbb2b2 | 503 | bool activeScanning = false) { |
rgrover1 | 538:00d5affbb2b2 | 504 | return gap().setScanParams(interval, window, timeout, activeScanning); |
rgrover1 | 538:00d5affbb2b2 | 505 | } |
rgrover1 | 538:00d5affbb2b2 | 506 | |
rgrover1 | 538:00d5affbb2b2 | 507 | /** |
rgrover1 | 538:00d5affbb2b2 | 508 | * Setup the scanInterval parameter for GAP scanning--i.e. observer mode. |
rgrover1 | 538:00d5affbb2b2 | 509 | * @param[in] interval |
rgrover1 | 538:00d5affbb2b2 | 510 | * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
rgrover1 | 538:00d5affbb2b2 | 511 | * |
rgrover1 | 538:00d5affbb2b2 | 512 | * The scanning window divided by the interval determines the duty cycle for |
rgrover1 | 538:00d5affbb2b2 | 513 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
rgrover1 | 538:00d5affbb2b2 | 514 | * then the controller will scan for 10 percent of the time. It is possible |
rgrover1 | 538:00d5affbb2b2 | 515 | * to have the interval and window set to the same value. In this case, |
rgrover1 | 538:00d5affbb2b2 | 516 | * scanning is continuous, with a change of scanning frequency once every |
rgrover1 | 538:00d5affbb2b2 | 517 | * interval. |
rgrover1 | 538:00d5affbb2b2 | 518 | * |
rgrover1 | 538:00d5affbb2b2 | 519 | * Once the scanning parameters have been configured, scanning can be |
rgrover1 | 538:00d5affbb2b2 | 520 | * enabled by using startScan(). |
rgrover1 | 538:00d5affbb2b2 | 521 | * |
rgrover1 | 538:00d5affbb2b2 | 522 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 523 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 524 | * ble.setScanInterval(interval) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 525 | * ble.gap().setScanInterval(interval). |
rgrover1 | 538:00d5affbb2b2 | 526 | */ |
rgrover1 | 538:00d5affbb2b2 | 527 | ble_error_t setScanInterval(uint16_t interval) { |
rgrover1 | 538:00d5affbb2b2 | 528 | return gap().setScanInterval(interval); |
rgrover1 | 538:00d5affbb2b2 | 529 | } |
rgrover1 | 538:00d5affbb2b2 | 530 | |
rgrover1 | 538:00d5affbb2b2 | 531 | /** |
rgrover1 | 538:00d5affbb2b2 | 532 | * Setup the scanWindow parameter for GAP scanning--i.e. observer mode. |
rgrover1 | 538:00d5affbb2b2 | 533 | * @param[in] window |
rgrover1 | 538:00d5affbb2b2 | 534 | * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
rgrover1 | 538:00d5affbb2b2 | 535 | * |
rgrover1 | 538:00d5affbb2b2 | 536 | * The scanning window divided by the interval determines the duty cycle for |
rgrover1 | 538:00d5affbb2b2 | 537 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
rgrover1 | 538:00d5affbb2b2 | 538 | * then the controller will scan for 10 percent of the time. It is possible |
rgrover1 | 538:00d5affbb2b2 | 539 | * to have the interval and window set to the same value. In this case, |
rgrover1 | 538:00d5affbb2b2 | 540 | * scanning is continuous, with a change of scanning frequency once every |
rgrover1 | 538:00d5affbb2b2 | 541 | * interval. |
rgrover1 | 538:00d5affbb2b2 | 542 | * |
rgrover1 | 538:00d5affbb2b2 | 543 | * Once the scanning parameters have been configured, scanning can be |
rgrover1 | 538:00d5affbb2b2 | 544 | * enabled by using startScan(). |
rgrover1 | 538:00d5affbb2b2 | 545 | * |
rgrover1 | 538:00d5affbb2b2 | 546 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 547 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 548 | * ble.setScanWindow(window) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 549 | * ble.gap().setScanWindow(window). |
rgrover1 | 538:00d5affbb2b2 | 550 | */ |
rgrover1 | 538:00d5affbb2b2 | 551 | ble_error_t setScanWindow(uint16_t window) { |
rgrover1 | 538:00d5affbb2b2 | 552 | return gap().setScanWindow(window); |
rgrover1 | 538:00d5affbb2b2 | 553 | } |
rgrover1 | 529:8d21604fe31d | 554 | |
rgrover1 | 529:8d21604fe31d | 555 | /** |
rgrover1 | 538:00d5affbb2b2 | 556 | * Setup parameters for GAP scanning--i.e. observer mode. |
rgrover1 | 538:00d5affbb2b2 | 557 | * @param[in] timeout |
rgrover1 | 538:00d5affbb2b2 | 558 | * Scan timeout (in seconds) between 0x0001 and 0xFFFF, 0x0000 disables timeout. |
rgrover1 | 538:00d5affbb2b2 | 559 | * |
rgrover1 | 538:00d5affbb2b2 | 560 | * The scanning window divided by the interval determines the duty cycle for |
rgrover1 | 538:00d5affbb2b2 | 561 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
rgrover1 | 538:00d5affbb2b2 | 562 | * then the controller will scan for 10 percent of the time. It is possible |
rgrover1 | 538:00d5affbb2b2 | 563 | * to have the interval and window set to the same value. In this case, |
rgrover1 | 538:00d5affbb2b2 | 564 | * scanning is continuous, with a change of scanning frequency once every |
rgrover1 | 538:00d5affbb2b2 | 565 | * interval. |
rgrover1 | 529:8d21604fe31d | 566 | * |
rgrover1 | 538:00d5affbb2b2 | 567 | * Once the scanning parameters have been configured, scanning can be |
rgrover1 | 538:00d5affbb2b2 | 568 | * enabled by using startScan(). |
rgrover1 | 538:00d5affbb2b2 | 569 | * |
rgrover1 | 538:00d5affbb2b2 | 570 | * @Note: The scan interval and window are recommendations to the BLE stack. |
rgrover1 | 538:00d5affbb2b2 | 571 | * |
rgrover1 | 538:00d5affbb2b2 | 572 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 573 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 574 | * ble.setScanTimeout(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 575 | * ble.gap().setScanTimeout(...). |
rgrover1 | 529:8d21604fe31d | 576 | */ |
rgrover1 | 538:00d5affbb2b2 | 577 | ble_error_t setScanTimeout(uint16_t timeout) { |
rgrover1 | 538:00d5affbb2b2 | 578 | return gap().setScanTimeout(timeout); |
rgrover1 | 538:00d5affbb2b2 | 579 | } |
rgrover1 | 529:8d21604fe31d | 580 | |
rgrover1 | 529:8d21604fe31d | 581 | /** |
rgrover1 | 538:00d5affbb2b2 | 582 | * Setup parameters for GAP scanning--i.e. observer mode. |
rgrover1 | 538:00d5affbb2b2 | 583 | * @param[in] activeScanning |
rgrover1 | 538:00d5affbb2b2 | 584 | * Set to True if active-scanning is required. This is used to fetch the |
rgrover1 | 538:00d5affbb2b2 | 585 | * scan response from a peer if possible. |
rgrover1 | 538:00d5affbb2b2 | 586 | * |
rgrover1 | 538:00d5affbb2b2 | 587 | * Once the scanning parameters have been configured, scanning can be |
rgrover1 | 538:00d5affbb2b2 | 588 | * enabled by using startScan(). |
rgrover1 | 538:00d5affbb2b2 | 589 | * |
rgrover1 | 538:00d5affbb2b2 | 590 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 591 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 592 | * ble.setActiveScan(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 593 | * ble.gap().setActiveScanning(...). |
rgrover1 | 538:00d5affbb2b2 | 594 | */ |
rgrover1 | 538:00d5affbb2b2 | 595 | void setActiveScan(bool activeScanning) { |
rgrover1 | 538:00d5affbb2b2 | 596 | gap().setActiveScanning(activeScanning); |
rgrover1 | 538:00d5affbb2b2 | 597 | } |
rgrover1 | 538:00d5affbb2b2 | 598 | |
rgrover1 | 538:00d5affbb2b2 | 599 | /** |
rgrover1 | 538:00d5affbb2b2 | 600 | * Start scanning (Observer Procedure) based on the parameters currently in |
rgrover1 | 538:00d5affbb2b2 | 601 | * effect. |
rgrover1 | 529:8d21604fe31d | 602 | * |
rgrover1 | 538:00d5affbb2b2 | 603 | * @param[in] callback |
rgrover1 | 538:00d5affbb2b2 | 604 | * The application specific callback to be invoked upon |
rgrover1 | 538:00d5affbb2b2 | 605 | * receiving every advertisement report. This can be passed in |
rgrover1 | 538:00d5affbb2b2 | 606 | * as NULL, in which case scanning may not be enabled at all. |
rgrover1 | 538:00d5affbb2b2 | 607 | * |
rgrover1 | 538:00d5affbb2b2 | 608 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 609 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 610 | * ble.startScan(callback) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 611 | * ble.gap().startScan(callback). |
rgrover1 | 538:00d5affbb2b2 | 612 | */ |
rgrover1 | 538:00d5affbb2b2 | 613 | ble_error_t startScan(void (*callback)(const Gap::AdvertisementCallbackParams_t *params)) { |
rgrover1 | 538:00d5affbb2b2 | 614 | return gap().startScan(callback); |
rgrover1 | 538:00d5affbb2b2 | 615 | } |
rgrover1 | 538:00d5affbb2b2 | 616 | |
rgrover1 | 538:00d5affbb2b2 | 617 | /** |
rgrover1 | 538:00d5affbb2b2 | 618 | * Same as above, but this takes an (object, method) pair for a callback. |
rgrover1 | 538:00d5affbb2b2 | 619 | * |
rgrover1 | 538:00d5affbb2b2 | 620 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 621 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 622 | * ble.startScan(callback) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 623 | * ble.gap().startScan(object, callback). |
rgrover1 | 529:8d21604fe31d | 624 | */ |
rgrover1 | 529:8d21604fe31d | 625 | template<typename T> |
rgrover1 | 529:8d21604fe31d | 626 | ble_error_t startScan(T *object, void (T::*memberCallback)(const Gap::AdvertisementCallbackParams_t *params)); |
rgrover1 | 529:8d21604fe31d | 627 | |
rgrover1 | 529:8d21604fe31d | 628 | /** |
rgrover1 | 529:8d21604fe31d | 629 | * Stop scanning. The current scanning parameters remain in effect. |
rgrover1 | 529:8d21604fe31d | 630 | * |
rgrover1 | 529:8d21604fe31d | 631 | * @retval BLE_ERROR_NONE if successfully stopped scanning procedure. |
rgrover1 | 538:00d5affbb2b2 | 632 | * |
rgrover1 | 538:00d5affbb2b2 | 633 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 634 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 635 | * ble.stopScan() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 636 | * ble.gap().stopScan(). |
rgrover1 | 529:8d21604fe31d | 637 | */ |
rgrover1 | 538:00d5affbb2b2 | 638 | ble_error_t stopScan(void) { |
rgrover1 | 538:00d5affbb2b2 | 639 | return gap().stopScan(); |
rgrover1 | 538:00d5affbb2b2 | 640 | } |
rgrover1 | 529:8d21604fe31d | 641 | |
rgrover1 | 529:8d21604fe31d | 642 | /** |
rgrover1 | 529:8d21604fe31d | 643 | * Create a connection (GAP Link Establishment). |
rgrover1 | 529:8d21604fe31d | 644 | * @param peerAddr |
rgrover1 | 529:8d21604fe31d | 645 | * 48-bit address, LSB format. |
rgrover1 | 529:8d21604fe31d | 646 | * @param peerAddrType |
rgrover1 | 529:8d21604fe31d | 647 | * Address type of the peer. |
rgrover1 | 529:8d21604fe31d | 648 | * @param connectionParams |
rgrover1 | 529:8d21604fe31d | 649 | * Connection parameters. |
rgrover1 | 529:8d21604fe31d | 650 | * @param scanParams |
rgrover1 | 529:8d21604fe31d | 651 | * Paramters to be used while scanning for the peer. |
rgrover1 | 529:8d21604fe31d | 652 | * @return BLE_ERROR_NONE if connection establishment procedure is started |
rgrover1 | 529:8d21604fe31d | 653 | * successfully. The onConnection callback (if set) will be invoked upon |
rgrover1 | 529:8d21604fe31d | 654 | * a connection event. |
rgrover1 | 538:00d5affbb2b2 | 655 | * |
rgrover1 | 538:00d5affbb2b2 | 656 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 657 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 658 | * ble.connect(...) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 659 | * ble.gap().connect(...). |
rgrover1 | 529:8d21604fe31d | 660 | */ |
rgrover1 | 529:8d21604fe31d | 661 | ble_error_t connect(const Gap::Address_t peerAddr, |
rgrover1 | 529:8d21604fe31d | 662 | Gap::AddressType_t peerAddrType = Gap::ADDR_TYPE_RANDOM_STATIC, |
rgrover1 | 529:8d21604fe31d | 663 | const Gap::ConnectionParams_t *connectionParams = NULL, |
rgrover1 | 538:00d5affbb2b2 | 664 | const GapScanningParams *scanParams = NULL) { |
rgrover1 | 538:00d5affbb2b2 | 665 | return gap().connect(peerAddr, peerAddrType, connectionParams, scanParams); |
rgrover1 | 538:00d5affbb2b2 | 666 | } |
rgrover1 | 529:8d21604fe31d | 667 | |
rgrover1 | 529:8d21604fe31d | 668 | /** |
rgrover1 | 529:8d21604fe31d | 669 | * This call initiates the disconnection procedure, and its completion will |
rgrover1 | 529:8d21604fe31d | 670 | * be communicated to the application with an invocation of the |
rgrover1 | 529:8d21604fe31d | 671 | * onDisconnection callback. |
rgrover1 | 529:8d21604fe31d | 672 | * |
rgrover1 | 529:8d21604fe31d | 673 | * @param reason |
rgrover1 | 529:8d21604fe31d | 674 | * The reason for disconnection to be sent back to the peer. |
rgrover1 | 538:00d5affbb2b2 | 675 | * |
rgrover1 | 538:00d5affbb2b2 | 676 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 677 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 678 | * ble.disconnect(reason) should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 679 | * ble.gap().disconnect(reason). |
rgrover1 | 529:8d21604fe31d | 680 | */ |
rgrover1 | 538:00d5affbb2b2 | 681 | ble_error_t disconnect(Gap::DisconnectionReason_t reason) { |
rgrover1 | 538:00d5affbb2b2 | 682 | return gap().disconnect(reason); |
rgrover1 | 538:00d5affbb2b2 | 683 | } |
rgrover1 | 538:00d5affbb2b2 | 684 | |
rgrover1 | 538:00d5affbb2b2 | 685 | /** |
rgrover1 | 538:00d5affbb2b2 | 686 | * Returns the current GAP state of the device using a bitmask which |
rgrover1 | 538:00d5affbb2b2 | 687 | * describes whether the device is advertising and/or connected. |
rgrover1 | 538:00d5affbb2b2 | 688 | * |
rgrover1 | 538:00d5affbb2b2 | 689 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 690 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 691 | * ble.getGapState() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 692 | * ble.gap().getState(). |
rgrover1 | 538:00d5affbb2b2 | 693 | */ |
rgrover1 | 538:00d5affbb2b2 | 694 | Gap::GapState_t getGapState(void) const { |
rgrover1 | 538:00d5affbb2b2 | 695 | return gap().getState(); |
rgrover1 | 538:00d5affbb2b2 | 696 | } |
rgrover1 | 538:00d5affbb2b2 | 697 | |
rgrover1 | 538:00d5affbb2b2 | 698 | /** |
rgrover1 | 538:00d5affbb2b2 | 699 | * Get the GAP peripheral preferred connection parameters. These are the |
rgrover1 | 538:00d5affbb2b2 | 700 | * defaults that the peripheral would like to have in a connection. The |
rgrover1 | 538:00d5affbb2b2 | 701 | * choice of the connection parameters is eventually up to the central. |
rgrover1 | 538:00d5affbb2b2 | 702 | * |
rgrover1 | 538:00d5affbb2b2 | 703 | * @param[out] params |
rgrover1 | 538:00d5affbb2b2 | 704 | * The structure where the parameters will be stored. Memory |
rgrover1 | 538:00d5affbb2b2 | 705 | * for this is owned by the caller. |
rgrover1 | 538:00d5affbb2b2 | 706 | * |
rgrover1 | 538:00d5affbb2b2 | 707 | * @return BLE_ERROR_NONE if the parameters were successfully filled into |
rgrover1 | 538:00d5affbb2b2 | 708 | * the given structure pointed to by params. |
rgrover1 | 538:00d5affbb2b2 | 709 | * |
rgrover1 | 538:00d5affbb2b2 | 710 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 711 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 712 | * ble.getPreferredConnectionParams() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 713 | * ble.gap().getPreferredConnectionParams(). |
rgrover1 | 538:00d5affbb2b2 | 714 | */ |
rgrover1 | 538:00d5affbb2b2 | 715 | ble_error_t getPreferredConnectionParams(Gap::ConnectionParams_t *params) { |
rgrover1 | 538:00d5affbb2b2 | 716 | return gap().getPreferredConnectionParams(params); |
rgrover1 | 538:00d5affbb2b2 | 717 | } |
rgrover1 | 538:00d5affbb2b2 | 718 | |
rgrover1 | 538:00d5affbb2b2 | 719 | /** |
rgrover1 | 538:00d5affbb2b2 | 720 | * Set the GAP peripheral preferred connection parameters. These are the |
rgrover1 | 538:00d5affbb2b2 | 721 | * defaults that the peripheral would like to have in a connection. The |
rgrover1 | 538:00d5affbb2b2 | 722 | * choice of the connection parameters is eventually up to the central. |
rgrover1 | 538:00d5affbb2b2 | 723 | * |
rgrover1 | 538:00d5affbb2b2 | 724 | * @param[in] params |
rgrover1 | 538:00d5affbb2b2 | 725 | * The structure containing the desired parameters. |
rgrover1 | 538:00d5affbb2b2 | 726 | * |
rgrover1 | 538:00d5affbb2b2 | 727 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 728 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 729 | * ble.setPreferredConnectionParams() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 730 | * ble.gap().setPreferredConnectionParams(). |
rgrover1 | 538:00d5affbb2b2 | 731 | */ |
rgrover1 | 538:00d5affbb2b2 | 732 | ble_error_t setPreferredConnectionParams(const Gap::ConnectionParams_t *params) { |
rgrover1 | 538:00d5affbb2b2 | 733 | return gap().setPreferredConnectionParams(params); |
rgrover1 | 538:00d5affbb2b2 | 734 | } |
rgrover1 | 538:00d5affbb2b2 | 735 | |
rgrover1 | 538:00d5affbb2b2 | 736 | /** |
rgrover1 | 538:00d5affbb2b2 | 737 | * Update connection parameters while in the peripheral role. |
rgrover1 | 538:00d5affbb2b2 | 738 | * @details In the peripheral role, this will send the corresponding L2CAP request to the connected peer and wait for |
rgrover1 | 538:00d5affbb2b2 | 739 | * the central to perform the procedure. |
rgrover1 | 538:00d5affbb2b2 | 740 | * @param[in] handle |
rgrover1 | 538:00d5affbb2b2 | 741 | * Connection Handle |
rgrover1 | 538:00d5affbb2b2 | 742 | * @param[in] params |
rgrover1 | 538:00d5affbb2b2 | 743 | * Pointer to desired connection parameters. If NULL is provided on a peripheral role, |
rgrover1 | 538:00d5affbb2b2 | 744 | * the parameters in the PPCP characteristic of the GAP service will be used instead. |
rgrover1 | 538:00d5affbb2b2 | 745 | * |
rgrover1 | 538:00d5affbb2b2 | 746 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 747 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 748 | * ble.updateConnectionParams() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 749 | * ble.gap().updateConnectionParams(). |
rgrover1 | 538:00d5affbb2b2 | 750 | */ |
rgrover1 | 538:00d5affbb2b2 | 751 | ble_error_t updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) { |
rgrover1 | 538:00d5affbb2b2 | 752 | return gap().updateConnectionParams(handle, params); |
rgrover1 | 538:00d5affbb2b2 | 753 | } |
rgrover1 | 538:00d5affbb2b2 | 754 | |
rgrover1 | 538:00d5affbb2b2 | 755 | /** |
rgrover1 | 538:00d5affbb2b2 | 756 | * Set the device name characteristic in the GAP service. |
rgrover1 | 538:00d5affbb2b2 | 757 | * @param[in] deviceName |
rgrover1 | 538:00d5affbb2b2 | 758 | * The new value for the device-name. This is a UTF-8 encoded, <b>NULL-terminated</b> string. |
rgrover1 | 538:00d5affbb2b2 | 759 | * |
rgrover1 | 538:00d5affbb2b2 | 760 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 761 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 762 | * ble.setDeviceName() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 763 | * ble.gap().setDeviceName(). |
rgrover1 | 538:00d5affbb2b2 | 764 | */ |
rgrover1 | 538:00d5affbb2b2 | 765 | ble_error_t setDeviceName(const uint8_t *deviceName) { |
rgrover1 | 538:00d5affbb2b2 | 766 | return gap().setDeviceName(deviceName); |
rgrover1 | 538:00d5affbb2b2 | 767 | } |
rgrover1 | 538:00d5affbb2b2 | 768 | |
rgrover1 | 538:00d5affbb2b2 | 769 | /** |
rgrover1 | 538:00d5affbb2b2 | 770 | * Get the value of the device name characteristic in the GAP service. |
rgrover1 | 538:00d5affbb2b2 | 771 | * @param[out] deviceName |
rgrover1 | 538:00d5affbb2b2 | 772 | * Pointer to an empty buffer where the UTF-8 *non NULL- |
rgrover1 | 538:00d5affbb2b2 | 773 | * terminated* string will be placed. Set this |
rgrover1 | 538:00d5affbb2b2 | 774 | * value to NULL in order to obtain the deviceName-length |
rgrover1 | 538:00d5affbb2b2 | 775 | * from the 'length' parameter. |
rgrover1 | 538:00d5affbb2b2 | 776 | * |
rgrover1 | 538:00d5affbb2b2 | 777 | * @param[in/out] lengthP |
rgrover1 | 538:00d5affbb2b2 | 778 | * (on input) Length of the buffer pointed to by deviceName; |
rgrover1 | 538:00d5affbb2b2 | 779 | * (on output) the complete device name length (without the |
rgrover1 | 538:00d5affbb2b2 | 780 | * null terminator). |
rgrover1 | 538:00d5affbb2b2 | 781 | * |
rgrover1 | 538:00d5affbb2b2 | 782 | * @note If the device name is longer than the size of the supplied buffer, |
rgrover1 | 538:00d5affbb2b2 | 783 | * length will return the complete device name length, and not the |
rgrover1 | 538:00d5affbb2b2 | 784 | * number of bytes actually returned in deviceName. The application may |
rgrover1 | 538:00d5affbb2b2 | 785 | * use this information to retry with a suitable buffer size. |
rgrover1 | 538:00d5affbb2b2 | 786 | * |
rgrover1 | 538:00d5affbb2b2 | 787 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 788 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 789 | * ble.getDeviceName() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 790 | * ble.gap().getDeviceName(). |
rgrover1 | 538:00d5affbb2b2 | 791 | */ |
rgrover1 | 538:00d5affbb2b2 | 792 | ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP) { |
rgrover1 | 538:00d5affbb2b2 | 793 | return gap().getDeviceName(deviceName, lengthP); |
rgrover1 | 538:00d5affbb2b2 | 794 | } |
rgrover1 | 538:00d5affbb2b2 | 795 | |
rgrover1 | 538:00d5affbb2b2 | 796 | /** |
rgrover1 | 538:00d5affbb2b2 | 797 | * Set the appearance characteristic in the GAP service. |
rgrover1 | 538:00d5affbb2b2 | 798 | * @param[in] appearance |
rgrover1 | 538:00d5affbb2b2 | 799 | * The new value for the device-appearance. |
rgrover1 | 538:00d5affbb2b2 | 800 | * |
rgrover1 | 538:00d5affbb2b2 | 801 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 802 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 803 | * ble.setAppearance() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 804 | * ble.gap().setAppearance(). |
rgrover1 | 538:00d5affbb2b2 | 805 | */ |
rgrover1 | 538:00d5affbb2b2 | 806 | ble_error_t setAppearance(GapAdvertisingData::Appearance appearance) { |
rgrover1 | 538:00d5affbb2b2 | 807 | return gap().setAppearance(appearance); |
rgrover1 | 538:00d5affbb2b2 | 808 | } |
rgrover1 | 538:00d5affbb2b2 | 809 | |
rgrover1 | 538:00d5affbb2b2 | 810 | /** |
rgrover1 | 538:00d5affbb2b2 | 811 | * Get the appearance characteristic in the GAP service. |
rgrover1 | 538:00d5affbb2b2 | 812 | * @param[out] appearance |
rgrover1 | 538:00d5affbb2b2 | 813 | * The new value for the device-appearance. |
rgrover1 | 538:00d5affbb2b2 | 814 | * |
rgrover1 | 538:00d5affbb2b2 | 815 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 816 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 817 | * ble.getAppearance() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 818 | * ble.gap().getAppearance(). |
rgrover1 | 538:00d5affbb2b2 | 819 | */ |
rgrover1 | 538:00d5affbb2b2 | 820 | ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP) { |
rgrover1 | 538:00d5affbb2b2 | 821 | return gap().getAppearance(appearanceP); |
rgrover1 | 538:00d5affbb2b2 | 822 | } |
rgrover1 | 538:00d5affbb2b2 | 823 | |
rgrover1 | 538:00d5affbb2b2 | 824 | /** |
rgrover1 | 538:00d5affbb2b2 | 825 | * Set the radio's transmit power. |
rgrover1 | 538:00d5affbb2b2 | 826 | * @param[in] txPower Radio transmit power in dBm. |
rgrover1 | 538:00d5affbb2b2 | 827 | * |
rgrover1 | 538:00d5affbb2b2 | 828 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 829 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 830 | * ble.setTxPower() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 831 | * ble.gap().setTxPower(). |
rgrover1 | 538:00d5affbb2b2 | 832 | */ |
rgrover1 | 538:00d5affbb2b2 | 833 | ble_error_t setTxPower(int8_t txPower) { |
rgrover1 | 538:00d5affbb2b2 | 834 | return gap().setTxPower(txPower); |
rgrover1 | 538:00d5affbb2b2 | 835 | } |
rgrover1 | 538:00d5affbb2b2 | 836 | |
rgrover1 | 538:00d5affbb2b2 | 837 | /** |
rgrover1 | 538:00d5affbb2b2 | 838 | * Query the underlying stack for permitted arguments for setTxPower(). |
rgrover1 | 538:00d5affbb2b2 | 839 | * |
rgrover1 | 538:00d5affbb2b2 | 840 | * @param[out] valueArrayPP |
rgrover1 | 538:00d5affbb2b2 | 841 | * Out parameter to receive the immutable array of Tx values. |
rgrover1 | 538:00d5affbb2b2 | 842 | * @param[out] countP |
rgrover1 | 538:00d5affbb2b2 | 843 | * Out parameter to receive the array's size. |
rgrover1 | 538:00d5affbb2b2 | 844 | * |
rgrover1 | 538:00d5affbb2b2 | 845 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 538:00d5affbb2b2 | 846 | * You should use the parallel API from Gap directly. A former call to |
rgrover1 | 538:00d5affbb2b2 | 847 | * ble.getPermittedTxPowerValues() should be replaced with |
rgrover1 | 538:00d5affbb2b2 | 848 | * ble.gap().getPermittedTxPowerValues(). |
rgrover1 | 538:00d5affbb2b2 | 849 | */ |
rgrover1 | 538:00d5affbb2b2 | 850 | void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP) { |
rgrover1 | 538:00d5affbb2b2 | 851 | gap().getPermittedTxPowerValues(valueArrayPP, countP); |
rgrover1 | 538:00d5affbb2b2 | 852 | } |
rgrover1 | 529:8d21604fe31d | 853 | |
rgrover1 | 529:8d21604fe31d | 854 | /** |
rgrover1 | 529:8d21604fe31d | 855 | * Add a service declaration to the local server ATT table. Also add the |
rgrover1 | 529:8d21604fe31d | 856 | * characteristics contained within. |
rgrover1 | 540:0b6e82025358 | 857 | * |
rgrover1 | 540:0b6e82025358 | 858 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 540:0b6e82025358 | 859 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 540:0b6e82025358 | 860 | * to ble.addService() should be replaced with |
rgrover1 | 540:0b6e82025358 | 861 | * ble.gattServer().addService(). |
rgrover1 | 529:8d21604fe31d | 862 | */ |
rgrover1 | 540:0b6e82025358 | 863 | ble_error_t addService(GattService &service) { |
rgrover1 | 540:0b6e82025358 | 864 | return gattServer().addService(service); |
rgrover1 | 540:0b6e82025358 | 865 | } |
rgrover1 | 540:0b6e82025358 | 866 | |
rgrover1 | 540:0b6e82025358 | 867 | /** |
rgrover1 | 540:0b6e82025358 | 868 | * Read the value of a characteristic from the local GattServer |
rgrover1 | 540:0b6e82025358 | 869 | * @param[in] attributeHandle |
rgrover1 | 540:0b6e82025358 | 870 | * Attribute handle for the value attribute of the characteristic. |
rgrover1 | 540:0b6e82025358 | 871 | * @param[out] buffer |
rgrover1 | 540:0b6e82025358 | 872 | * A buffer to hold the value being read. |
rgrover1 | 540:0b6e82025358 | 873 | * @param[in/out] lengthP |
rgrover1 | 540:0b6e82025358 | 874 | * Length of the buffer being supplied. If the attribute |
rgrover1 | 540:0b6e82025358 | 875 | * value is longer than the size of the supplied buffer, |
rgrover1 | 540:0b6e82025358 | 876 | * this variable will hold upon return the total attribute value length |
rgrover1 | 540:0b6e82025358 | 877 | * (excluding offset). The application may use this |
rgrover1 | 540:0b6e82025358 | 878 | * information to allocate a suitable buffer size. |
rgrover1 | 540:0b6e82025358 | 879 | * |
rgrover1 | 540:0b6e82025358 | 880 | * @return BLE_ERROR_NONE if a value was read successfully into the buffer. |
rgrover1 | 540:0b6e82025358 | 881 | * |
rgrover1 | 540:0b6e82025358 | 882 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 540:0b6e82025358 | 883 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 540:0b6e82025358 | 884 | * to ble.readCharacteristicValue() should be replaced with |
rgrover1 | 540:0b6e82025358 | 885 | * ble.gattServer().read(). |
rgrover1 | 540:0b6e82025358 | 886 | */ |
rgrover1 | 540:0b6e82025358 | 887 | ble_error_t readCharacteristicValue(GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) { |
rgrover1 | 540:0b6e82025358 | 888 | return gattServer().read(attributeHandle, buffer, lengthP); |
rgrover1 | 540:0b6e82025358 | 889 | } |
rgrover1 | 529:8d21604fe31d | 890 | |
rgrover1 | 529:8d21604fe31d | 891 | /** |
rgrover1 | 540:0b6e82025358 | 892 | * Read the value of a characteristic from the local GattServer |
rgrover1 | 540:0b6e82025358 | 893 | * @param[in] connectionHandle |
rgrover1 | 540:0b6e82025358 | 894 | * Connection Handle. |
rgrover1 | 540:0b6e82025358 | 895 | * @param[in] attributeHandle |
rgrover1 | 540:0b6e82025358 | 896 | * Attribute handle for the value attribute of the characteristic. |
rgrover1 | 540:0b6e82025358 | 897 | * @param[out] buffer |
rgrover1 | 540:0b6e82025358 | 898 | * A buffer to hold the value being read. |
rgrover1 | 540:0b6e82025358 | 899 | * @param[in/out] lengthP |
rgrover1 | 540:0b6e82025358 | 900 | * Length of the buffer being supplied. If the attribute |
rgrover1 | 540:0b6e82025358 | 901 | * value is longer than the size of the supplied buffer, |
rgrover1 | 540:0b6e82025358 | 902 | * this variable will hold upon return the total attribute value length |
rgrover1 | 540:0b6e82025358 | 903 | * (excluding offset). The application may use this |
rgrover1 | 540:0b6e82025358 | 904 | * information to allocate a suitable buffer size. |
rgrover1 | 540:0b6e82025358 | 905 | * |
rgrover1 | 540:0b6e82025358 | 906 | * @return BLE_ERROR_NONE if a value was read successfully into the buffer. |
rgrover1 | 540:0b6e82025358 | 907 | * |
rgrover1 | 540:0b6e82025358 | 908 | * @note This API is a version of above with an additional connection handle |
rgrover1 | 540:0b6e82025358 | 909 | * parameter to allow fetches for connection-specific multivalued |
rgrover1 | 540:0b6e82025358 | 910 | * attribtues (such as the CCCDs). |
rgrover1 | 540:0b6e82025358 | 911 | * |
rgrover1 | 540:0b6e82025358 | 912 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 540:0b6e82025358 | 913 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 540:0b6e82025358 | 914 | * to ble.readCharacteristicValue() should be replaced with |
rgrover1 | 540:0b6e82025358 | 915 | * ble.gattServer().read(). |
rgrover1 | 529:8d21604fe31d | 916 | */ |
rgrover1 | 540:0b6e82025358 | 917 | ble_error_t readCharacteristicValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) { |
rgrover1 | 540:0b6e82025358 | 918 | return gattServer().read(connectionHandle, attributeHandle, buffer, lengthP); |
rgrover1 | 540:0b6e82025358 | 919 | } |
rgrover1 | 529:8d21604fe31d | 920 | |
rgrover1 | 529:8d21604fe31d | 921 | /** |
rgrover1 | 540:0b6e82025358 | 922 | * Update the value of a characteristic on the local GattServer. |
rgrover1 | 540:0b6e82025358 | 923 | * |
rgrover1 | 540:0b6e82025358 | 924 | * @param[in] attributeHandle |
rgrover1 | 540:0b6e82025358 | 925 | * Handle for the value attribute of the Characteristic. |
rgrover1 | 540:0b6e82025358 | 926 | * @param[in] value |
rgrover1 | 540:0b6e82025358 | 927 | * A pointer to a buffer holding the new value |
rgrover1 | 540:0b6e82025358 | 928 | * @param[in] size |
rgrover1 | 540:0b6e82025358 | 929 | * Size of the new value (in bytes). |
rgrover1 | 540:0b6e82025358 | 930 | * @param[in] localOnly |
rgrover1 | 540:0b6e82025358 | 931 | * Should this update be kept on the local |
rgrover1 | 540:0b6e82025358 | 932 | * GattServer regardless of the state of the |
rgrover1 | 540:0b6e82025358 | 933 | * notify/indicate flag in the CCCD for this |
rgrover1 | 540:0b6e82025358 | 934 | * Characteristic? If set to true, no notification |
rgrover1 | 540:0b6e82025358 | 935 | * or indication is generated. |
rgrover1 | 540:0b6e82025358 | 936 | * |
rgrover1 | 540:0b6e82025358 | 937 | * @return BLE_ERROR_NONE if we have successfully set the value of the attribute. |
rgrover1 | 540:0b6e82025358 | 938 | * |
rgrover1 | 540:0b6e82025358 | 939 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 540:0b6e82025358 | 940 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 540:0b6e82025358 | 941 | * to ble.updateCharacteristicValue() should be replaced with |
rgrover1 | 540:0b6e82025358 | 942 | * ble.gattServer().write(). |
rgrover1 | 529:8d21604fe31d | 943 | */ |
rgrover1 | 540:0b6e82025358 | 944 | ble_error_t updateCharacteristicValue(GattAttribute::Handle_t attributeHandle, |
rgrover1 | 540:0b6e82025358 | 945 | const uint8_t *value, |
rgrover1 | 540:0b6e82025358 | 946 | uint16_t size, |
rgrover1 | 540:0b6e82025358 | 947 | bool localOnly = false) { |
rgrover1 | 540:0b6e82025358 | 948 | return gattServer().write(attributeHandle, value, size, localOnly); |
rgrover1 | 540:0b6e82025358 | 949 | } |
rgrover1 | 540:0b6e82025358 | 950 | |
rgrover1 | 529:8d21604fe31d | 951 | /** |
rgrover1 | 540:0b6e82025358 | 952 | * Update the value of a characteristic on the local GattServer. A version |
rgrover1 | 540:0b6e82025358 | 953 | * of the same as above with connection handle parameter to allow updates |
rgrover1 | 540:0b6e82025358 | 954 | * for connection-specific multivalued attribtues (such as the CCCDs). |
rgrover1 | 540:0b6e82025358 | 955 | * |
rgrover1 | 540:0b6e82025358 | 956 | * @param[in] connectionHandle |
rgrover1 | 540:0b6e82025358 | 957 | * Connection Handle. |
rgrover1 | 540:0b6e82025358 | 958 | * @param[in] attributeHandle |
rgrover1 | 540:0b6e82025358 | 959 | * Handle for the value attribute of the Characteristic. |
rgrover1 | 540:0b6e82025358 | 960 | * @param[in] value |
rgrover1 | 540:0b6e82025358 | 961 | * A pointer to a buffer holding the new value |
rgrover1 | 540:0b6e82025358 | 962 | * @param[in] size |
rgrover1 | 540:0b6e82025358 | 963 | * Size of the new value (in bytes). |
rgrover1 | 540:0b6e82025358 | 964 | * @param[in] localOnly |
rgrover1 | 540:0b6e82025358 | 965 | * Should this update be kept on the local |
rgrover1 | 540:0b6e82025358 | 966 | * GattServer regardless of the state of the |
rgrover1 | 540:0b6e82025358 | 967 | * notify/indicate flag in the CCCD for this |
rgrover1 | 540:0b6e82025358 | 968 | * Characteristic? If set to true, no notification |
rgrover1 | 540:0b6e82025358 | 969 | * or indication is generated. |
rgrover1 | 540:0b6e82025358 | 970 | * |
rgrover1 | 540:0b6e82025358 | 971 | * @return BLE_ERROR_NONE if we have successfully set the value of the attribute. |
rgrover1 | 540:0b6e82025358 | 972 | * |
rgrover1 | 540:0b6e82025358 | 973 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 540:0b6e82025358 | 974 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 540:0b6e82025358 | 975 | * to ble.updateCharacteristicValue() should be replaced with |
rgrover1 | 540:0b6e82025358 | 976 | * ble.gattServer().write(). |
rgrover1 | 529:8d21604fe31d | 977 | */ |
rgrover1 | 529:8d21604fe31d | 978 | ble_error_t updateCharacteristicValue(Gap::Handle_t connectionHandle, |
rgrover1 | 529:8d21604fe31d | 979 | GattAttribute::Handle_t attributeHandle, |
rgrover1 | 529:8d21604fe31d | 980 | const uint8_t *value, |
rgrover1 | 529:8d21604fe31d | 981 | uint16_t size, |
rgrover1 | 540:0b6e82025358 | 982 | bool localOnly = false) { |
rgrover1 | 540:0b6e82025358 | 983 | return gattServer().write(connectionHandle, attributeHandle, value, size, localOnly); |
rgrover1 | 540:0b6e82025358 | 984 | } |
rgrover1 | 529:8d21604fe31d | 985 | |
rgrover1 | 542:aa30f63e7b3f | 986 | /** |
rgrover1 | 547:9fdf3d960d12 | 987 | * Enable the BLE stack's Security Manager. The Security Manager implements |
rgrover1 | 547:9fdf3d960d12 | 988 | * the actual cryptographic algorithms and protocol exchanges that allow two |
rgrover1 | 547:9fdf3d960d12 | 989 | * devices to securely exchange data and privately detect each other. |
rgrover1 | 547:9fdf3d960d12 | 990 | * Calling this API is a prerequisite for encryption and pairing (bonding). |
rgrover1 | 547:9fdf3d960d12 | 991 | * |
rgrover1 | 547:9fdf3d960d12 | 992 | * @param[in] enableBonding Allow for bonding. |
rgrover1 | 547:9fdf3d960d12 | 993 | * @param[in] requireMITM Require protection for man-in-the-middle attacks. |
rgrover1 | 547:9fdf3d960d12 | 994 | * @param[in] iocaps To specify IO capabilities of this peripheral, |
rgrover1 | 547:9fdf3d960d12 | 995 | * such as availability of a display or keyboard to |
rgrover1 | 547:9fdf3d960d12 | 996 | * support out-of-band exchanges of security data. |
rgrover1 | 547:9fdf3d960d12 | 997 | * @param[in] passkey To specify a static passkey. |
rgrover1 | 547:9fdf3d960d12 | 998 | * |
rgrover1 | 547:9fdf3d960d12 | 999 | * @return BLE_ERROR_NONE on success. |
rgrover1 | 547:9fdf3d960d12 | 1000 | * |
rgrover1 | 547:9fdf3d960d12 | 1001 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1002 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1003 | * call to ble.initializeSecurity(...) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1004 | * ble.securityManager().init(...). |
rgrover1 | 547:9fdf3d960d12 | 1005 | */ |
rgrover1 | 547:9fdf3d960d12 | 1006 | ble_error_t initializeSecurity(bool enableBonding = true, |
rgrover1 | 547:9fdf3d960d12 | 1007 | bool requireMITM = true, |
rgrover1 | 547:9fdf3d960d12 | 1008 | SecurityManager::SecurityIOCapabilities_t iocaps = SecurityManager::IO_CAPS_NONE, |
rgrover1 | 547:9fdf3d960d12 | 1009 | const SecurityManager::Passkey_t passkey = NULL) { |
rgrover1 | 547:9fdf3d960d12 | 1010 | return securityManager().init(enableBonding, requireMITM, iocaps, passkey); |
rgrover1 | 547:9fdf3d960d12 | 1011 | } |
rgrover1 | 547:9fdf3d960d12 | 1012 | |
rgrover1 | 547:9fdf3d960d12 | 1013 | /** |
rgrover1 | 547:9fdf3d960d12 | 1014 | * Get the security status of a connection. |
rgrover1 | 547:9fdf3d960d12 | 1015 | * |
rgrover1 | 547:9fdf3d960d12 | 1016 | * @param[in] connectionHandle Handle to identify the connection. |
rgrover1 | 547:9fdf3d960d12 | 1017 | * @param[out] securityStatusP security status. |
rgrover1 | 547:9fdf3d960d12 | 1018 | * |
rgrover1 | 547:9fdf3d960d12 | 1019 | * @return BLE_SUCCESS Or appropriate error code indicating reason for failure. |
rgrover1 | 547:9fdf3d960d12 | 1020 | * |
rgrover1 | 547:9fdf3d960d12 | 1021 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1022 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1023 | * call to ble.getLinkSecurity(...) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1024 | * ble.securityManager().getLinkSecurity(...). |
rgrover1 | 547:9fdf3d960d12 | 1025 | */ |
rgrover1 | 547:9fdf3d960d12 | 1026 | ble_error_t getLinkSecurity(Gap::Handle_t connectionHandle, SecurityManager::LinkSecurityStatus_t *securityStatusP) { |
rgrover1 | 547:9fdf3d960d12 | 1027 | return securityManager().getLinkSecurity(connectionHandle, securityStatusP); |
rgrover1 | 547:9fdf3d960d12 | 1028 | } |
rgrover1 | 547:9fdf3d960d12 | 1029 | |
rgrover1 | 547:9fdf3d960d12 | 1030 | /** |
rgrover1 | 547:9fdf3d960d12 | 1031 | * Delete all peer device context and all related bonding information from |
rgrover1 | 547:9fdf3d960d12 | 1032 | * the database within the security manager. |
rgrover1 | 547:9fdf3d960d12 | 1033 | * |
rgrover1 | 547:9fdf3d960d12 | 1034 | * @retval BLE_ERROR_NONE On success, else an error code indicating reason for failure. |
rgrover1 | 547:9fdf3d960d12 | 1035 | * @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization and/or |
rgrover1 | 547:9fdf3d960d12 | 1036 | * application registration. |
rgrover1 | 547:9fdf3d960d12 | 1037 | * |
rgrover1 | 547:9fdf3d960d12 | 1038 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1039 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1040 | * call to ble.purgeAllBondingState() should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1041 | * ble.securityManager().purgeAllBondingState(). |
rgrover1 | 547:9fdf3d960d12 | 1042 | */ |
rgrover1 | 547:9fdf3d960d12 | 1043 | ble_error_t purgeAllBondingState(void) { |
rgrover1 | 547:9fdf3d960d12 | 1044 | return securityManager().purgeAllBondingState(); |
rgrover1 | 547:9fdf3d960d12 | 1045 | } |
rgrover1 | 547:9fdf3d960d12 | 1046 | |
rgrover1 | 547:9fdf3d960d12 | 1047 | /** |
rgrover1 | 542:aa30f63e7b3f | 1048 | * Setup a callback for timeout events. Refer to Gap::TimeoutSource_t for |
rgrover1 | 542:aa30f63e7b3f | 1049 | * possible event types. |
rgrover1 | 542:aa30f63e7b3f | 1050 | * |
rgrover1 | 542:aa30f63e7b3f | 1051 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 542:aa30f63e7b3f | 1052 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 542:aa30f63e7b3f | 1053 | * to ble.onTimeout(callback) should be replaced with |
rgrover1 | 542:aa30f63e7b3f | 1054 | * ble.gap().onTimeout(callback). |
rgrover1 | 542:aa30f63e7b3f | 1055 | */ |
rgrover1 | 542:aa30f63e7b3f | 1056 | void onTimeout(Gap::TimeoutEventCallback_t timeoutCallback) { |
rgrover1 | 542:aa30f63e7b3f | 1057 | gap().onTimeout(timeoutCallback); |
rgrover1 | 542:aa30f63e7b3f | 1058 | } |
rgrover1 | 529:8d21604fe31d | 1059 | |
rgrover1 | 544:4defb791aa94 | 1060 | /** |
rgrover1 | 544:4defb791aa94 | 1061 | * Setup a callback for connection events. Refer to Gap::ConnectionEventCallback_t. |
rgrover1 | 544:4defb791aa94 | 1062 | * |
rgrover1 | 544:4defb791aa94 | 1063 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 544:4defb791aa94 | 1064 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 544:4defb791aa94 | 1065 | * to ble.onConnection(callback) should be replaced with |
rgrover1 | 544:4defb791aa94 | 1066 | * ble.gap().onConnection(callback). |
rgrover1 | 544:4defb791aa94 | 1067 | */ |
rgrover1 | 544:4defb791aa94 | 1068 | void onConnection(Gap::ConnectionEventCallback_t connectionCallback) { |
rgrover1 | 544:4defb791aa94 | 1069 | gap().onConnection(connectionCallback); |
rgrover1 | 544:4defb791aa94 | 1070 | } |
rgrover1 | 544:4defb791aa94 | 1071 | |
rgrover1 | 529:8d21604fe31d | 1072 | /** |
rgrover1 | 541:1fb1e0b809eb | 1073 | * Used to setup a callback for GAP disconnection. |
rgrover1 | 545:840f428d18c7 | 1074 | * |
rgrover1 | 545:840f428d18c7 | 1075 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 545:840f428d18c7 | 1076 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 545:840f428d18c7 | 1077 | * to ble.onDisconnection(callback) should be replaced with |
rgrover1 | 545:840f428d18c7 | 1078 | * ble.gap().onDisconnection(callback). |
rgrover1 | 529:8d21604fe31d | 1079 | */ |
rgrover1 | 545:840f428d18c7 | 1080 | void onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback) { |
rgrover1 | 545:840f428d18c7 | 1081 | gap().onDisconnection(disconnectionCallback); |
rgrover1 | 545:840f428d18c7 | 1082 | } |
rgrover1 | 529:8d21604fe31d | 1083 | |
rgrover1 | 529:8d21604fe31d | 1084 | /** |
rgrover1 | 541:1fb1e0b809eb | 1085 | * Append to a chain of callbacks to be invoked upon disconnection; these |
rgrover1 | 541:1fb1e0b809eb | 1086 | * callbacks receive no context and are therefore different from the |
rgrover1 | 541:1fb1e0b809eb | 1087 | * onDisconnection callback. |
rgrover1 | 545:840f428d18c7 | 1088 | * |
rgrover1 | 545:840f428d18c7 | 1089 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 545:840f428d18c7 | 1090 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 545:840f428d18c7 | 1091 | * to ble.addToDisconnectionCallchain(...) should be replaced with |
rgrover1 | 545:840f428d18c7 | 1092 | * ble.gap().addToDisconnectionCallchain(...). |
rgrover1 | 529:8d21604fe31d | 1093 | */ |
rgrover1 | 541:1fb1e0b809eb | 1094 | template<typename T> |
rgrover1 | 545:840f428d18c7 | 1095 | void addToDisconnectionCallChain(T *tptr, void (T::*mptr)(void)) { |
rgrover1 | 545:840f428d18c7 | 1096 | gap().addToDisconnectionCallChain(tptr, mptr); |
rgrover1 | 545:840f428d18c7 | 1097 | } |
rgrover1 | 529:8d21604fe31d | 1098 | |
rgrover1 | 529:8d21604fe31d | 1099 | /** |
rgrover1 | 546:45bbdb1d5eca | 1100 | * Radio Notification is a feature that enables ACTIVE and INACTIVE |
rgrover1 | 546:45bbdb1d5eca | 1101 | * (nACTIVE) signals from the stack that notify the application when the |
rgrover1 | 546:45bbdb1d5eca | 1102 | * radio is in use. The signal is sent using software interrupt. |
rgrover1 | 546:45bbdb1d5eca | 1103 | * |
rgrover1 | 546:45bbdb1d5eca | 1104 | * The ACTIVE signal is sent before the Radio Event starts. The nACTIVE |
rgrover1 | 546:45bbdb1d5eca | 1105 | * signal is sent at the end of the Radio Event. These signals can be used |
rgrover1 | 546:45bbdb1d5eca | 1106 | * by the application programmer to synchronize application logic with radio |
rgrover1 | 546:45bbdb1d5eca | 1107 | * activity. For example, the ACTIVE signal can be used to shut off external |
rgrover1 | 546:45bbdb1d5eca | 1108 | * devices to manage peak current drawn during periods when the radio is on, |
rgrover1 | 546:45bbdb1d5eca | 1109 | * or to trigger sensor data collection for transmission in the Radio Event. |
rgrover1 | 546:45bbdb1d5eca | 1110 | * |
rgrover1 | 546:45bbdb1d5eca | 1111 | * @param callback |
rgrover1 | 546:45bbdb1d5eca | 1112 | * The application handler to be invoked in response to a radio |
rgrover1 | 546:45bbdb1d5eca | 1113 | * ACTIVE/INACTIVE event. |
rgrover1 | 546:45bbdb1d5eca | 1114 | * |
rgrover1 | 546:45bbdb1d5eca | 1115 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 546:45bbdb1d5eca | 1116 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 546:45bbdb1d5eca | 1117 | * to ble.onRadioNotification(...) should be replaced with |
rgrover1 | 546:45bbdb1d5eca | 1118 | * ble.gap().onRadioNotification(...). |
rgrover1 | 546:45bbdb1d5eca | 1119 | */ |
rgrover1 | 546:45bbdb1d5eca | 1120 | void onRadioNotification(Gap::RadioNotificationEventCallback_t callback) { |
rgrover1 | 546:45bbdb1d5eca | 1121 | gap().onRadioNotification(callback); |
rgrover1 | 546:45bbdb1d5eca | 1122 | } |
rgrover1 | 546:45bbdb1d5eca | 1123 | |
rgrover1 | 546:45bbdb1d5eca | 1124 | /** |
rgrover1 | 541:1fb1e0b809eb | 1125 | * Add a callback for the GATT event DATA_SENT (which is triggered when |
rgrover1 | 541:1fb1e0b809eb | 1126 | * updates are sent out by GATT in the form of notifications). |
rgrover1 | 529:8d21604fe31d | 1127 | * |
rgrover1 | 541:1fb1e0b809eb | 1128 | * @Note: it is possible to chain together multiple onDataSent callbacks |
rgrover1 | 541:1fb1e0b809eb | 1129 | * (potentially from different modules of an application) to receive updates |
rgrover1 | 541:1fb1e0b809eb | 1130 | * to characteristics. |
rgrover1 | 529:8d21604fe31d | 1131 | * |
rgrover1 | 541:1fb1e0b809eb | 1132 | * @Note: it is also possible to setup a callback into a member function of |
rgrover1 | 541:1fb1e0b809eb | 1133 | * some object. |
rgrover1 | 548:f84c514eee35 | 1134 | * |
rgrover1 | 548:f84c514eee35 | 1135 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 548:f84c514eee35 | 1136 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 548:f84c514eee35 | 1137 | * to ble.onDataSent(...) should be replaced with |
rgrover1 | 548:f84c514eee35 | 1138 | * ble.gap().onDataSent(...). |
rgrover1 | 529:8d21604fe31d | 1139 | */ |
rgrover1 | 548:f84c514eee35 | 1140 | void onDataSent(void (*callback)(unsigned count)) { |
rgrover1 | 548:f84c514eee35 | 1141 | gattServer().onDataSent(callback); |
rgrover1 | 548:f84c514eee35 | 1142 | } |
rgrover1 | 548:f84c514eee35 | 1143 | template <typename T> void onDataSent(T * objPtr, void (T::*memberPtr)(unsigned count)) { |
rgrover1 | 548:f84c514eee35 | 1144 | gattServer().onDataSent(objPtr, memberPtr); |
rgrover1 | 548:f84c514eee35 | 1145 | } |
rgrover1 | 529:8d21604fe31d | 1146 | |
rgrover1 | 529:8d21604fe31d | 1147 | /** |
rgrover1 | 549:623e4c0f0b6e | 1148 | * Setup a callback for when an attribute has its value updated by or at the |
rgrover1 | 549:623e4c0f0b6e | 1149 | * connected peer. For a peripheral, this callback triggered when the local |
rgrover1 | 549:623e4c0f0b6e | 1150 | * GATT server has an attribute updated by a write command from the peer. |
rgrover1 | 549:623e4c0f0b6e | 1151 | * For a Central, this callback is triggered when a response is received for |
rgrover1 | 549:623e4c0f0b6e | 1152 | * a write request. |
rgrover1 | 529:8d21604fe31d | 1153 | * |
rgrover1 | 541:1fb1e0b809eb | 1154 | * @Note: it is possible to chain together multiple onDataWritten callbacks |
rgrover1 | 541:1fb1e0b809eb | 1155 | * (potentially from different modules of an application) to receive updates |
rgrover1 | 541:1fb1e0b809eb | 1156 | * to characteristics. Many services, such as DFU and UART add their own |
rgrover1 | 541:1fb1e0b809eb | 1157 | * onDataWritten callbacks behind the scenes to trap interesting events. |
rgrover1 | 529:8d21604fe31d | 1158 | * |
rgrover1 | 541:1fb1e0b809eb | 1159 | * @Note: it is also possible to setup a callback into a member function of |
rgrover1 | 541:1fb1e0b809eb | 1160 | * some object. |
rgrover1 | 549:623e4c0f0b6e | 1161 | * |
rgrover1 | 549:623e4c0f0b6e | 1162 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 549:623e4c0f0b6e | 1163 | * You should use the parallel API from GattServer directly. A former call |
rgrover1 | 549:623e4c0f0b6e | 1164 | * to ble.onDataWritten(...) should be replaced with |
rgrover1 | 549:623e4c0f0b6e | 1165 | * ble.gap().onDataWritten(...). |
rgrover1 | 529:8d21604fe31d | 1166 | */ |
rgrover1 | 549:623e4c0f0b6e | 1167 | void onDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP)) { |
rgrover1 | 549:623e4c0f0b6e | 1168 | gattServer().onDataWritten(callback); |
rgrover1 | 549:623e4c0f0b6e | 1169 | } |
rgrover1 | 549:623e4c0f0b6e | 1170 | template <typename T> void onDataWritten(T * objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context)) { |
rgrover1 | 549:623e4c0f0b6e | 1171 | gattServer().onDataWritten(objPtr, memberPtr); |
rgrover1 | 549:623e4c0f0b6e | 1172 | } |
rgrover1 | 529:8d21604fe31d | 1173 | |
rgrover1 | 529:8d21604fe31d | 1174 | /** |
rgrover1 | 541:1fb1e0b809eb | 1175 | * Setup a callback for when a characteristic is being read by a client. |
rgrover1 | 541:1fb1e0b809eb | 1176 | * |
rgrover1 | 541:1fb1e0b809eb | 1177 | * @Note: this functionality may not be available on all underlying stacks. |
rgrover1 | 541:1fb1e0b809eb | 1178 | * You could use GattCharacteristic::setReadAuthorizationCallback() as an |
rgrover1 | 541:1fb1e0b809eb | 1179 | * alternative. |
rgrover1 | 541:1fb1e0b809eb | 1180 | * |
rgrover1 | 541:1fb1e0b809eb | 1181 | * @Note: it is possible to chain together multiple onDataRead callbacks |
rgrover1 | 541:1fb1e0b809eb | 1182 | * (potentially from different modules of an application) to receive updates |
rgrover1 | 541:1fb1e0b809eb | 1183 | * to characteristics. Services may add their own onDataRead callbacks |
rgrover1 | 541:1fb1e0b809eb | 1184 | * behind the scenes to trap interesting events. |
rgrover1 | 541:1fb1e0b809eb | 1185 | * |
rgrover1 | 541:1fb1e0b809eb | 1186 | * @Note: it is also possible to setup a callback into a member function of |
rgrover1 | 541:1fb1e0b809eb | 1187 | * some object. |
rgrover1 | 541:1fb1e0b809eb | 1188 | * |
rgrover1 | 541:1fb1e0b809eb | 1189 | * @return BLE_ERROR_NOT_IMPLEMENTED if this functionality isn't available; |
rgrover1 | 541:1fb1e0b809eb | 1190 | * else BLE_ERROR_NONE. |
rgrover1 | 529:8d21604fe31d | 1191 | */ |
rgrover1 | 541:1fb1e0b809eb | 1192 | ble_error_t onDataRead(void (*callback)(const GattReadCallbackParams *eventDataP)); |
rgrover1 | 541:1fb1e0b809eb | 1193 | template <typename T> ble_error_t onDataRead(T * objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context)); |
rgrover1 | 541:1fb1e0b809eb | 1194 | |
rgrover1 | 541:1fb1e0b809eb | 1195 | void onUpdatesEnabled(GattServer::EventCallback_t callback); |
rgrover1 | 541:1fb1e0b809eb | 1196 | void onUpdatesDisabled(GattServer::EventCallback_t callback); |
rgrover1 | 541:1fb1e0b809eb | 1197 | void onConfirmationReceived(GattServer::EventCallback_t callback); |
rgrover1 | 529:8d21604fe31d | 1198 | |
rgrover1 | 547:9fdf3d960d12 | 1199 | /** |
rgrover1 | 547:9fdf3d960d12 | 1200 | * Setup a callback for when the security setup procedure (key generation |
rgrover1 | 547:9fdf3d960d12 | 1201 | * and exchange) for a link has started. This will be skipped for bonded |
rgrover1 | 547:9fdf3d960d12 | 1202 | * devices. The callback is passed in parameters received from the peer's |
rgrover1 | 547:9fdf3d960d12 | 1203 | * security request: bool allowBonding, bool requireMITM, and |
rgrover1 | 547:9fdf3d960d12 | 1204 | * SecurityIOCapabilities_t. |
rgrover1 | 547:9fdf3d960d12 | 1205 | * |
rgrover1 | 547:9fdf3d960d12 | 1206 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1207 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1208 | * call to ble.onSecuritySetupInitiated(callback) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1209 | * ble.securityManager().onSecuritySetupInitiated(callback). |
rgrover1 | 547:9fdf3d960d12 | 1210 | */ |
rgrover1 | 547:9fdf3d960d12 | 1211 | void onSecuritySetupInitiated(SecurityManager::SecuritySetupInitiatedCallback_t callback) { |
rgrover1 | 547:9fdf3d960d12 | 1212 | securityManager().onSecuritySetupInitiated(callback); |
rgrover1 | 547:9fdf3d960d12 | 1213 | } |
rgrover1 | 547:9fdf3d960d12 | 1214 | |
rgrover1 | 547:9fdf3d960d12 | 1215 | /** |
rgrover1 | 547:9fdf3d960d12 | 1216 | * Setup a callback for when the security setup procedure (key generation |
rgrover1 | 547:9fdf3d960d12 | 1217 | * and exchange) for a link has completed. This will be skipped for bonded |
rgrover1 | 547:9fdf3d960d12 | 1218 | * devices. The callback is passed in the success/failure status of the |
rgrover1 | 547:9fdf3d960d12 | 1219 | * security setup procedure. |
rgrover1 | 547:9fdf3d960d12 | 1220 | * |
rgrover1 | 547:9fdf3d960d12 | 1221 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1222 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1223 | * call to ble.onSecuritySetupCompleted(callback) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1224 | * ble.securityManager().onSecuritySetupCompleted(callback). |
rgrover1 | 547:9fdf3d960d12 | 1225 | */ |
rgrover1 | 547:9fdf3d960d12 | 1226 | void onSecuritySetupCompleted(SecurityManager::SecuritySetupCompletedCallback_t callback) { |
rgrover1 | 547:9fdf3d960d12 | 1227 | securityManager().onSecuritySetupCompleted(callback); |
rgrover1 | 547:9fdf3d960d12 | 1228 | } |
rgrover1 | 547:9fdf3d960d12 | 1229 | |
rgrover1 | 547:9fdf3d960d12 | 1230 | /** |
rgrover1 | 547:9fdf3d960d12 | 1231 | * Setup a callback for when a link with the peer is secured. For bonded |
rgrover1 | 547:9fdf3d960d12 | 1232 | * devices, subsequent reconnections with bonded peer will result only in |
rgrover1 | 547:9fdf3d960d12 | 1233 | * this callback when the link is secured and setup procedures will not |
rgrover1 | 547:9fdf3d960d12 | 1234 | * occur unless the bonding information is either lost or deleted on either |
rgrover1 | 547:9fdf3d960d12 | 1235 | * or both sides. The callback is passed in a SecurityManager::SecurityMode_t according |
rgrover1 | 547:9fdf3d960d12 | 1236 | * to the level of security in effect for the secured link. |
rgrover1 | 547:9fdf3d960d12 | 1237 | * |
rgrover1 | 547:9fdf3d960d12 | 1238 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1239 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1240 | * call to ble.onLinkSecured(callback) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1241 | * ble.securityManager().onLinkSecured(callback). |
rgrover1 | 547:9fdf3d960d12 | 1242 | */ |
rgrover1 | 547:9fdf3d960d12 | 1243 | void onLinkSecured(SecurityManager::LinkSecuredCallback_t callback) { |
rgrover1 | 547:9fdf3d960d12 | 1244 | securityManager().onLinkSecured(callback); |
rgrover1 | 547:9fdf3d960d12 | 1245 | } |
rgrover1 | 547:9fdf3d960d12 | 1246 | |
rgrover1 | 547:9fdf3d960d12 | 1247 | /** |
rgrover1 | 547:9fdf3d960d12 | 1248 | * Setup a callback for successful bonding; i.e. that link-specific security |
rgrover1 | 547:9fdf3d960d12 | 1249 | * context is stored persistently for a peer device. |
rgrover1 | 547:9fdf3d960d12 | 1250 | * |
rgrover1 | 547:9fdf3d960d12 | 1251 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1252 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1253 | * call to ble.onSecurityContextStored(callback) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1254 | * ble.securityManager().onSecurityContextStored(callback). |
rgrover1 | 547:9fdf3d960d12 | 1255 | */ |
rgrover1 | 547:9fdf3d960d12 | 1256 | void onSecurityContextStored(SecurityManager::HandleSpecificEvent_t callback) { |
rgrover1 | 547:9fdf3d960d12 | 1257 | securityManager().onSecurityContextStored(callback); |
rgrover1 | 547:9fdf3d960d12 | 1258 | } |
rgrover1 | 547:9fdf3d960d12 | 1259 | |
rgrover1 | 547:9fdf3d960d12 | 1260 | /** |
rgrover1 | 547:9fdf3d960d12 | 1261 | * Setup a callback for when the passkey needs to be displayed on a |
rgrover1 | 547:9fdf3d960d12 | 1262 | * peripheral with DISPLAY capability. This happens when security is |
rgrover1 | 547:9fdf3d960d12 | 1263 | * configured to prevent Man-In-The-Middle attacks, and a PIN (or passkey) |
rgrover1 | 547:9fdf3d960d12 | 1264 | * needs to be exchanged between the peers to authenticate the connection |
rgrover1 | 547:9fdf3d960d12 | 1265 | * attempt. |
rgrover1 | 547:9fdf3d960d12 | 1266 | * |
rgrover1 | 547:9fdf3d960d12 | 1267 | * @note: This API is now *deprecated* and will be dropped in the future. |
rgrover1 | 547:9fdf3d960d12 | 1268 | * You should use the parallel API from SecurityManager directly. A former |
rgrover1 | 547:9fdf3d960d12 | 1269 | * call to ble.onPasskeyDisplay(callback) should be replaced with |
rgrover1 | 547:9fdf3d960d12 | 1270 | * ble.securityManager().onPasskeyDisplay(callback). |
rgrover1 | 547:9fdf3d960d12 | 1271 | */ |
rgrover1 | 547:9fdf3d960d12 | 1272 | void onPasskeyDisplay(SecurityManager::PasskeyDisplayCallback_t callback) { |
rgrover1 | 547:9fdf3d960d12 | 1273 | return securityManager().onPasskeyDisplay(callback); |
rgrover1 | 547:9fdf3d960d12 | 1274 | } |
rgrover1 | 547:9fdf3d960d12 | 1275 | |
rgrover1 | 529:8d21604fe31d | 1276 | public: |
rgrover1 | 532:bdcd44b03974 | 1277 | BLE() : transport(createBLEInstance()) { |
rgrover1 | 532:bdcd44b03974 | 1278 | /* empty */ |
rgrover1 | 529:8d21604fe31d | 1279 | } |
rgrover1 | 529:8d21604fe31d | 1280 | |
rgrover1 | 529:8d21604fe31d | 1281 | private: |
rgrover1 | 529:8d21604fe31d | 1282 | BLEInstanceBase *const transport; /* the device specific backend */ |
rgrover1 | 529:8d21604fe31d | 1283 | }; |
rgrover1 | 529:8d21604fe31d | 1284 | |
rgrover1 | 538:00d5affbb2b2 | 1285 | typedef BLE BLEDevice; /* DEPRECATED. This type alias is retained for the sake of compatibility with older |
rgrover1 | 529:8d21604fe31d | 1286 | * code. Will be dropped at some point soon.*/ |
rgrover1 | 529:8d21604fe31d | 1287 | |
rgrover1 | 529:8d21604fe31d | 1288 | /* BLE methods. Most of these simply forward the calls to the underlying |
rgrover1 | 529:8d21604fe31d | 1289 | * transport.*/ |
rgrover1 | 529:8d21604fe31d | 1290 | |
rgrover1 | 529:8d21604fe31d | 1291 | inline ble_error_t |
rgrover1 | 529:8d21604fe31d | 1292 | BLE::onDataRead(void (*callback)(const GattReadCallbackParams *eventDataP)) { |
rgrover1 | 529:8d21604fe31d | 1293 | return transport->getGattServer().setOnDataRead(callback); |
rgrover1 | 529:8d21604fe31d | 1294 | } |
rgrover1 | 529:8d21604fe31d | 1295 | |
rgrover1 | 529:8d21604fe31d | 1296 | template <typename T> inline ble_error_t |
rgrover1 | 529:8d21604fe31d | 1297 | BLE::onDataRead(T *objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context)) { |
rgrover1 | 529:8d21604fe31d | 1298 | return transport->getGattServer().setOnDataRead(objPtr, memberPtr); |
rgrover1 | 529:8d21604fe31d | 1299 | } |
rgrover1 | 529:8d21604fe31d | 1300 | |
rgrover1 | 529:8d21604fe31d | 1301 | inline void |
rgrover1 | 529:8d21604fe31d | 1302 | BLE::onUpdatesEnabled(GattServer::EventCallback_t callback) |
rgrover1 | 529:8d21604fe31d | 1303 | { |
rgrover1 | 529:8d21604fe31d | 1304 | transport->getGattServer().setOnUpdatesEnabled(callback); |
rgrover1 | 529:8d21604fe31d | 1305 | } |
rgrover1 | 529:8d21604fe31d | 1306 | |
rgrover1 | 529:8d21604fe31d | 1307 | inline void |
rgrover1 | 529:8d21604fe31d | 1308 | BLE::onUpdatesDisabled(GattServer::EventCallback_t callback) |
rgrover1 | 529:8d21604fe31d | 1309 | { |
rgrover1 | 529:8d21604fe31d | 1310 | transport->getGattServer().setOnUpdatesDisabled(callback); |
rgrover1 | 529:8d21604fe31d | 1311 | } |
rgrover1 | 529:8d21604fe31d | 1312 | |
rgrover1 | 529:8d21604fe31d | 1313 | inline void |
rgrover1 | 529:8d21604fe31d | 1314 | BLE::onConfirmationReceived(GattServer::EventCallback_t callback) |
rgrover1 | 529:8d21604fe31d | 1315 | { |
rgrover1 | 529:8d21604fe31d | 1316 | transport->getGattServer().setOnConfirmationReceived(callback); |
rgrover1 | 529:8d21604fe31d | 1317 | } |
rgrover1 | 529:8d21604fe31d | 1318 | |
rgrover1 | 529:8d21604fe31d | 1319 | #endif // ifndef __BLE_H__ |