Includes library modifications to allow access to AIN_4 (AIN_0 / 5)

Committer:
bryantaylor
Date:
Tue Sep 20 21:26:12 2016 +0000
Revision:
0:eafc3fd41f75
hackathon

Who changed what in which revision?

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