add "LE Device Address" 0x1B to advertising data types

Fork of BLE_API by Bluetooth Low Energy

Committer:
rgrover1
Date:
Fri Jun 19 15:53:28 2015 +0100
Revision:
710:b2e1a2660ec2
Parent:
public/BLE.h@563:62cc3335df23
Synchronized with git rev 7e8977d8
Author: Rohit Grover
Release 0.3.8
=============

This is a minor set of enhancements before we yotta-ize BLE_API.

Enhancements
~~~~~~~~~~~~

* Minor rework for class UUID; added a default and copy constructor; and a != operator.

* Added copy constructor and accessors for GapAdvertisingParams.

* GapScanningParams:: remove unnecessary checks for SCAN_TIMEOUT_MAX.

* Add a comment header block to explain why BLEDevice::init() may not be safe
to call from global static context.

* Introduce GattAttribute::INVALID_HANDLE.

* Replace some deprecated uses of Gap::address_t with Gap::Address_t.

Bugfixes
~~~~~~~~

* None.

Who changed what in which revision?

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