Gleb Klochkov / Mbed OS Climatcontroll_Main

Dependencies:   esp8266-driver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BLE.h Source File

BLE.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef MBED_BLE_H__
00018 #define MBED_BLE_H__
00019 
00020 #include "blecommon.h"
00021 #include "Gap.h"
00022 #include "GattServer.h"
00023 #include "GattClient.h"
00024 #include "SecurityManager.h"
00025 
00026 #include "ble/FunctionPointerWithContext.h "
00027 
00028 #ifdef YOTTA_CFG_MBED_OS
00029 #include "mbed-drivers/mbed_error.h"
00030 #else
00031 #include "platform/mbed_error.h"
00032 #endif
00033 
00034 #include "platform/mbed_toolchain.h"
00035 
00036 /* Forward declaration for the implementation class */
00037 class BLEInstanceBase;
00038 
00039 /**
00040  * @addtogroup ble
00041  * @{
00042  */
00043 
00044 /**
00045  * Abstract away BLE-capable radio transceivers or SOCs.
00046  *
00047  * Instances of this class have three responsibilities:
00048  *   - Initialize the inner BLE subsystem.
00049  *   - Signal user code that BLE events are available and an API to process them.
00050  *   - Manage access to the instances abstracting each BLE layer:
00051  *        + GAP: Handle advertising and scan, as well as connection and
00052  *          disconnection.
00053  *        + GATTServer: API to construct and manage a GATT server, which connected peers can
00054  *          access.
00055  *        + GATTClient: API to interact with a peer GATT server.
00056  *        + SecurityManager: API to manage security.
00057  *
00058  * The user should not create BLE instances directly but rather access to the
00059  * singleton(s) holding the BLE interfaces present in the system by using the
00060  * static function Instance().
00061  *
00062  * @code
00063  * #include "ble/BLE.h"
00064  *
00065  * BLE& ble_interface = BLE::Instance();
00066  * @endcode
00067  *
00068  * Next, the signal handling/process mechanism should be set up. By design,
00069  * Mbed BLE does not impose to the user an event handling/processing mechanism;
00070  * however, it exposes APIs, which allows an application to compose its own:
00071  *   - onEventsToProcess(), whichs register a callback that
00072  *     the BLE subsystem will call when there is an event ready to be processed.
00073  *   - processEvents(), which processes all the events present in the BLE subsystem.
00074  *
00075  * It is common to bind BLE event mechanism with Mbed EventQueue:
00076  *
00077  * @code
00078  * #include <events/mbed_events.h>
00079  * #include "ble/BLE.h"
00080  *
00081  * // declare the event queue, which the whole application will share.
00082  * static EventQueue event_queue( 4 * EVENTS_EVENT_SIZE);
00083  *
00084  * // Function invoked when there is a BLE event available.
00085  * // It put into the event queue the processing of the event(s)
00086  * void schedule_ble_processing(BLE::OnEventsToProcessCallbackContext* context) {
00087  *   event_queue.call(callback(&(context->ble), &BLE::processEvents));
00088  * }
00089  *
00090  * int main()
00091  * {
00092  *   BLE &ble_interface = BLE::Instance();
00093  *
00094  *   // Bind event signaling to schedule_ble_processing
00095  *   ble_interface.onEventsToProcess(schedule_ble_processing);
00096  *
00097  *   // Launch BLE initialisation
00098  *
00099  *   // Dispatch events in the event queue
00100  *   event_queue.dispatch_forever();
00101  *   return 0;
00102  * }
00103  * @endcode
00104  *
00105  * Once the event processing mechanism is in place, the Bluetooth subsystem can
00106  * be initialized with the init() function. That function accepts in input a
00107  * callback, which will be invoked once the initialization process has finished.
00108  *
00109  * @code
00110  * void on_ble_init_complete(BLE::InitializationCompleteCallbackContext *context)
00111  * {
00112  *   BLE& ble_interface = context->ble;
00113  *   ble_error_t initialization_error = context->error;
00114  *
00115  *   if (initialization_error) {
00116  *     // handle error
00117  *     return;
00118  *   }
00119  *
00120  *   // The BLE interface can be accessed now.
00121  * }
00122  *
00123  * int main() {
00124  *   BLE &ble_interface = BLE::Instance();
00125  *   ble_interface.onEventsToProcess(schedule_ble_processing);
00126  *
00127  *   // Initialize the BLE interface
00128  *   ble_interface.init(on_ble_init_complete);
00129  *
00130  *   event_queue.dispatch_forever();
00131  *   return 0;
00132  * }
00133  * @endcode
00134  */
00135 class BLE
00136 {
00137 public:
00138     /**
00139      * Opaque type used to store the ID of a BLE instance.
00140      */
00141     typedef unsigned InstanceID_t;
00142 
00143     /**
00144      * The value of the BLE::InstanceID_t for the default BLE instance.
00145      */
00146     static const InstanceID_t DEFAULT_INSTANCE = 0;
00147 
00148 #ifndef YOTTA_CFG_BLE_INSTANCES_COUNT
00149     /**
00150      * The number of permitted BLE instances for the application.
00151      */
00152     static const InstanceID_t NUM_INSTANCES = 1;
00153 #else
00154     /**
00155      * The number of permitted BLE instances for the application.
00156      */
00157     static const InstanceID_t NUM_INSTANCES = YOTTA_CFG_BLE_INSTANCES_COUNT;
00158 #endif
00159 
00160     /**
00161      * Get a reference to the BLE singleton corresponding to a given interface.
00162      *
00163      * There is a static array of BLE singletons.
00164      *
00165      * @note Calling Instance() is preferred over constructing a BLE object
00166      * directly because it returns references to singletons.
00167      *
00168      * @param[in] id BLE Instance ID to get.
00169      *
00170      * @return A reference to a single object.
00171      *
00172      * @pre id shall be less than NUM_INSTANCES.
00173      */
00174     static BLE &Instance(InstanceID_t id = DEFAULT_INSTANCE);
00175 
00176     /**
00177      * Fetch the ID of a BLE instance.
00178      *
00179      * @return Instance id of this BLE instance.
00180      */
00181     InstanceID_t getInstanceID(void) const {
00182         return instanceID;
00183     }
00184 
00185     /**
00186      * Events to process event.
00187      *
00188      * Instances of OnEventsToProcessCallbackContext are passed to the event
00189      * handler registered with onEventsToProcess().
00190      */
00191     struct OnEventsToProcessCallbackContext {
00192         /**
00193          * The ble instance which have events to process.
00194          */
00195         BLE& ble;
00196     };
00197 
00198     /**
00199      * Events to process event handler
00200      */
00201     typedef FunctionPointerWithContext<OnEventsToProcessCallbackContext*> 
00202         OnEventsToProcessCallback_t;
00203 
00204     /**
00205      * Register a callback called when the BLE stack has pending work.
00206      *
00207      * By registering a callback, application code can know when event processing
00208      * has to be scheduled.
00209      *
00210      * @param on_event_cb Callback invoked when there are new events to process.
00211      */
00212     void onEventsToProcess(const OnEventsToProcessCallback_t & on_event_cb);
00213 
00214     /**
00215      * Process ALL pending events living in the BLE stack and return once all
00216      * events have been consumed.
00217      *
00218      * @see onEventsToProcess()
00219      */
00220     void processEvents();
00221 
00222     /**
00223      * Initialization complete event.
00224      *
00225      * This event is generated at the end of the init() procedure and is passed
00226      * to the completion callback passed to init().
00227      */
00228     struct InitializationCompleteCallbackContext {
00229         /**
00230          * Reference to the BLE object that has been initialized
00231          */
00232         BLE& ble;
00233 
00234         /**
00235          * Error status of the initialization.
00236          *
00237          * That value is set to BLE_ERROR_NONE if initialization completed
00238          * successfully or the appropriate error code otherwise.
00239          * */
00240         ble_error_t error;
00241     };
00242 
00243     /**
00244      * Initialization complete event handler.
00245      *
00246      * @note There are two versions of init(). In addition to the
00247      * function-pointer, init() can also take an <Object, member> tuple as its
00248      * callback target. In case of the latter, the following declaration doesn't
00249      * apply.
00250      */
00251     typedef void (*InitializationCompleteCallback_t)(
00252         InitializationCompleteCallbackContext *context
00253     );
00254 
00255     /**
00256      * Initialize the BLE controller/stack.
00257      *
00258      * init() hands control to the underlying BLE module to accomplish
00259      * initialization. This initialization may tacitly depend on other hardware
00260      * setup (such as clocks or power-modes) that happens early on during system
00261      * startup. It may not be safe to call init() from a global static context
00262      * where ordering is compiler-specific and can't be guaranteed - it is safe
00263      * to call BLE::init() from within main().
00264      *
00265      * @param[in] completion_cb A callback for when initialization completes for
00266      * a BLE instance. This is an optional parameter; if no callback is set up,
00267      * the application can still determine the status of initialization using
00268      * BLE::hasInitialized() (see below).
00269      *
00270      * @return BLE_ERROR_NONE if the initialization procedure started
00271      * successfully.
00272      *
00273      * @note If init() returns BLE_ERROR_NONE, the underlying stack must invoke
00274      * the initialization completion callback at some point.
00275      *
00276      * @note Nearly all BLE APIs would return BLE_ERROR_INITIALIZATION_INCOMPLETE
00277      * if used on an instance before the corresponding transport is initialized.
00278      *
00279      * @note There are two versions of init(). In addition to the
00280      * function-pointer, init() can also take an <Object, member> pair as its
00281      * callback target.
00282      *
00283      * @attention This should be called before using anything else in the BLE
00284      * API.
00285      */
00286     ble_error_t init(InitializationCompleteCallback_t completion_cb = NULL) {
00287         FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback(completion_cb);
00288         return initImplementation(callback);
00289     }
00290 
00291     /**
00292      * Initialize the BLE controller/stack.
00293      *
00294      * This is an alternate declaration for init(). This one takes an
00295      * <Object, member> pair as its callback target.
00296      *
00297      * @param[in] object Object, which will be used to invoke the completion callback.
00298      * @param[in] completion_cb Member function pointer, which will be invoked when
00299      * initialization is complete.
00300      */
00301     template<typename T>
00302     ble_error_t init(T *object, void (T::*completion_cb)(InitializationCompleteCallbackContext *context)) {
00303         FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback(object, completion_cb);
00304         return initImplementation(callback);
00305     }
00306 
00307     /**
00308      * Indicate if the BLE instance has been initialized.
00309      *
00310      * @return true if initialization has completed for the underlying BLE
00311      * transport.
00312      *
00313      * @note The application should set up a callback to signal completion of
00314      * initialization when using init().
00315      */
00316     bool hasInitialized(void) const;
00317 
00318     /**
00319      * Shut down the underlying stack, and reset state of this BLE instance.
00320      *
00321      * @return BLE_ERROR_NONE if the instance was shut down without error or the
00322      * appropriate error code.
00323      *
00324      * @attention init() must be called afterward to reinstate services and
00325      * GAP state. This API offers a way to repopulate the GATT database with new
00326      * services and characteristics.
00327      */
00328     ble_error_t shutdown(void);
00329 
00330     /**
00331      * This call allows the application to get the BLE stack version information.
00332      *
00333      * @return A pointer to a const string representing the version.
00334      *
00335      * @note The BLE API owns the string returned.
00336      */
00337     const char *getVersion(void);
00338 
00339     /**
00340      * Accessor to Gap. All Gap-related functionality requires going through
00341      * this accessor.
00342      *
00343      * @return A reference to a Gap object associated to this BLE instance.
00344      */
00345     Gap &gap();
00346 
00347     /**
00348      * A const alternative to gap().
00349      *
00350      * @return A const reference to a Gap object associated to this BLE instance.
00351      */
00352     const Gap &gap() const;
00353 
00354     /**
00355      * Accessor to GattServer. All GattServer related functionality requires
00356      * going through this accessor.
00357      *
00358      * @return A reference to a GattServer object associated to this BLE instance.
00359      */
00360     GattServer& gattServer();
00361 
00362     /**
00363      * A const alternative to gattServer().
00364      *
00365      * @return A const reference to a GattServer object associated to this BLE
00366      * instance.
00367      */
00368     const GattServer& gattServer() const;
00369 
00370     /**
00371      * Accessors to GattClient. All GattClient related functionality requires
00372      * going through this accessor.
00373      *
00374      * @return A reference to a GattClient object associated to this BLE instance.
00375      */
00376     GattClient& gattClient();
00377 
00378     /**
00379      * A const alternative to gattClient().
00380      *
00381      * @return A const reference to a GattClient object associated to this BLE
00382      * instance.
00383      */
00384     const GattClient& gattClient() const;
00385 
00386     /**
00387      * Accessors to SecurityManager. All SecurityManager-related functionality
00388      * requires going through this accessor.
00389      *
00390      * @return A reference to a SecurityManager object associated to this BLE
00391      * instance.
00392      */
00393     SecurityManager& securityManager();
00394 
00395     /**
00396      * A const alternative to securityManager().
00397      *
00398      * @return A const reference to a SecurityManager object associated to this
00399      * BLE instance.
00400      */
00401     const SecurityManager& securityManager() const;
00402 
00403     /**
00404      * Translate error code into a printable string.
00405      *
00406      * @param[in] error Error code returned by BLE functions.
00407      *
00408      * @return A pointer to a const string describing the error.
00409      */
00410     static const char* errorToString(ble_error_t error);
00411 
00412     /*
00413      * Deprecation alert!
00414      * All of the following are deprecated and may be dropped in a future
00415      * release. Documentation should refer to alternative APIs.
00416      */
00417 public:
00418     /**
00419      * Constructor for a handle to a BLE instance (the BLE stack). BLE handles
00420      * are thin wrappers around a transport object (that is, ptr. to
00421      * BLEInstanceBase).
00422      *
00423      * It is better to create BLE objects as singletons accessed through the
00424      * Instance() method. If multiple BLE handles are constructed for the same
00425      * interface (using this constructor), they share the same underlying
00426      * transport object.
00427      *
00428      * @deprecated Use the Instance() function instead of the constructor.
00429      */
00430     MBED_DEPRECATED("Use BLE::Instance() instead of BLE constructor.")
00431     BLE(InstanceID_t instanceID = DEFAULT_INSTANCE);
00432 
00433     /**
00434      * Yield control to the BLE stack or to other tasks waiting for events.
00435      *
00436      * This is a sleep function that returns when there is an application-specific
00437      * interrupt. This is not interchangeable with WFE() considering that the
00438      * MCU might wake up several times to service the stack before returning
00439      * control to the caller.
00440      *
00441      * @deprecated This function block the CPU prefer to use the pair
00442      * onEventsToProcess() and processEvents().
00443      */
00444     MBED_DEPRECATED("Use BLE::processEvents() and BLE::onEventsToProcess().")
00445     void waitForEvent(void);
00446 
00447     /**
00448      * Set the BTLE MAC address and type.
00449      *
00450      * @return BLE_ERROR_NONE on success.
00451      *
00452      * @deprecated You should use the parallel API from Gap directly, refer to
00453      * Gap::setAddress(). A former call to ble.setAddress(...) should be
00454      * replaced with ble.gap().setAddress(...).
00455      */
00456     MBED_DEPRECATED("Use ble.gap().setAddress(...)")
00457     ble_error_t setAddress(
00458         BLEProtocol::AddressType_t type,
00459         const BLEProtocol::AddressBytes_t address
00460     ) {
00461         return gap().setAddress(type, address);
00462     }
00463 
00464     /**
00465      * Fetch the Bluetooth Low Energy MAC address and type.
00466      *
00467      * @return BLE_ERROR_NONE on success.
00468      *
00469      * @deprecated You should use the parallel API from Gap directly and refer to
00470      * Gap::getAddress(). A former call to ble.getAddress(...) should be
00471      * replaced with ble.gap().getAddress(...).
00472      */
00473     MBED_DEPRECATED("Use ble.gap().getAddress(...)")
00474     ble_error_t getAddress(
00475         BLEProtocol::AddressType_t *typeP, BLEProtocol::AddressBytes_t address
00476     ) {
00477         return gap().getAddress(typeP, address);
00478     }
00479 
00480     /**
00481      * Set the GAP advertising mode to use for this device.
00482      *
00483      * @deprecated You should use the parallel API from Gap directly and refer to
00484      *             Gap::setAdvertisingType(). A former call to
00485      *             ble.setAdvertisingType(...) should be replaced with
00486      *             ble.gap().setAdvertisingType(...).
00487      */
00488     MBED_DEPRECATED("Use ble.gap().setAdvertisingType(...)")
00489     void setAdvertisingType(GapAdvertisingParams::AdvertisingType advType) {
00490         gap().setAdvertisingType(advType);
00491     }
00492 
00493     /**
00494      * @param[in] interval
00495      *              Advertising interval in units of milliseconds. Advertising
00496      *              is disabled if interval is 0. If interval is smaller than
00497      *              the minimum supported value, then the minimum supported
00498      *              value is used instead. This minimum value can be discovered
00499      *              using getMinAdvertisingInterval().
00500      *
00501      *              This field must be set to 0 if connectionMode is equal
00502      *              to ADV_CONNECTABLE_DIRECTED.
00503      *
00504      * @note Decreasing this value allows central devices to detect a
00505      * peripheral faster at the expense of more power being used by the radio
00506      * due to the higher data transmit rate.
00507      *
00508      * @deprecated You should use the parallel API from Gap directly and refer to
00509      *             Gap::setAdvertisingInterval(). A former call to
00510      *             ble.setAdvertisingInterval(...) should be replaced with
00511      *             ble.gap().setAdvertisingInterval(...).
00512      *
00513      * @note WARNING: This API previously used 0.625ms as the unit for its
00514      * 'interval' argument. That required an explicit conversion from
00515      * milliseconds using Gap::MSEC_TO_GAP_DURATION_UNITS(). This conversion is
00516      * no longer required as the new units are milliseconds. Any application
00517      * code depending on the old semantics needs to be updated accordingly.
00518      */
00519     MBED_DEPRECATED("Use ble.gap().setAdvertisingInterval(...)")
00520     void setAdvertisingInterval(uint16_t interval) {
00521         gap().setAdvertisingInterval(interval);
00522     }
00523 
00524     /**
00525      * @return Minimum Advertising interval in milliseconds.
00526      *
00527      * @deprecated You should use the parallel API from Gap directly, refer to
00528      *             Gap::getMinAdvertisingInterval(). A former call to
00529      *             ble.getMinAdvertisingInterval(...) should be replaced with
00530      *             ble.gap().getMinAdvertisingInterval(...).
00531      */
00532     MBED_DEPRECATED("Use ble.gap().getMinAdvertisingInterval(...)")
00533     uint16_t getMinAdvertisingInterval(void) const {
00534         return gap().getMinAdvertisingInterval();
00535     }
00536 
00537     /**
00538      * @return Minimum Advertising interval in milliseconds for nonconnectible mode.
00539      *
00540      * @deprecated You should use the parallel API from Gap directly, refer to
00541      *             Gap::MinNonConnectableAdvertisingInterval(). A former call to
00542      *             ble.getMinNonConnectableAdvertisingInterval(...) should be replaced with
00543      *             ble.gap().getMinNonConnectableAdvertisingInterval(...).
00544      */
00545     MBED_DEPRECATED("Use ble.gap().getMinNonConnectableAdvertisingInterval(...)")
00546     uint16_t getMinNonConnectableAdvertisingInterval(void) const {
00547         return gap().getMinNonConnectableAdvertisingInterval();
00548     }
00549 
00550     /**
00551      * @return Maximum Advertising interval in milliseconds.
00552      *
00553      * @deprecated You should use the parallel API from Gap directly, refer to
00554      *             Gap::getMaxAdvertisingInterval(). A former call to
00555      *             ble.getMaxAdvertisingInterval(...) should be replaced with
00556      *             ble.gap().getMaxAdvertisingInterval(...).
00557      */
00558     MBED_DEPRECATED("Use ble.gap().getMaxAdvertisingInterval(...)")
00559     uint16_t getMaxAdvertisingInterval(void) const {
00560         return gap().getMaxAdvertisingInterval();
00561     }
00562 
00563     /**
00564      * @param[in] timeout
00565      *              Advertising timeout (in seconds) between 0x1 and 0x3FFF (1
00566      *              and 16383). Use 0 to disable the advertising timeout.
00567      *
00568      * @deprecated You should use the parallel API from Gap directly and refer to
00569      *             Gap::setAdvertisingTimeout(). A former call to
00570      *             ble.setAdvertisingTimeout(...) should be replaced with
00571      *             ble.gap().setAdvertisingTimeout(...).
00572      */
00573     MBED_DEPRECATED("Use ble.gap().setAdvertisingTimeout(...)")
00574     void setAdvertisingTimeout(uint16_t timeout) {
00575         gap().setAdvertisingTimeout(timeout);
00576     }
00577 
00578     /**
00579      * Set up a particular, user-constructed set of advertisement parameters for
00580      * the underlying stack. It would be uncommon for this API to be used
00581      * directly; there are other APIs to tweak advertisement parameters
00582      * individually (see above).
00583      *
00584      * @deprecated You should use the parallel API from Gap directly and refer to
00585      *             Gap::setAdvertisingParams(). A former call to
00586      *             ble.setAdvertisingParams(...) should be replaced with
00587      *             ble.gap().setAdvertisingParams(...).
00588      */
00589     MBED_DEPRECATED("Use ble.gap().setAdvertisingParams(...)")
00590     void setAdvertisingParams(const GapAdvertisingParams &advParams) {
00591         gap().setAdvertisingParams(advParams);
00592     }
00593 
00594     /**
00595      * @return  Read back advertising parameters. Useful for storing and
00596      *          restoring parameters rapidly.
00597      *
00598      * @deprecated You should use the parallel API from Gap directly and refer to
00599      *             Gap::getAdvertisingParams(). A former call to
00600      *             ble.getAdvertisingParams(...) should be replaced with
00601      *             ble.gap().getAdvertisingParams(...).
00602      */
00603     MBED_DEPRECATED("Use ble.gap().getAdvertisingParams(...)")
00604     const GapAdvertisingParams &getAdvertisingParams(void) const {
00605         return gap().getAdvertisingParams();
00606     }
00607 
00608     /**
00609      * Accumulate an AD structure in the advertising payload. Please note that
00610      * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
00611      * as an additional 31 bytes if the advertising payload is too
00612      * small.
00613      *
00614      * @param[in] flags
00615      *              The flags to add. Please refer to
00616      *              GapAdvertisingData::Flags for valid flags. Multiple
00617      *              flags may be specified in combination.
00618      *
00619      * @deprecated You should use the parallel API from Gap directly, refer to
00620      *             Gap::accumulateAdvertisingPayload(uint8_t). A former call to
00621      *             ble.accumulateAdvertisingPayload(flags) should be replaced with
00622      *             ble.gap().accumulateAdvertisingPayload(flags).
00623      */
00624     MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayload(flags)")
00625     ble_error_t accumulateAdvertisingPayload(uint8_t flags) {
00626         return gap().accumulateAdvertisingPayload(flags);
00627     }
00628 
00629     /**
00630      * Accumulate an AD structure in the advertising payload. Please note that
00631      * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
00632      * as an additional 31 bytes if the advertising payload is too
00633      * small.
00634      *
00635      * @param[in] app
00636      *              The appearance of the peripheral.
00637      *
00638      * @deprecated You should use the parallel API from Gap directly and refer to
00639      *             Gap::accumulateAdvertisingPayload(GapAdvertisingData::Appearance).
00640      *             A former call to ble.accumulateAdvertisingPayload(appearance)
00641      *             should be replaced with
00642      *             ble.gap().accumulateAdvertisingPayload(appearance).
00643      */
00644     MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayload(appearance)")
00645     ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::Appearance app) {
00646         return gap().accumulateAdvertisingPayload(app);
00647     }
00648 
00649     /**
00650      * Accumulate an AD structure in the advertising payload. Please note that
00651      * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
00652      * as an additional 31 bytes if the advertising payload is too
00653      * small.
00654      *
00655      * @param[in] power
00656      *              The max transmit power to be used by the controller. This
00657      *              is only a hint.
00658      *
00659      * @deprecated You should use the parallel API from Gap directly and refer to
00660      *             Gap::accumulateAdvertisingPayloadTxPower(). A former call to
00661      *             ble.accumulateAdvertisingPayloadTxPower(txPower) should be replaced with
00662      *             ble.gap().accumulateAdvertisingPayloadTxPower(txPower).
00663      */
00664     MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayloadTxPower(...)")
00665     ble_error_t accumulateAdvertisingPayloadTxPower(int8_t power) {
00666         return gap().accumulateAdvertisingPayloadTxPower(power);
00667     }
00668 
00669     /**
00670      * Accumulate a variable length byte-stream as an AD structure in the
00671      * advertising payload. Please note that the payload is limited to 31 bytes.
00672      * The SCAN_RESPONSE message may be used as an additional 31 bytes if the
00673      * advertising payload is too small.
00674      *
00675      * @param  type The type that describes the variable length data.
00676      * @param  data Data bytes.
00677      * @param  len  Data length.
00678      *
00679      * @deprecated You should use the parallel API from Gap directly, refer to
00680      *             Gap::accumulateAdvertisingPayload(GapAdvertisingData::DataType, const uint8_t, uint8_t).
00681      *             A former call to ble.accumulateAdvertisingPayload(...) should
00682      *             be replaced with ble.gap().accumulateAdvertisingPayload(...).
00683      */
00684     MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayload(...)")
00685     ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) {
00686         return gap().accumulateAdvertisingPayload(type, data, len);
00687     }
00688 
00689     /**
00690      * Set up a particular, user-constructed advertisement payload for the
00691      * underlying stack. It would be uncommon for this API to be used directly;
00692      * there are other APIs to build an advertisement payload (see above).
00693      *
00694      * @deprecated You should use the parallel API from Gap directly, refer to
00695      *             Gap::setAdvertisingData(). A former call to
00696      *             ble.setAdvertisingData(...) should be replaced with
00697      *             ble.gap().setAdvertisingPayload(...).
00698      */
00699     MBED_DEPRECATED("Use ble.gap().setAdvertisingData(...)")
00700     ble_error_t setAdvertisingData(const GapAdvertisingData &advData) {
00701         return gap().setAdvertisingPayload(advData);
00702     }
00703 
00704     /**
00705      * @return  Read back advertising data. Useful for storing and
00706      *          restoring payload.
00707      *
00708      * @deprecated You should use the parallel API from Gap directly, refer to
00709      *             Gap::getAdvertisingData(). A former call to
00710      *             ble.getAdvertisingData(...) should be replaced with
00711      *             ble.gap().getAdvertisingPayload()(...).
00712      */
00713     MBED_DEPRECATED("Use ble.gap().getAdvertisingData(...)")
00714     const GapAdvertisingData &getAdvertisingData(void) const {
00715         return gap().getAdvertisingPayload();
00716     }
00717 
00718     /**
00719      * Reset any advertising payload prepared from prior calls to
00720      * accumulateAdvertisingPayload(). This automatically propagates the re-
00721      * initialized advertising payload to the underlying stack.
00722      *
00723      * @deprecated You should use the parallel API from Gap directly and refer to
00724      *             Gap::clearAdvertisingPayload(). A former call to
00725      *             ble.clearAdvertisingPayload(...) should be replaced with
00726      *             ble.gap().clearAdvertisingPayload(...).
00727      */
00728     MBED_DEPRECATED("Use ble.gap().clearAdvertisingPayload(...)")
00729     void clearAdvertisingPayload(void) {
00730         gap().clearAdvertisingPayload();
00731     }
00732 
00733     /**
00734      * Dynamically reset the accumulated advertising
00735      * payload and scanResponse. The application must clear and re-
00736      * accumulate a new advertising payload (and scanResponse) before using this
00737      * API.
00738      *
00739      * @return BLE_ERROR_NONE when the advertising payload is set successfully.
00740      *
00741      * @deprecated You should use the parallel API from Gap directly, refer to
00742      *             Gap::setAdvertisingPayload().
00743      *
00744      * @note The new APIs in Gap update the underlying advertisement payload
00745      * implicitly.
00746      */
00747     MBED_DEPRECATED("Use ble.gap().setAdvertisingPayload(...)")
00748     ble_error_t setAdvertisingPayload(void) {
00749         return BLE_ERROR_NONE;
00750     }
00751 
00752     /**
00753      * Accumulate a variable length byte-stream as an AD structure in the
00754      * scanResponse payload.
00755      *
00756      * @param[in] type The type that describes the variable length data.
00757      * @param[in] data Data bytes.
00758      * @param[in] len  Data length.
00759      *
00760      * @deprecated You should use the parallel API from Gap directly and refer to
00761      *             Gap::accumulateScanResponse(). A former call to
00762      *             ble.accumulateScanResponse(...) should be replaced with
00763      *             ble.gap().accumulateScanResponse(...).
00764      */
00765     MBED_DEPRECATED("Use ble.gap().accumulateScanResponse(...)")
00766     ble_error_t accumulateScanResponse(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) {
00767         return gap().accumulateScanResponse(type, data, len);
00768     }
00769 
00770     /**
00771      * Reset any scan response prepared from prior calls to
00772      * accumulateScanResponse().
00773      *
00774      * @deprecated You should use the parallel API from Gap directly and refer to
00775      *             Gap::clearScanResponse(). A former call to
00776      *             ble.clearScanResponse(...) should be replaced with
00777      *             ble.gap().clearScanResponse(...).
00778      */
00779     MBED_DEPRECATED("Use ble.gap().clearScanResponse(...)")
00780     void clearScanResponse(void) {
00781         gap().clearScanResponse();
00782     }
00783 
00784     /**
00785      * Start advertising.
00786      *
00787      * @deprecated You should use the parallel API from Gap directly and refer to
00788      *             Gap::startAdvertising(). A former call to
00789      *             ble.startAdvertising(...) should be replaced with
00790      *             ble.gap().startAdvertising(...).
00791      */
00792     MBED_DEPRECATED("Use ble.gap().startAdvertising(...)")
00793     ble_error_t startAdvertising(void) {
00794         return gap().startAdvertising();
00795     }
00796 
00797     /**
00798      * Stop advertising.
00799      *
00800      * @deprecated You should use the parallel API from Gap directly and refer to
00801      *             Gap::stopAdvertising(). A former call to
00802      *             ble.stopAdvertising(...) should be replaced with
00803      *             ble.gap().stopAdvertising(...).
00804      */
00805     MBED_DEPRECATED("Use ble.gap().stopAdvertising(...)")
00806     ble_error_t stopAdvertising(void) {
00807         return gap().stopAdvertising();
00808     }
00809 
00810     /**
00811      * Set up parameters for GAP scanning (observer mode).
00812      * @param[in] interval
00813      *              Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s].
00814      * @param[in] window
00815      *              Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s].
00816      * @param[in] timeout
00817      *              Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables timeout.
00818      * @param[in] activeScanning
00819      *              Set to True if active-scanning is required. This is used to fetch the
00820      *              scan response from a peer if possible.
00821      *
00822      * The scanning window divided by the interval determines the duty cycle for
00823      * scanning. For example, if the interval is 100ms and the window is 10ms,
00824      * then the controller will scan for 10 percent of the time. It is possible
00825      * to have the interval and window set to the same value. In this case,
00826      * scanning is continuous, with a change of scanning frequency once every
00827      * interval.
00828      *
00829      * Once the scanning parameters have been configured, scanning can be
00830      * enabled by using startScan().
00831      *
00832      * @note The scan interval and window are recommendations to the BLE stack.
00833      *
00834      * @deprecated You should use the parallel API from Gap directly and refer to
00835      *             Gap::setScanParams(). A former call to
00836      *             ble.setScanParams(...) should be replaced with
00837      *             ble.gap().setScanParams(...).
00838      */
00839     MBED_DEPRECATED("Use ble.gap().setScanParams(...)")
00840     ble_error_t setScanParams(uint16_t interval       = GapScanningParams::SCAN_INTERVAL_MAX,
00841                               uint16_t window         = GapScanningParams::SCAN_WINDOW_MAX,
00842                               uint16_t timeout        = 0,
00843                               bool     activeScanning = false) {
00844         return gap().setScanParams(interval, window, timeout, activeScanning);
00845     }
00846 
00847     /**
00848      * Set up the scanInterval parameter for GAP scanning (observer mode).
00849      * @param[in] interval
00850      *              Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s].
00851      *
00852      * The scanning window divided by the interval determines the duty cycle for
00853      * scanning. For example, if the interval is 100ms and the window is 10ms,
00854      * then the controller will scan for 10 percent of the time. It is possible
00855      * to have the interval and window set to the same value. In this case,
00856      * scanning is continuous, with a change of scanning frequency once every
00857      * interval.
00858      *
00859      * Once the scanning parameters have been configured, scanning can be
00860      * enabled by using startScan().
00861      *
00862      * @deprecated You should use the parallel API from Gap directly and refer to
00863      *             Gap::setScanInterval(). A former call to
00864      *             ble.setScanInterval(interval) should be replaced with
00865      *             ble.gap().setScanInterval(interval).
00866      */
00867     MBED_DEPRECATED("Use ble.gap().setScanInterval(...)")
00868     ble_error_t setScanInterval(uint16_t interval) {
00869         return gap().setScanInterval(interval);
00870     }
00871 
00872     /**
00873      * Set up the scanWindow parameter for GAP scanning (observer mode).
00874      * @param[in] window
00875      *              Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s].
00876      *
00877      * The scanning window divided by the interval determines the duty cycle for
00878      * scanning. For example, if the interval is 100ms and the window is 10ms,
00879      * then the controller will scan for 10 percent of the time. It is possible
00880      * to have the interval and window set to the same value. In this case,
00881      * scanning is continuous, with a change of scanning frequency once every
00882      * interval.
00883      *
00884      * Once the scanning parameters have been configured, scanning can be
00885      * enabled by using startScan().
00886      *
00887      * @deprecated You should use the parallel API from Gap directly and refer to
00888      *             Gap::setScanWindow(). A former call to
00889      *             ble.setScanWindow(window) should be replaced with
00890      *             ble.gap().setScanWindow(window).
00891      */
00892     MBED_DEPRECATED("Use ble.gap().setScanWindow(...)")
00893     ble_error_t setScanWindow(uint16_t window) {
00894         return gap().setScanWindow(window);
00895     }
00896 
00897     /**
00898      * Set up parameters for GAP scanning (observer mode).
00899      * @param[in] timeout
00900      *              Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables timeout.
00901      *
00902      * The scanning window divided by the interval determines the duty cycle for
00903      * scanning. For example, if the interval is 100ms and the window is 10ms,
00904      * then the controller will scan for 10 percent of the time. It is possible
00905      * to have the interval and window set to the same value. In this case,
00906      * scanning is continuous, with a change of scanning frequency once every
00907      * interval.
00908      *
00909      * Once the scanning parameters have been configured, scanning can be
00910      * enabled by using startScan().
00911      *
00912      * @note The scan interval and window are recommendations to the BLE stack.
00913      *
00914      * @deprecated You should use the parallel API from Gap directly and refer to
00915      *             Gap::setScanTimeout(). A former call to
00916      *             ble.setScanTimeout(...) should be replaced with
00917      *             ble.gap().setScanTimeout(...).
00918      */
00919     MBED_DEPRECATED("Use ble.gap().setScanTimeout(...)")
00920     ble_error_t setScanTimeout(uint16_t timeout) {
00921         return gap().setScanTimeout(timeout);
00922     }
00923 
00924     /**
00925      * Set up parameters for GAP scanning (observer mode).
00926      * @param[in] activeScanning
00927      *              Set to True if active-scanning is required. This is used to fetch the
00928      *              scan response from a peer if possible.
00929      *
00930      * Once the scanning parameters have been configured, scanning can be
00931      * enabled by using startScan().
00932      *
00933      * @deprecated You should use the parallel API from Gap directly, refer to
00934      *             Gap::setActiveScan(). A former call to
00935      *             ble.setActiveScan(...) should be replaced with
00936      *             ble.gap().setActiveScanning(...).
00937      */
00938     MBED_DEPRECATED("Use ble.gap().setActiveScan(...)")
00939     void setActiveScan(bool activeScanning) {
00940         gap().setActiveScanning(activeScanning);
00941     }
00942 
00943     /**
00944      * Start scanning (Observer Procedure) based on the parameters currently in
00945      * effect.
00946      *
00947      * @param[in] callback
00948      *              The application-specific callback to be invoked upon
00949      *              receiving every advertisement report. This can be passed in
00950      *              as NULL, in which case scanning may not be enabled at all.
00951      *
00952      * @deprecated You should use the parallel API from Gap directly, refer to
00953      *             Gap::startScan(). A former call to
00954      *             ble.startScan(callback) should be replaced with
00955      *             ble.gap().startScan(callback).
00956      */
00957     MBED_DEPRECATED("Use ble.gap().startScan(callback)")
00958     ble_error_t startScan(void (*callback)(const Gap::AdvertisementCallbackParams_t *params)) {
00959         return gap().startScan(callback);
00960     }
00961 
00962     /**
00963      * Same as above, but this takes an (object, method) pair for a callback.
00964      *
00965      * @deprecated You should use the parallel API from Gap directly, refer to
00966      *             Gap::startScan(). A former call to
00967      *             ble.startScan(callback) should be replaced with
00968      *             ble.gap().startScan(object, callback).
00969      */
00970     template<typename T>
00971     MBED_DEPRECATED("Use ble.gap().startScan(object, callback)")
00972     ble_error_t startScan(T *object, void (T::*memberCallback)(const Gap::AdvertisementCallbackParams_t *params));
00973 
00974     /**
00975      * Stop scanning. The current scanning parameters remain in effect.
00976      *
00977      * @retval BLE_ERROR_NONE if successfully stopped scanning procedure.
00978      *
00979      * @deprecated You should use the parallel API from Gap directly and refer to
00980      *             Gap::stopScan(). A former call to
00981      *             ble.stopScan() should be replaced with
00982      *             ble.gap().stopScan().
00983      */
00984     MBED_DEPRECATED("Use ble.gap().stopScan()")
00985     ble_error_t stopScan(void) {
00986         return gap().stopScan();
00987     }
00988 
00989     /**
00990      * Create a connection (GAP Link Establishment).
00991      * @param peerAddr
00992      *          48-bit address, LSB format.
00993      * @param peerAddrType
00994      *          Address type of the peer.
00995      * @param connectionParams
00996      *         Connection parameters.
00997      * @param scanParams
00998      *          Parameters to use while scanning for the peer.
00999      * @return  BLE_ERROR_NONE if connection establishment procedure is started
01000      *     successfully. The onConnection callback (if set) is invoked upon
01001      *     a connection event.
01002      *
01003      * @deprecated You should use the parallel API from Gap directly and refer to
01004      *             Gap::connect(). A former call to
01005      *             ble.connect(...) should be replaced with
01006      *             ble.gap().connect(...).
01007      */
01008     MBED_DEPRECATED("Use ble.gap().connect(...)")
01009     ble_error_t connect(const BLEProtocol::AddressBytes_t  peerAddr,
01010                         BLEProtocol::AddressType_t         peerAddrType = BLEProtocol::AddressType::RANDOM_STATIC,
01011                         const Gap::ConnectionParams_t     *connectionParams = NULL,
01012                         const GapScanningParams           *scanParams = NULL) {
01013         return gap().connect(peerAddr, peerAddrType, connectionParams, scanParams);
01014     }
01015 
01016     /**
01017      * This call initiates the disconnection procedure, and its completion is
01018      * communicated to the application with an invocation of the
01019      * onDisconnection callback.
01020      *
01021      * @param[in] connectionHandle
01022      * @param[in] reason
01023      *              The reason for disconnection; sent back to the peer.
01024      */
01025     MBED_DEPRECATED("Use ble.gap().disconnect(...)")
01026     ble_error_t disconnect(Gap::Handle_t connectionHandle, Gap::DisconnectionReason_t reason) {
01027         return gap().disconnect(connectionHandle, reason);
01028     }
01029 
01030     /**
01031      * This call initiates the disconnection procedure, and its completion
01032      * is communicated to the application with an invocation of the
01033      * onDisconnection callback.
01034      *
01035      * @param  reason
01036      *           The reason for disconnection; sent back to the peer.
01037      *
01038      * @deprecated You should use the parallel API from Gap directly and refer to
01039      *             Gap::disconnect(). A former call to
01040      *             ble.disconnect(reason) should be replaced with
01041      *             ble.gap().disconnect(reason).
01042      *
01043      * @note This version of disconnect() doesn't take a connection handle. It
01044      * works reliably only for stacks that are limited to a single
01045      * connection.
01046      */
01047     MBED_DEPRECATED("Use ble.gap().disconnect(...)")
01048     ble_error_t disconnect(Gap::DisconnectionReason_t reason) {
01049         return gap().disconnect(reason);
01050     }
01051 
01052     /**
01053      * Returns the current Gap state of the device using a bitmask that
01054      * describes whether the device is advertising or connected.
01055      *
01056      * @deprecated You should use the parallel API from Gap directly and refer to
01057      *             Gap::getState(). A former call to
01058      *             ble.getGapState() should be replaced with
01059      *             ble.gap().getState().
01060      */
01061     MBED_DEPRECATED("Use ble.gap().getGapState(...)")
01062     Gap::GapState_t getGapState(void) const {
01063         return gap().getState();
01064     }
01065 
01066     /**
01067      * Get the GAP peripheral's preferred connection parameters. These are the
01068      * defaults that the peripheral would like to have in a connection. The
01069      * choice of the connection parameters is eventually up to the central.
01070      *
01071      * @param[out] params
01072      *               The structure where the parameters will be stored. The caller owns memory
01073      *               for this.
01074      *
01075      * @return BLE_ERROR_NONE if the parameters were successfully filled into
01076      * the given structure pointed to by params.
01077      *
01078      * @deprecated You should use the parallel API from Gap directly and refer to
01079      *             Gap::getPreferredConnectionParams(). A former call to
01080      *             ble.getPreferredConnectionParams() should be replaced with
01081      *             ble.gap().getPreferredConnectionParams().
01082      */
01083     MBED_DEPRECATED("Use ble.gap().getPreferredConnectionParams(...)")
01084     ble_error_t getPreferredConnectionParams(Gap::ConnectionParams_t *params) {
01085         return gap().getPreferredConnectionParams(params);
01086     }
01087 
01088     /**
01089      * Set the GAP peripheral's preferred connection parameters. These are the
01090      * defaults that the peripheral would like to have in a connection. The
01091      * choice of the connection parameters is eventually up to the central.
01092      *
01093      * @param[in] params
01094      *               The structure containing the desired parameters.
01095      *
01096      * @deprecated You should use the parallel API from Gap directly and refer to
01097      *             Gap::setPreferredConnectionParams(). A former call to
01098      *             ble.setPreferredConnectionParams() should be replaced with
01099      *             ble.gap().setPreferredConnectionParams().
01100      */
01101     MBED_DEPRECATED("Use ble.gap().setPreferredConnectionParams(...)")
01102     ble_error_t setPreferredConnectionParams(const Gap::ConnectionParams_t *params) {
01103         return gap().setPreferredConnectionParams(params);
01104     }
01105 
01106     /**
01107      * Update connection parameters while in the peripheral role.
01108      * @details In the peripheral role, this will send the corresponding L2CAP request to the connected peer and wait for
01109      *          the central to perform the procedure.
01110      * @param[in] handle
01111      *              Connection Handle
01112      * @param[in] params
01113      *              Pointer to desired connection parameters. If NULL is provided on a peripheral role,
01114      *              the parameters in the PPCP characteristic of the GAP service will be used instead.
01115      *
01116      * @deprecated You should use the parallel API from Gap directly and refer to
01117      *             Gap::updateConnectionParams(). A former call to
01118      *             ble.updateConnectionParams() should be replaced with
01119      *             ble.gap().updateConnectionParams().
01120      */
01121     MBED_DEPRECATED("Use ble.gap().updateConnectionParams(...)")
01122     ble_error_t updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) {
01123         return gap().updateConnectionParams(handle, params);
01124     }
01125 
01126     /**
01127      * Set the device name characteristic in the Gap service.
01128      * @param[in] deviceName
01129      *              The new value for the device-name. This is a UTF-8 encoded, <b>NULL-terminated</b> string.
01130      *
01131      * @deprecated You should use the parallel API from Gap directly and refer to
01132      *             Gap::setDeviceName(). A former call to
01133      *             ble.setDeviceName() should be replaced with
01134      *             ble.gap().setDeviceName().
01135      */
01136     MBED_DEPRECATED("Use ble.gap().setDeviceName(...)")
01137     ble_error_t setDeviceName(const uint8_t *deviceName) {
01138         return gap().setDeviceName(deviceName);
01139     }
01140 
01141     /**
01142      * Get the value of the device name characteristic in the Gap service.
01143      * @param[out]    deviceName
01144      *                  Pointer to an empty buffer where the UTF-8 *non NULL-
01145      *                  terminated* string will be placed. Set this
01146      *                  value to NULL to obtain the deviceName-length
01147      *                  from the 'length' parameter.
01148      *
01149      * @param[in,out] lengthP
01150      *                  (on input) Length of the buffer pointed to by deviceName;
01151      *                  (on output) the complete device name length (without the
01152      *                     null terminator).
01153      *
01154      * @note If the device name is longer than the size of the supplied buffer,
01155      *     the length will return the complete device name length and not the
01156      *     number of bytes actually returned in deviceName. The application may
01157      *     use this information to retry with a suitable buffer size.
01158      *
01159      * @deprecated You should use the parallel API from Gap directly and refer to
01160      *             Gap::getDeviceName(). A former call to
01161      *             ble.getDeviceName() should be replaced with
01162      *             ble.gap().getDeviceName().
01163      */
01164     MBED_DEPRECATED("Use ble.gap().getDeviceName(...)")
01165     ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP) {
01166         return gap().getDeviceName(deviceName, lengthP);
01167     }
01168 
01169     /**
01170      * Set the appearance characteristic in the Gap service.
01171      * @param[in] appearance
01172      *              The new value for the device-appearance.
01173      *
01174      * @deprecated You should use the parallel API from Gap directly and refer to
01175      *             Gap::setAppearance(). A former call to
01176      *             ble.setAppearance() should be replaced with
01177      *             ble.gap().setAppearance().
01178      */
01179     MBED_DEPRECATED("Use ble.gap().setAppearance(...)")
01180     ble_error_t setAppearance(GapAdvertisingData::Appearance appearance) {
01181         return gap().setAppearance(appearance);
01182     }
01183 
01184     /**
01185      * Get the appearance characteristic in the Gap service.
01186      * @param[out] appearanceP
01187      *               The new value for the device-appearance.
01188      *
01189      * @deprecated You should use the parallel API from Gap directly, refer to
01190      *             Gap::getAppearance(). A former call to
01191      *             ble.getAppearance() should be replaced with
01192      *             ble.gap().getAppearance().
01193      */
01194     MBED_DEPRECATED("Use ble.gap().getAppearance(...)")
01195     ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP) {
01196         return gap().getAppearance(appearanceP);
01197     }
01198 
01199     /**
01200      * Set the radio's transmit power.
01201      * @param[in] txPower Radio transmit power in dBm.
01202      *
01203      * @deprecated You should use the parallel API from Gap directly and refer to
01204      *             Gap::setTxPower(). A former call to
01205      *             ble.setTxPower() should be replaced with
01206      *             ble.gap().setTxPower().
01207      */
01208     MBED_DEPRECATED("Use ble.gap().setTxPower(...)")
01209     ble_error_t setTxPower(int8_t txPower) {
01210         return gap().setTxPower(txPower);
01211     }
01212 
01213     /**
01214      * Query the underlying stack for permitted arguments for setTxPower().
01215      *
01216      * @param[out] valueArrayPP
01217      *                 Out parameter to receive the immutable array of Tx values.
01218      * @param[out] countP
01219      *                 Out parameter to receive the array's size.
01220      *
01221      * @deprecated You should use the parallel API from Gap directly, refer to
01222      *             Gap::getPermittedTxPowerValues(). A former call to
01223      *             ble.getPermittedTxPowerValues() should be replaced with
01224      *             ble.gap().getPermittedTxPowerValues().
01225      */
01226     MBED_DEPRECATED("Use ble.gap().getPermittedTxPowerValues(...)")
01227     void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP) {
01228         gap().getPermittedTxPowerValues(valueArrayPP, countP);
01229     }
01230 
01231     /**
01232      * Add a service declaration to the local server ATT table. Also add the
01233      * characteristics contained within.
01234      *
01235      * @deprecated You should use the parallel API from GattServer directly, refer to
01236      *             GattServer::addService(). A former call
01237      *             to ble.addService() should be replaced with
01238      *             ble.gattServer().addService().
01239      */
01240     MBED_DEPRECATED("Use ble.gattServer().addService(...)")
01241     ble_error_t addService(GattService &service) {
01242         return gattServer().addService(service);
01243     }
01244 
01245     /**
01246      * Read the value of a characteristic from the local GattServer.
01247      * @param[in]     attributeHandle
01248      *                  Attribute handle for the value attribute of the characteristic.
01249      * @param[out]    buffer
01250      *                  A buffer to hold the value being read.
01251      * @param[in,out] lengthP
01252      *                  Length of the buffer being supplied. If the attribute
01253      *                  value is longer than the size of the supplied buffer,
01254      *                  this variable will return the total attribute value length
01255      *                  (excluding offset). The application may use this
01256      *                  information to allocate a suitable buffer size.
01257      *
01258      * @return BLE_ERROR_NONE if a value was read successfully into the buffer.
01259      *
01260      * @deprecated You should use the parallel API from GattServer directly,
01261      *             GattServer::read(GattAttribute::Handle_t,uint8_t,uint16_t). A former call
01262      *             to ble.readCharacteristicValue() should be replaced with
01263      *             ble.gattServer().read().
01264      */
01265     MBED_DEPRECATED("Use ble.gattServer().read(...)")
01266     ble_error_t readCharacteristicValue(GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) {
01267         return gattServer().read(attributeHandle, buffer, lengthP);
01268     }
01269 
01270     /**
01271      * Read the value of a characteristic from the local GattServer.
01272      * @param[in]     connectionHandle
01273      *                  Connection Handle.
01274      * @param[in]     attributeHandle
01275      *                  Attribute handle for the value attribute of the characteristic.
01276      * @param[out]    buffer
01277      *                  A buffer to hold the value being read.
01278      * @param[in,out] lengthP
01279      *                  Length of the buffer being supplied. If the attribute
01280      *                  value is longer than the size of the supplied buffer,
01281      *                  this variable will return the total attribute value length
01282      *                  (excluding offset). The application may use this
01283      *                  information to allocate a suitable buffer size.
01284      *
01285      * @return BLE_ERROR_NONE if a value was read successfully into the buffer.
01286      *
01287      * @note This API is a version of the above, with an additional connection handle
01288      *     parameter to allow fetches for connection-specific multivalued
01289      *     attributes (such as the CCCDs).
01290      *
01291      * @deprecated You should use the parallel API from GattServer directly, refer to
01292      *             GattServer::read(Gap::Handle_t,GattAttribute::Handle_t,uint8_t,uint16_t).
01293      *             A former call to ble.readCharacteristicValue() should be replaced with
01294      *             ble.gattServer().read().
01295      */
01296     MBED_DEPRECATED("Use ble.gattServer().read(...)")
01297     ble_error_t readCharacteristicValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) {
01298         return gattServer().read(connectionHandle, attributeHandle, buffer, lengthP);
01299     }
01300 
01301     /**
01302      * Update the value of a characteristic on the local GattServer.
01303      *
01304      * @param[in] attributeHandle
01305      *              Handle for the value attribute of the characteristic.
01306      * @param[in] value
01307      *              A pointer to a buffer holding the new value.
01308      * @param[in] size
01309      *              Size of the new value (in bytes).
01310      * @param[in] localOnly
01311      *              Should this update be kept on the local
01312      *              GattServer regardless of the state of the
01313      *              notify/indicate flag in the CCCD for this
01314      *              characteristic? If set to true, no notification
01315      *              or indication is generated.
01316      *
01317      * @return BLE_ERROR_NONE if we have successfully set the value of the attribute.
01318      *
01319      * @deprecated You should use the parallel API from GattServer directly and refer to
01320      *             GattServer::write(GattAttribute::Handle_t,const uint8_t,uint16_t,bool).
01321      *             A former call to ble.updateCharacteristicValue() should be replaced with
01322      *             ble.gattServer().write().
01323      */
01324     MBED_DEPRECATED("Use ble.gattServer().write(...)")
01325     ble_error_t updateCharacteristicValue(GattAttribute::Handle_t  attributeHandle,
01326                                           const uint8_t           *value,
01327                                           uint16_t                 size,
01328                                           bool                     localOnly = false) {
01329         return gattServer().write(attributeHandle, value, size, localOnly);
01330     }
01331 
01332     /**
01333      * Update the value of a characteristic on the local GattServer. A version
01334      * of the above, with a connection handle parameter to allow updates
01335      * for connection-specific multivalued attributes (such as the CCCDs).
01336      *
01337      * @param[in] connectionHandle
01338      *              Connection Handle.
01339      * @param[in] attributeHandle
01340      *              Handle for the value attribute of the Characteristic.
01341      * @param[in] value
01342      *              A pointer to a buffer holding the new value.
01343      * @param[in] size
01344      *              Size of the new value (in bytes).
01345      * @param[in] localOnly
01346      *              Should this update be kept on the local
01347      *              GattServer regardless of the state of the
01348      *              notify/indicate flag in the CCCD for this
01349      *              Characteristic? If set to true, no notification
01350      *              or indication is generated.
01351      *
01352      * @return BLE_ERROR_NONE if we have successfully set the value of the attribute.
01353      *
01354      * @deprecated You should use the parallel API from GattServer directly and refer to
01355      *             GattServer::write(Gap::Handle_t,GattAttribute::Handle_t,const uint8_t,uint16_t,bool).
01356      *             A former call to ble.updateCharacteristicValue() should be replaced with
01357      *             ble.gattServer().write().
01358      */
01359     MBED_DEPRECATED("Use ble.gattServer().write(...)")
01360     ble_error_t updateCharacteristicValue(Gap::Handle_t            connectionHandle,
01361                                           GattAttribute::Handle_t  attributeHandle,
01362                                           const uint8_t           *value,
01363                                           uint16_t                 size,
01364                                           bool                     localOnly = false) {
01365         return gattServer().write(connectionHandle, attributeHandle, value, size, localOnly);
01366     }
01367 
01368     /**
01369      * Enable the BLE stack's Security Manager. The Security Manager implements
01370      * the cryptographic algorithms and protocol exchanges that allow two
01371      * devices to securely exchange data and privately detect each other.
01372      * Calling this API is a prerequisite for encryption and pairing (bonding).
01373      *
01374      * @param[in]  enableBonding Allow for bonding.
01375      * @param[in]  requireMITM   Require protection against man-in-the-middle attacks.
01376      * @param[in]  iocaps        To specify the I/O capabilities of this peripheral,
01377      *                           such as availability of a display or keyboard, to
01378      *                           support out-of-band exchanges of security data.
01379      * @param[in]  passkey       To specify a static passkey.
01380      *
01381      * @return BLE_ERROR_NONE on success.
01382      *
01383      * @deprecated You should use the parallel API from SecurityManager directly, refer to
01384      *             SecurityManager.init(). A former
01385      *             call to ble.initializeSecurity(...) should be replaced with
01386      *             ble.securityManager().init(...).
01387      */
01388     MBED_DEPRECATED("Use ble.gattServer().write(...)")
01389     ble_error_t initializeSecurity(bool                                      enableBonding = true,
01390                                    bool                                      requireMITM   = true,
01391                                    SecurityManager::SecurityIOCapabilities_t iocaps        = SecurityManager::IO_CAPS_NONE,
01392                                    const SecurityManager::Passkey_t          passkey       = NULL) {
01393         return securityManager().init(enableBonding, requireMITM, iocaps, passkey);
01394     }
01395 
01396     /**
01397      * Get the security status of a connection.
01398      *
01399      * @param[in]  connectionHandle   Handle to identify the connection.
01400      * @param[out] securityStatusP    Security status.
01401      *
01402      * @return BLE_SUCCESS or appropriate error code indicating the reason of failure.
01403      *
01404      * @deprecated You should use the parallel API from SecurityManager directly, refer to
01405      *             SecurityManager::getLinkSecurity(). A former
01406      *             call to ble.getLinkSecurity(...) should be replaced with
01407      *             ble.securityManager().getLinkSecurity(...).
01408      */
01409     MBED_DEPRECATED("ble.securityManager().getLinkSecurity(...)")
01410     ble_error_t getLinkSecurity(Gap::Handle_t connectionHandle, SecurityManager::LinkSecurityStatus_t *securityStatusP) {
01411         return securityManager().getLinkSecurity (connectionHandle, securityStatusP);
01412     }
01413 
01414     /**
01415      * Delete all peer device context and all related bonding information from
01416      * the database within the security manager.
01417      *
01418      * @retval BLE_ERROR_NONE             On success; else returns an error code indicating the reason for the failure.
01419      * @retval BLE_ERROR_INVALID_STATE    If the API is called without module initialization or
01420      *                                    application registration.
01421      *
01422      * @deprecated You should use the parallel API from SecurityManager directly and refer to
01423      *             SecurityManager::purgeAllBondingState(). A former
01424      *             call to ble.purgeAllBondingState() should be replaced with
01425      *             ble.securityManager().purgeAllBondingState().
01426      */
01427     MBED_DEPRECATED("ble.securityManager().purgeAllBondingState(...)")
01428     ble_error_t purgeAllBondingState(void) {
01429         return securityManager().purgeAllBondingState();
01430     }
01431 
01432     /**
01433      * Set up a callback for timeout events. Refer to Gap::TimeoutSource_t for
01434      * possible event types.
01435      *
01436      * @deprecated You should use the parallel API from Gap directly and refer to
01437      *             Gap::onTimeout(). A former call
01438      *             to ble.onTimeout(callback) should be replaced with
01439      *             ble.gap().onTimeout(callback).
01440      */
01441     MBED_DEPRECATED("ble.gap().onTimeout(callback)")
01442     void onTimeout(Gap::TimeoutEventCallback_t timeoutCallback) {
01443         gap().onTimeout(timeoutCallback);
01444     }
01445 
01446     /**
01447      * Set up a callback for connection events. Refer to Gap::ConnectionEventCallback_t.
01448      *
01449      * @deprecated You should use the parallel API from Gap directly, refer to
01450      *             Gap::onConnection(). A former call
01451      *             to ble.onConnection(callback) should be replaced with
01452      *             ble.gap().onConnection(callback).
01453      */
01454     MBED_DEPRECATED("ble.gap().onConnection(callback)")
01455     void onConnection(Gap::ConnectionEventCallback_t connectionCallback) {
01456         gap().onConnection(connectionCallback);
01457     }
01458 
01459     /**
01460      * Append to a chain of callbacks to be invoked upon GAP disconnection.
01461      *
01462      * @deprecated You should use the parallel API from Gap directly and refer to
01463      *             Gap::onDisconnection(). A former call
01464      *             to ble.onDisconnection(callback) should be replaced with
01465      *             ble.gap().onDisconnection(callback).
01466      */
01467     MBED_DEPRECATED("ble.gap().onDisconnection(callback)")
01468     void onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback) {
01469         gap().onDisconnection(disconnectionCallback);
01470     }
01471 
01472     /**
01473      * The same as onDisconnection() but allows an object reference and member function
01474      * to be added to the chain of callbacks.
01475      *
01476      * @deprecated You should use the parallel API from Gap directly and refer to
01477      *             Gap::onDisconnection(). A former call
01478      *             to ble.onDisconnection(callback) should be replaced with
01479      *             ble.gap().onDisconnection(callback).
01480      */
01481     template<typename T>
01482     MBED_DEPRECATED("ble.gap().onDisconnection(callback)")
01483     void onDisconnection(T *tptr, void (T::*mptr)(const Gap::DisconnectionCallbackParams_t*)) {
01484         gap().onDisconnection(tptr, mptr);
01485     }
01486 
01487     /**
01488      * Radio Notification is a feature that enables ACTIVE and INACTIVE
01489      * (nACTIVE) signals from the stack. These notify the application when the
01490      * radio is in use. The signal is sent using software interrupt.
01491      *
01492      * The ACTIVE signal is sent before the radio event starts. The nACTIVE
01493      * signal is sent at the end of the radio event. These signals can be used
01494      * by the application programmer to synchronize application logic with radio
01495      * activity. For example, the ACTIVE signal can be used to shut off external
01496      * devices to manage peak current drawn during periods when the radio is on,
01497      * or to trigger sensor data collection for transmission in the radio event.
01498      *
01499      * @param callback
01500      *          The application handler to be invoked in response to a radio
01501      *          ACTIVE/INACTIVE event.
01502      *
01503      * @deprecated You should use the parallel API from Gap directly, refer to
01504      *             Gap::onRadioNotification(). A former call
01505      *             to ble.onRadioNotification(...) should be replaced with
01506      *             ble.gap().onRadioNotification(...).
01507      */
01508     MBED_DEPRECATED("ble.gap().onRadioNotification(...)")
01509     void onRadioNotification(void (*callback)(bool)) {
01510         gap().onRadioNotification(callback);
01511     }
01512 
01513     /**
01514      * Add a callback for the GATT event DATA_SENT (which is triggered when
01515      * updates are sent out by GATT in the form of notifications).
01516      *
01517      * @note It is possible to chain together multiple onDataSent callbacks
01518      * (potentially from different modules of an application) to receive updates
01519      * to characteristics.
01520      *
01521      * @note It is also possible to set up a callback into a member function of
01522      * some object.
01523      *
01524      * @deprecated You should use the parallel API from GattServer directly and refer to
01525      *             GattServer::onDataSent(). A former call
01526      *             to ble.onDataSent(...) should be replaced with
01527      *             ble.gattServer().onDataSent(...).
01528      */
01529     MBED_DEPRECATED("ble.gattServer().onDataSent(...)")
01530     void onDataSent(void (*callback)(unsigned count)) {
01531         gattServer().onDataSent(callback);
01532     }
01533 
01534     /**
01535      * The same as onDataSent() but allows an object reference and member function
01536      * to be added to the chain of callbacks.
01537      *
01538      * @deprecated You should use the parallel API from GattServer directly and refer to
01539      *             GattServer::onDataSent(). A former call
01540      *             to ble.onDataSent(...) should be replaced with
01541      *             ble.gattServer().onDataSent(...).
01542      */
01543     template <typename T>
01544     MBED_DEPRECATED("ble.gattServer().onDataSent(...)")
01545     void onDataSent(T * objPtr, void (T::*memberPtr)(unsigned count)) {
01546         gattServer().onDataSent(objPtr, memberPtr);
01547     }
01548 
01549     /**
01550      * Set up a callback for when an attribute has its value updated by or at the
01551      * connected peer. For a peripheral, this callback is triggered when the local
01552      * GATT server has an attribute updated by a write command from the peer.
01553      * For a Central, this callback is triggered when a response is received for
01554      * a write request.
01555      *
01556      * @note It is possible to chain together multiple onDataWritten callbacks
01557      * (potentially from different modules of an application) to receive updates
01558      * to characteristics. Many services, such as DFU and UART, add their own
01559      * onDataWritten callbacks behind the scenes to trap interesting events.
01560      *
01561      * @note It is also possible to set up a callback into a member function of
01562      * some object.
01563      *
01564      * @deprecated You should use the parallel API from GattServer directly and refer to
01565      *             GattServer::onDataWritten(). A former call
01566      *             to ble.onDataWritten(...) should be replaced with
01567      *             ble.gattServer().onDataWritten(...).
01568      */
01569     MBED_DEPRECATED("ble.gattServer().onDataWritten(...)")
01570     void onDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP)) {
01571         gattServer().onDataWritten(callback);
01572     }
01573 
01574     /**
01575      * The same as onDataWritten() but allows an object reference and member function
01576      * to be added to the chain of callbacks.
01577      *
01578      * @deprecated You should use the parallel API from GattServer directly, refer to
01579      *             GattServer::onDataWritten(). A former call
01580      *             to ble.onDataWritten(...) should be replaced with
01581      *             ble.gattServer().onDataWritten(...).
01582      */
01583     template <typename T>
01584     MBED_DEPRECATED("ble.gattServer().onDataWritten(...)")
01585     void onDataWritten(T * objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context)) {
01586         gattServer().onDataWritten(objPtr, memberPtr);
01587     }
01588 
01589     /**
01590      * Set up a callback to be invoked on the peripheral when an attribute is
01591      * being read by a remote client.
01592      *
01593      * @note This functionality may not be available on all underlying stacks.
01594      * You could use GattCharacteristic::setReadAuthorizationCallback() as an
01595      * alternative.
01596      *
01597      * @note It is possible to chain together multiple onDataRead callbacks
01598      * (potentially from different modules of an application) to receive updates
01599      * to characteristics. Services may add their own onDataRead callbacks
01600      * behind the scenes to trap interesting events.
01601      *
01602      * @note It is also possible to set up a callback into a member function of
01603      * some object.
01604      *
01605      * @return BLE_ERROR_NOT_IMPLEMENTED if this functionality isn't available;
01606      *         else BLE_ERROR_NONE.
01607      *
01608      * @deprecated You should use the parallel API from GattServer directly and refer to
01609      *             GattServer::onDataRead(). A former call
01610      *             to ble.onDataRead(...) should be replaced with
01611      *             ble.gattServer().onDataRead(...).
01612      */
01613     MBED_DEPRECATED("ble.gattServer().onDataRead(...)")
01614     ble_error_t onDataRead(void (*callback)(const GattReadCallbackParams *eventDataP)) {
01615         return gattServer().onDataRead(callback);
01616     }
01617 
01618     /**
01619      * The same as onDataRead() but allows an object reference and member function
01620      * to be added to the chain of callbacks.
01621      *
01622      * @deprecated You should use the parallel API from GattServer directly and refer to
01623      *             GattServer::onDataRead(). A former call
01624      *             to ble.onDataRead(...) should be replaced with
01625      *             ble.gattServer().onDataRead(...).
01626      */
01627     template <typename T>
01628     MBED_DEPRECATED("ble.gattServer().onDataRead(...)")
01629     ble_error_t onDataRead(T * objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context)) {
01630         return gattServer().onDataRead(objPtr, memberPtr);
01631     }
01632 
01633     /**
01634      * Set up a callback for when notifications or indications are enabled for a
01635      * characteristic on the local GattServer.
01636      *
01637      * @deprecated You should use the parallel API from GattServer directly and refer to
01638      *             GattServer::onUpdatesEnabled(). A former call
01639      *             to ble.onUpdatesEnabled(callback) should be replaced with
01640      *             ble.gattServer().onUpdatesEnabled(callback).
01641      */
01642     MBED_DEPRECATED("ble.gattServer().onUpdatesEnabled(...)")
01643     void onUpdatesEnabled(GattServer::EventCallback_t callback) {
01644         gattServer().onUpdatesEnabled(callback);
01645     }
01646 
01647     /**
01648      * Set up a callback for when notifications or indications are disabled for a
01649      * characteristic on the local GattServer.
01650      *
01651      * @deprecated You should use the parallel API from GattServer directly and refer to
01652      *             GattServer::onUpdatesDisabled(). A former call
01653      *             to ble.onUpdatesDisabled(callback) should be replaced with
01654      *             ble.gattServer().onUpdatesDisabled(callback).
01655      */
01656     MBED_DEPRECATED("ble.gattServer().onUpdatesDisabled(...)")
01657     void onUpdatesDisabled(GattServer::EventCallback_t callback) {
01658         gattServer().onUpdatesDisabled(callback);
01659     }
01660 
01661     /**
01662      * Set up a callback for when the GATT server receives a response for an
01663      * indication event sent previously.
01664      *
01665      * @deprecated You should use the parallel API from GattServer directly and refer to
01666      *             GattServer::onConfirmationReceived(). A former call
01667      *             to ble.onConfirmationReceived(callback) should be replaced with
01668      *             ble.gattServer().onConfirmationReceived(callback).
01669      */
01670     MBED_DEPRECATED("ble.gattServer().onConfirmationReceived(...)")
01671     void onConfirmationReceived(GattServer::EventCallback_t callback) {
01672         gattServer().onConfirmationReceived(callback);
01673     }
01674 
01675     /**
01676      * Set up a callback for when the security setup procedure (key generation
01677      * and exchange) for a link has started. This will be skipped for bonded
01678      * devices. The callback is passed in parameters received from the peer's
01679      * security request: bool allowBonding, bool requireMITM and
01680      * SecurityIOCapabilities_t.
01681      *
01682      * @deprecated You should use the parallel API from SecurityManager directly and refer to
01683      *             SecurityManager::onSecuritySetupInitiated(). A former
01684      *             call to ble.onSecuritySetupInitiated(callback) should be replaced with
01685      *             ble.securityManager().onSecuritySetupInitiated(callback).
01686      */
01687     MBED_DEPRECATED("ble.securityManager().onSecuritySetupInitiated(callback)")
01688     void onSecuritySetupInitiated(SecurityManager::SecuritySetupInitiatedCallback_t callback) {
01689         securityManager().onSecuritySetupInitiated (callback);
01690     }
01691 
01692     /**
01693      * Set up a callback for when the security setup procedure (key generation
01694      * and exchange) for a link has completed. This will be skipped for bonded
01695      * devices. The callback is passed in the success/failure status of the
01696      * security setup procedure.
01697      *
01698      * @deprecated You should use the parallel API from SecurityManager directly and refer to
01699      *             SecurityManager::onSecuritySetupCompleted(). A former
01700      *             call to ble.onSecuritySetupCompleted(callback) should be replaced with
01701      *             ble.securityManager().onSecuritySetupCompleted(callback).
01702      */
01703     MBED_DEPRECATED("ble.securityManager().onSecuritySetupCompleted(callback)")
01704     void onSecuritySetupCompleted(SecurityManager::SecuritySetupCompletedCallback_t callback) {
01705         securityManager().onSecuritySetupCompleted (callback);
01706     }
01707 
01708     /**
01709      * Set up a callback for when a link with the peer is secured. For bonded
01710      * devices, subsequent reconnections with a bonded peer will result only in
01711      * this callback when the link is secured, and setup procedures will not
01712      * occur unless the bonding information is either lost or deleted on either
01713      * or both sides. The callback is passed in a SecurityManager::SecurityMode_t according
01714      * to the level of security in effect for the secured link.
01715      *
01716      * @deprecated You should use the parallel API from SecurityManager directly and refer to
01717      *             SecurityManager::onLinkSecured(). A former
01718      *             call to ble.onLinkSecured(callback) should be replaced with
01719      *             ble.securityManager().onLinkSecured(callback).
01720      */
01721     MBED_DEPRECATED("ble.securityManager().onLinkSecured(callback)")
01722     void onLinkSecured(SecurityManager::LinkSecuredCallback_t callback) {
01723         securityManager().onLinkSecured (callback);
01724     }
01725 
01726     /**
01727      * Set up a callback for successful bonding, meaning that link-specific security
01728      * context is stored persistently for a peer device.
01729      *
01730      * @deprecated You should use the parallel API from SecurityManager directly and refer to
01731      *             SecurityManager::onSecurityContextStored(). A former
01732      *             call to ble.onSecurityContextStored(callback) should be replaced with
01733      *             ble.securityManager().onSecurityContextStored(callback).
01734      */
01735     MBED_DEPRECATED("ble.securityManager().onSecurityContextStored(callback)")
01736     void onSecurityContextStored(SecurityManager::HandleSpecificEvent_t callback) {
01737         securityManager().onSecurityContextStored (callback);
01738     }
01739 
01740     /**
01741      * Set up a callback for when the passkey needs to be displayed on a
01742      * peripheral with DISPLAY capability. This happens when security is
01743      * configured to prevent man-in-the-middle attacks, and the peers need to exchange
01744      * a passkey (or PIN) to authenticate the connection
01745      * attempt.
01746      *
01747      * @deprecated You should use the parallel API from SecurityManager directly and refer to
01748      *             SecurityManager::onPasskeyDisplay(). A former
01749      *             call to ble.onPasskeyDisplay(callback) should be replaced with
01750      *             ble.securityManager().onPasskeyDisplay(callback).
01751      */
01752     MBED_DEPRECATED("ble.securityManager().onPasskeyDisplay(callback)")
01753     void onPasskeyDisplay(SecurityManager::PasskeyDisplayCallback_t callback) {
01754         return securityManager().onPasskeyDisplay (callback);
01755     }
01756 
01757 private:
01758     friend class BLEInstanceBase;
01759 
01760     /**
01761      * This function allows the BLE stack to signal that there is work to do and
01762      * event processing should be done (BLE::processEvent()).
01763      *
01764      * @note This function should be called by the port of BLE_API. It is not
01765      * meant to be used by end users.
01766      */
01767     void signalEventsToProcess();
01768 
01769     /**
01770      * Implementation of init() [internal to BLE_API].
01771      *
01772      * The implementation is separated into a private method because it isn't
01773      * suitable to be included in the header.
01774      */
01775     ble_error_t initImplementation(
01776         FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback
01777     );
01778 
01779 private:
01780     // Prevent copy construction and copy assignment of BLE.
01781     BLE(const BLE&);
01782     BLE &operator=(const BLE &);
01783 
01784 private:
01785     InstanceID_t instanceID;
01786     BLEInstanceBase *transport; /* The device-specific backend */
01787     OnEventsToProcessCallback_t whenEventsToProcess;
01788     bool event_signaled;
01789 };
01790 
01791 /**
01792  * @deprecated This type alias is retained for the sake of compatibility with
01793  * older code. This will be dropped at some point.
01794  */
01795 typedef BLE BLEDevice ;
01796 
01797 /**
01798  * @namespace ble Entry namespace for all %BLE API definitions.
01799  */
01800 
01801 /**
01802  * @}
01803  */
01804 
01805 #endif /* ifndef MBED_BLE_H__ */