Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 00462 /** 00463 * Fetch the Bluetooth Low Energy MAC address and type. 00464 * 00465 * @return BLE_ERROR_NONE on success. 00466 * 00467 * @deprecated You should use the parallel API from Gap directly and refer to 00468 * Gap::getAddress(). A former call to ble.getAddress(...) should be 00469 * replaced with ble.gap().getAddress(...). 00470 */ 00471 MBED_DEPRECATED("Use ble.gap().getAddress(...)") 00472 ble_error_t getAddress( 00473 BLEProtocol::AddressType_t *typeP, BLEProtocol::AddressBytes_t address 00474 ) { 00475 return gap().getAddress(typeP, address); 00476 } 00477 00478 /** 00479 * Set the GAP advertising mode to use for this device. 00480 * 00481 * @deprecated You should use the parallel API from Gap directly and refer to 00482 * Gap::setAdvertisingType(). A former call to 00483 * ble.setAdvertisingType(...) should be replaced with 00484 * ble.gap().setAdvertisingType(...). 00485 */ 00486 MBED_DEPRECATED("Use ble.gap().setAdvertisingType(...)") 00487 void setAdvertisingType(GapAdvertisingParams::AdvertisingType advType) { 00488 gap().setAdvertisingType(advType); 00489 } 00490 00491 /** 00492 * @param[in] interval 00493 * Advertising interval in units of milliseconds. Advertising 00494 * is disabled if interval is 0. If interval is smaller than 00495 * the minimum supported value, then the minimum supported 00496 * value is used instead. This minimum value can be discovered 00497 * using getMinAdvertisingInterval(). 00498 * 00499 * This field must be set to 0 if connectionMode is equal 00500 * to ADV_CONNECTABLE_DIRECTED. 00501 * 00502 * @note Decreasing this value allows central devices to detect a 00503 * peripheral faster at the expense of more power being used by the radio 00504 * due to the higher data transmit rate. 00505 * 00506 * @deprecated You should use the parallel API from Gap directly and refer to 00507 * Gap::setAdvertisingInterval(). A former call to 00508 * ble.setAdvertisingInterval(...) should be replaced with 00509 * ble.gap().setAdvertisingInterval(...). 00510 * 00511 * @note WARNING: This API previously used 0.625ms as the unit for its 00512 * 'interval' argument. That required an explicit conversion from 00513 * milliseconds using Gap::MSEC_TO_GAP_DURATION_UNITS(). This conversion is 00514 * no longer required as the new units are milliseconds. Any application 00515 * code depending on the old semantics needs to be updated accordingly. 00516 */ 00517 MBED_DEPRECATED("Use ble.gap().setAdvertisingInterval(...)") 00518 void setAdvertisingInterval(uint16_t interval) { 00519 gap().setAdvertisingInterval(interval); 00520 } 00521 00522 /** 00523 * @return Minimum Advertising interval in milliseconds. 00524 * 00525 * @deprecated You should use the parallel API from Gap directly, refer to 00526 * Gap::getMinAdvertisingInterval(). A former call to 00527 * ble.getMinAdvertisingInterval(...) should be replaced with 00528 * ble.gap().getMinAdvertisingInterval(...). 00529 */ 00530 MBED_DEPRECATED("Use ble.gap().getMinAdvertisingInterval(...)") 00531 uint16_t getMinAdvertisingInterval(void) const { 00532 return gap().getMinAdvertisingInterval(); 00533 } 00534 00535 /** 00536 * @return Minimum Advertising interval in milliseconds for nonconnectible mode. 00537 * 00538 * @deprecated You should use the parallel API from Gap directly, refer to 00539 * Gap::MinNonConnectableAdvertisingInterval(). A former call to 00540 * ble.getMinNonConnectableAdvertisingInterval(...) should be replaced with 00541 * ble.gap().getMinNonConnectableAdvertisingInterval(...). 00542 */ 00543 MBED_DEPRECATED("Use ble.gap().getMinNonConnectableAdvertisingInterval(...)") 00544 uint16_t getMinNonConnectableAdvertisingInterval(void) const { 00545 return gap().getMinNonConnectableAdvertisingInterval(); 00546 } 00547 00548 /** 00549 * @return Maximum Advertising interval in milliseconds. 00550 * 00551 * @deprecated You should use the parallel API from Gap directly, refer to 00552 * Gap::getMaxAdvertisingInterval(). A former call to 00553 * ble.getMaxAdvertisingInterval(...) should be replaced with 00554 * ble.gap().getMaxAdvertisingInterval(...). 00555 */ 00556 MBED_DEPRECATED("Use ble.gap().getMaxAdvertisingInterval(...)") 00557 uint16_t getMaxAdvertisingInterval(void) const { 00558 return gap().getMaxAdvertisingInterval(); 00559 } 00560 00561 /** 00562 * @param[in] timeout 00563 * Advertising timeout (in seconds) between 0x1 and 0x3FFF (1 00564 * and 16383). Use 0 to disable the advertising timeout. 00565 * 00566 * @deprecated You should use the parallel API from Gap directly and refer to 00567 * Gap::setAdvertisingTimeout(). A former call to 00568 * ble.setAdvertisingTimeout(...) should be replaced with 00569 * ble.gap().setAdvertisingTimeout(...). 00570 */ 00571 MBED_DEPRECATED("Use ble.gap().setAdvertisingTimeout(...)") 00572 void setAdvertisingTimeout(uint16_t timeout) { 00573 gap().setAdvertisingTimeout(timeout); 00574 } 00575 00576 /** 00577 * Set up a particular, user-constructed set of advertisement parameters for 00578 * the underlying stack. It would be uncommon for this API to be used 00579 * directly; there are other APIs to tweak advertisement parameters 00580 * individually (see above). 00581 * 00582 * @deprecated You should use the parallel API from Gap directly and refer to 00583 * Gap::setAdvertisingParams(). A former call to 00584 * ble.setAdvertisingParams(...) should be replaced with 00585 * ble.gap().setAdvertisingParams(...). 00586 */ 00587 MBED_DEPRECATED("Use ble.gap().setAdvertisingParams(...)") 00588 void setAdvertisingParams(const GapAdvertisingParams &advParams) { 00589 gap().setAdvertisingParams(advParams); 00590 } 00591 00592 /** 00593 * @return Read back advertising parameters. Useful for storing and 00594 * restoring parameters rapidly. 00595 * 00596 * @deprecated You should use the parallel API from Gap directly and refer to 00597 * Gap::getAdvertisingParams(). A former call to 00598 * ble.getAdvertisingParams(...) should be replaced with 00599 * ble.gap().getAdvertisingParams(...). 00600 */ 00601 MBED_DEPRECATED("Use ble.gap().getAdvertisingParams(...)") 00602 const GapAdvertisingParams &getAdvertisingParams(void) const { 00603 return gap().getAdvertisingParams(); 00604 } 00605 00606 /** 00607 * Accumulate an AD structure in the advertising payload. Please note that 00608 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used 00609 * as an additional 31 bytes if the advertising payload is too 00610 * small. 00611 * 00612 * @param[in] flags 00613 * The flags to add. Please refer to 00614 * GapAdvertisingData::Flags for valid flags. Multiple 00615 * flags may be specified in combination. 00616 * 00617 * @deprecated You should use the parallel API from Gap directly, refer to 00618 * Gap::accumulateAdvertisingPayload(uint8_t). A former call to 00619 * ble.accumulateAdvertisingPayload(flags) should be replaced with 00620 * ble.gap().accumulateAdvertisingPayload(flags). 00621 */ 00622 MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayload(flags)") 00623 ble_error_t accumulateAdvertisingPayload(uint8_t flags) { 00624 return gap().accumulateAdvertisingPayload(flags); 00625 } 00626 00627 /** 00628 * Accumulate an AD structure in the advertising payload. Please note that 00629 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used 00630 * as an additional 31 bytes if the advertising payload is too 00631 * small. 00632 * 00633 * @param[in] app 00634 * The appearance of the peripheral. 00635 * 00636 * @deprecated You should use the parallel API from Gap directly and refer to 00637 * Gap::accumulateAdvertisingPayload(GapAdvertisingData::Appearance). 00638 * A former call to ble.accumulateAdvertisingPayload(appearance) 00639 * should be replaced with 00640 * ble.gap().accumulateAdvertisingPayload(appearance). 00641 */ 00642 MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayload(appearance)") 00643 ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::Appearance app) { 00644 return gap().accumulateAdvertisingPayload(app); 00645 } 00646 00647 /** 00648 * Accumulate an AD structure in the advertising payload. Please note that 00649 * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used 00650 * as an additional 31 bytes if the advertising payload is too 00651 * small. 00652 * 00653 * @param[in] power 00654 * The max transmit power to be used by the controller. This 00655 * is only a hint. 00656 * 00657 * @deprecated You should use the parallel API from Gap directly and refer to 00658 * Gap::accumulateAdvertisingPayloadTxPower(). A former call to 00659 * ble.accumulateAdvertisingPayloadTxPower(txPower) should be replaced with 00660 * ble.gap().accumulateAdvertisingPayloadTxPower(txPower). 00661 */ 00662 MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayloadTxPower(...)") 00663 ble_error_t accumulateAdvertisingPayloadTxPower(int8_t power) { 00664 return gap().accumulateAdvertisingPayloadTxPower(power); 00665 } 00666 00667 /** 00668 * Accumulate a variable length byte-stream as an AD structure in the 00669 * advertising payload. Please note that the payload is limited to 31 bytes. 00670 * The SCAN_RESPONSE message may be used as an additional 31 bytes if the 00671 * advertising payload is too small. 00672 * 00673 * @param type The type that describes the variable length data. 00674 * @param data Data bytes. 00675 * @param len Data length. 00676 * 00677 * @deprecated You should use the parallel API from Gap directly, refer to 00678 * Gap::accumulateAdvertisingPayload(GapAdvertisingData::DataType, const uint8_t, uint8_t). 00679 * A former call to ble.accumulateAdvertisingPayload(...) should 00680 * be replaced with ble.gap().accumulateAdvertisingPayload(...). 00681 */ 00682 MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayload(...)") 00683 ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) { 00684 return gap().accumulateAdvertisingPayload(type, data, len); 00685 } 00686 00687 /** 00688 * Set up a particular, user-constructed advertisement payload for the 00689 * underlying stack. It would be uncommon for this API to be used directly; 00690 * there are other APIs to build an advertisement payload (see above). 00691 * 00692 * @deprecated You should use the parallel API from Gap directly, refer to 00693 * Gap::setAdvertisingData(). A former call to 00694 * ble.setAdvertisingData(...) should be replaced with 00695 * ble.gap().setAdvertisingPayload(...). 00696 */ 00697 MBED_DEPRECATED("Use ble.gap().setAdvertisingData(...)") 00698 ble_error_t setAdvertisingData(const GapAdvertisingData &advData) { 00699 return gap().setAdvertisingPayload(advData); 00700 } 00701 00702 /** 00703 * @return Read back advertising data. Useful for storing and 00704 * restoring payload. 00705 * 00706 * @deprecated You should use the parallel API from Gap directly, refer to 00707 * Gap::getAdvertisingData(). A former call to 00708 * ble.getAdvertisingData(...) should be replaced with 00709 * ble.gap().getAdvertisingPayload()(...). 00710 */ 00711 MBED_DEPRECATED("Use ble.gap().getAdvertisingData(...)") 00712 const GapAdvertisingData &getAdvertisingData(void) const { 00713 return gap().getAdvertisingPayload(); 00714 } 00715 00716 /** 00717 * Reset any advertising payload prepared from prior calls to 00718 * accumulateAdvertisingPayload(). This automatically propagates the re- 00719 * initialized advertising payload to the underlying stack. 00720 * 00721 * @deprecated You should use the parallel API from Gap directly and refer to 00722 * Gap::clearAdvertisingPayload(). A former call to 00723 * ble.clearAdvertisingPayload(...) should be replaced with 00724 * ble.gap().clearAdvertisingPayload(...). 00725 */ 00726 MBED_DEPRECATED("Use ble.gap().clearAdvertisingPayload(...)") 00727 void clearAdvertisingPayload(void) { 00728 gap().clearAdvertisingPayload(); 00729 } 00730 00731 /** 00732 * Dynamically reset the accumulated advertising 00733 * payload and scanResponse. The application must clear and re- 00734 * accumulate a new advertising payload (and scanResponse) before using this 00735 * API. 00736 * 00737 * @return BLE_ERROR_NONE when the advertising payload is set successfully. 00738 * 00739 * @deprecated You should use the parallel API from Gap directly, refer to 00740 * Gap::setAdvertisingPayload(). 00741 * 00742 * @note The new APIs in Gap update the underlying advertisement payload 00743 * implicitly. 00744 */ 00745 MBED_DEPRECATED("Use ble.gap().setAdvertisingPayload(...)") 00746 ble_error_t setAdvertisingPayload(void) { 00747 return BLE_ERROR_NONE; 00748 } 00749 00750 /** 00751 * Accumulate a variable length byte-stream as an AD structure in the 00752 * scanResponse payload. 00753 * 00754 * @param[in] type The type that describes the variable length data. 00755 * @param[in] data Data bytes. 00756 * @param[in] len Data length. 00757 * 00758 * @deprecated You should use the parallel API from Gap directly and refer to 00759 * Gap::accumulateScanResponse(). A former call to 00760 * ble.accumulateScanResponse(...) should be replaced with 00761 * ble.gap().accumulateScanResponse(...). 00762 */ 00763 MBED_DEPRECATED("Use ble.gap().accumulateScanResponse(...)") 00764 ble_error_t accumulateScanResponse(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) { 00765 return gap().accumulateScanResponse(type, data, len); 00766 } 00767 00768 /** 00769 * Reset any scan response prepared from prior calls to 00770 * accumulateScanResponse(). 00771 * 00772 * @deprecated You should use the parallel API from Gap directly and refer to 00773 * Gap::clearScanResponse(). A former call to 00774 * ble.clearScanResponse(...) should be replaced with 00775 * ble.gap().clearScanResponse(...). 00776 */ 00777 MBED_DEPRECATED("Use ble.gap().clearScanResponse(...)") 00778 void clearScanResponse(void) { 00779 gap().clearScanResponse(); 00780 } 00781 00782 /** 00783 * Start advertising. 00784 * 00785 * @deprecated You should use the parallel API from Gap directly and refer to 00786 * Gap::startAdvertising(). A former call to 00787 * ble.startAdvertising(...) should be replaced with 00788 * ble.gap().startAdvertising(...). 00789 */ 00790 MBED_DEPRECATED("Use ble.gap().startAdvertising(...)") 00791 ble_error_t startAdvertising(void) { 00792 return gap().startAdvertising(); 00793 } 00794 00795 /** 00796 * Stop advertising. 00797 * 00798 * @deprecated You should use the parallel API from Gap directly and refer to 00799 * Gap::stopAdvertising(). A former call to 00800 * ble.stopAdvertising(...) should be replaced with 00801 * ble.gap().stopAdvertising(...). 00802 */ 00803 MBED_DEPRECATED("Use ble.gap().stopAdvertising(...)") 00804 ble_error_t stopAdvertising(void) { 00805 return gap().stopAdvertising(); 00806 } 00807 00808 /** 00809 * Set up parameters for GAP scanning (observer mode). 00810 * @param[in] interval 00811 * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s]. 00812 * @param[in] window 00813 * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s]. 00814 * @param[in] timeout 00815 * Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables timeout. 00816 * @param[in] activeScanning 00817 * Set to True if active-scanning is required. This is used to fetch the 00818 * scan response from a peer if possible. 00819 * 00820 * The scanning window divided by the interval determines the duty cycle for 00821 * scanning. For example, if the interval is 100ms and the window is 10ms, 00822 * then the controller will scan for 10 percent of the time. It is possible 00823 * to have the interval and window set to the same value. In this case, 00824 * scanning is continuous, with a change of scanning frequency once every 00825 * interval. 00826 * 00827 * Once the scanning parameters have been configured, scanning can be 00828 * enabled by using startScan(). 00829 * 00830 * @note The scan interval and window are recommendations to the BLE stack. 00831 * 00832 * @deprecated You should use the parallel API from Gap directly and refer to 00833 * Gap::setScanParams(). A former call to 00834 * ble.setScanParams(...) should be replaced with 00835 * ble.gap().setScanParams(...). 00836 */ 00837 MBED_DEPRECATED("Use ble.gap().setScanParams(...)") 00838 ble_error_t setScanParams(uint16_t interval = GapScanningParams::SCAN_INTERVAL_MAX, 00839 uint16_t window = GapScanningParams::SCAN_WINDOW_MAX, 00840 uint16_t timeout = 0, 00841 bool activeScanning = false) { 00842 return gap().setScanParams(interval, window, timeout, activeScanning); 00843 } 00844 00845 /** 00846 * Set up the scanInterval parameter for GAP scanning (observer mode). 00847 * @param[in] interval 00848 * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s]. 00849 * 00850 * The scanning window divided by the interval determines the duty cycle for 00851 * scanning. For example, if the interval is 100ms and the window is 10ms, 00852 * then the controller will scan for 10 percent of the time. It is possible 00853 * to have the interval and window set to the same value. In this case, 00854 * scanning is continuous, with a change of scanning frequency once every 00855 * interval. 00856 * 00857 * Once the scanning parameters have been configured, scanning can be 00858 * enabled by using startScan(). 00859 * 00860 * @deprecated You should use the parallel API from Gap directly and refer to 00861 * Gap::setScanInterval(). A former call to 00862 * ble.setScanInterval(interval) should be replaced with 00863 * ble.gap().setScanInterval(interval). 00864 */ 00865 MBED_DEPRECATED("Use ble.gap().setScanInterval(...)") 00866 ble_error_t setScanInterval(uint16_t interval) { 00867 return gap().setScanInterval(interval); 00868 } 00869 00870 /** 00871 * Set up the scanWindow parameter for GAP scanning (observer mode). 00872 * @param[in] window 00873 * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s]. 00874 * 00875 * The scanning window divided by the interval determines the duty cycle for 00876 * scanning. For example, if the interval is 100ms and the window is 10ms, 00877 * then the controller will scan for 10 percent of the time. It is possible 00878 * to have the interval and window set to the same value. In this case, 00879 * scanning is continuous, with a change of scanning frequency once every 00880 * interval. 00881 * 00882 * Once the scanning parameters have been configured, scanning can be 00883 * enabled by using startScan(). 00884 * 00885 * @deprecated You should use the parallel API from Gap directly and refer to 00886 * Gap::setScanWindow(). A former call to 00887 * ble.setScanWindow(window) should be replaced with 00888 * ble.gap().setScanWindow(window). 00889 */ 00890 MBED_DEPRECATED("Use ble.gap().setScanWindow(...)") 00891 ble_error_t setScanWindow(uint16_t window) { 00892 return gap().setScanWindow(window); 00893 } 00894 00895 /** 00896 * Set up parameters for GAP scanning (observer mode). 00897 * @param[in] timeout 00898 * Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables timeout. 00899 * 00900 * The scanning window divided by the interval determines the duty cycle for 00901 * scanning. For example, if the interval is 100ms and the window is 10ms, 00902 * then the controller will scan for 10 percent of the time. It is possible 00903 * to have the interval and window set to the same value. In this case, 00904 * scanning is continuous, with a change of scanning frequency once every 00905 * interval. 00906 * 00907 * Once the scanning parameters have been configured, scanning can be 00908 * enabled by using startScan(). 00909 * 00910 * @note The scan interval and window are recommendations to the BLE stack. 00911 * 00912 * @deprecated You should use the parallel API from Gap directly and refer to 00913 * Gap::setScanTimeout(). A former call to 00914 * ble.setScanTimeout(...) should be replaced with 00915 * ble.gap().setScanTimeout(...). 00916 */ 00917 MBED_DEPRECATED("Use ble.gap().setScanTimeout(...)") 00918 ble_error_t setScanTimeout(uint16_t timeout) { 00919 return gap().setScanTimeout(timeout); 00920 } 00921 00922 /** 00923 * Set up parameters for GAP scanning (observer mode). 00924 * @param[in] activeScanning 00925 * Set to True if active-scanning is required. This is used to fetch the 00926 * scan response from a peer if possible. 00927 * 00928 * Once the scanning parameters have been configured, scanning can be 00929 * enabled by using startScan(). 00930 * 00931 * @deprecated You should use the parallel API from Gap directly, refer to 00932 * Gap::setActiveScan(). A former call to 00933 * ble.setActiveScan(...) should be replaced with 00934 * ble.gap().setActiveScanning(...). 00935 */ 00936 MBED_DEPRECATED("Use ble.gap().setActiveScan(...)") 00937 void setActiveScan(bool activeScanning) { 00938 gap().setActiveScanning(activeScanning); 00939 } 00940 00941 /** 00942 * Start scanning (Observer Procedure) based on the parameters currently in 00943 * effect. 00944 * 00945 * @param[in] callback 00946 * The application-specific callback to be invoked upon 00947 * receiving every advertisement report. This can be passed in 00948 * as NULL, in which case scanning may not be enabled at all. 00949 * 00950 * @deprecated You should use the parallel API from Gap directly, refer to 00951 * Gap::startScan(). A former call to 00952 * ble.startScan(callback) should be replaced with 00953 * ble.gap().startScan(callback). 00954 */ 00955 MBED_DEPRECATED("Use ble.gap().startScan(callback)") 00956 ble_error_t startScan(void (*callback)(const Gap::AdvertisementCallbackParams_t *params)) { 00957 return gap().startScan(callback); 00958 } 00959 00960 /** 00961 * Same as above, but this takes an (object, method) pair for a callback. 00962 * 00963 * @deprecated You should use the parallel API from Gap directly, refer to 00964 * Gap::startScan(). A former call to 00965 * ble.startScan(callback) should be replaced with 00966 * ble.gap().startScan(object, callback). 00967 */ 00968 template<typename T> 00969 MBED_DEPRECATED("Use ble.gap().startScan(object, callback)") 00970 ble_error_t startScan(T *object, void (T::*memberCallback)(const Gap::AdvertisementCallbackParams_t *params)); 00971 00972 /** 00973 * Stop scanning. The current scanning parameters remain in effect. 00974 * 00975 * @retval BLE_ERROR_NONE if successfully stopped scanning procedure. 00976 * 00977 * @deprecated You should use the parallel API from Gap directly and refer to 00978 * Gap::stopScan(). A former call to 00979 * ble.stopScan() should be replaced with 00980 * ble.gap().stopScan(). 00981 */ 00982 MBED_DEPRECATED("Use ble.gap().stopScan()") 00983 ble_error_t stopScan(void) { 00984 return gap().stopScan(); 00985 } 00986 00987 /** 00988 * Create a connection (GAP Link Establishment). 00989 * @param peerAddr 00990 * 48-bit address, LSB format. 00991 * @param peerAddrType 00992 * Address type of the peer. 00993 * @param connectionParams 00994 * Connection parameters. 00995 * @param scanParams 00996 * Parameters to use while scanning for the peer. 00997 * @return BLE_ERROR_NONE if connection establishment procedure is started 00998 * successfully. The onConnection callback (if set) is invoked upon 00999 * a connection event. 01000 * 01001 * @deprecated You should use the parallel API from Gap directly and refer to 01002 * Gap::connect(). A former call to 01003 * ble.connect(...) should be replaced with 01004 * ble.gap().connect(...). 01005 */ 01006 MBED_DEPRECATED("Use ble.gap().connect(...)") 01007 ble_error_t connect(const BLEProtocol::AddressBytes_t peerAddr, 01008 BLEProtocol::AddressType_t peerAddrType = BLEProtocol::AddressType::RANDOM_STATIC, 01009 const Gap::ConnectionParams_t *connectionParams = NULL, 01010 const GapScanningParams *scanParams = NULL); 01011 01012 /** 01013 * This call initiates the disconnection procedure, and its completion is 01014 * communicated to the application with an invocation of the 01015 * onDisconnection callback. 01016 * 01017 * @param[in] connectionHandle 01018 * @param[in] reason 01019 * The reason for disconnection; sent back to the peer. 01020 */ 01021 MBED_DEPRECATED("Use ble.gap().disconnect(...)") 01022 ble_error_t disconnect(Gap::Handle_t connectionHandle, Gap::DisconnectionReason_t reason) { 01023 return gap().disconnect(connectionHandle, reason); 01024 } 01025 01026 /** 01027 * This call initiates the disconnection procedure, and its completion 01028 * is communicated to the application with an invocation of the 01029 * onDisconnection callback. 01030 * 01031 * @param reason 01032 * The reason for disconnection; sent back to the peer. 01033 * 01034 * @deprecated You should use the parallel API from Gap directly and refer to 01035 * Gap::disconnect(). A former call to 01036 * ble.disconnect(reason) should be replaced with 01037 * ble.gap().disconnect(reason). 01038 * 01039 * @note This version of disconnect() doesn't take a connection handle. It 01040 * works reliably only for stacks that are limited to a single 01041 * connection. 01042 */ 01043 MBED_DEPRECATED("Use ble.gap().disconnect(...)") 01044 ble_error_t disconnect(Gap::DisconnectionReason_t reason); 01045 01046 /** 01047 * Returns the current Gap state of the device using a bitmask that 01048 * describes whether the device is advertising or connected. 01049 * 01050 * @deprecated You should use the parallel API from Gap directly and refer to 01051 * Gap::getState(). A former call to 01052 * ble.getGapState() should be replaced with 01053 * ble.gap().getState(). 01054 */ 01055 MBED_DEPRECATED("Use ble.gap().getGapState(...)") 01056 Gap::GapState_t getGapState(void) const { 01057 return gap().getState(); 01058 } 01059 01060 /** 01061 * Get the GAP peripheral's preferred connection parameters. These are the 01062 * defaults that the peripheral would like to have in a connection. The 01063 * choice of the connection parameters is eventually up to the central. 01064 * 01065 * @param[out] params 01066 * The structure where the parameters will be stored. The caller owns memory 01067 * for this. 01068 * 01069 * @return BLE_ERROR_NONE if the parameters were successfully filled into 01070 * the given structure pointed to by params. 01071 * 01072 * @deprecated You should use the parallel API from Gap directly and refer to 01073 * Gap::getPreferredConnectionParams(). A former call to 01074 * ble.getPreferredConnectionParams() should be replaced with 01075 * ble.gap().getPreferredConnectionParams(). 01076 */ 01077 MBED_DEPRECATED("Use ble.gap().getPreferredConnectionParams(...)") 01078 ble_error_t getPreferredConnectionParams(Gap::ConnectionParams_t *params) { 01079 return gap().getPreferredConnectionParams(params); 01080 } 01081 01082 /** 01083 * Set the GAP peripheral's preferred connection parameters. These are the 01084 * defaults that the peripheral would like to have in a connection. The 01085 * choice of the connection parameters is eventually up to the central. 01086 * 01087 * @param[in] params 01088 * The structure containing the desired parameters. 01089 * 01090 * @deprecated You should use the parallel API from Gap directly and refer to 01091 * Gap::setPreferredConnectionParams(). A former call to 01092 * ble.setPreferredConnectionParams() should be replaced with 01093 * ble.gap().setPreferredConnectionParams(). 01094 */ 01095 MBED_DEPRECATED("Use ble.gap().setPreferredConnectionParams(...)") 01096 ble_error_t setPreferredConnectionParams(const Gap::ConnectionParams_t *params) { 01097 return gap().setPreferredConnectionParams(params); 01098 } 01099 01100 /** 01101 * Update connection parameters while in the peripheral role. 01102 * @details In the peripheral role, this will send the corresponding L2CAP request to the connected peer and wait for 01103 * the central to perform the procedure. 01104 * @param[in] handle 01105 * Connection Handle 01106 * @param[in] params 01107 * Pointer to desired connection parameters. If NULL is provided on a peripheral role, 01108 * the parameters in the PPCP characteristic of the GAP service will be used instead. 01109 * 01110 * @deprecated You should use the parallel API from Gap directly and refer to 01111 * Gap::updateConnectionParams(). A former call to 01112 * ble.updateConnectionParams() should be replaced with 01113 * ble.gap().updateConnectionParams(). 01114 */ 01115 MBED_DEPRECATED("Use ble.gap().updateConnectionParams(...)") 01116 ble_error_t updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) { 01117 return gap().updateConnectionParams(handle, params); 01118 } 01119 01120 /** 01121 * Set the device name characteristic in the Gap service. 01122 * @param[in] deviceName 01123 * The new value for the device-name. This is a UTF-8 encoded, <b>NULL-terminated</b> string. 01124 * 01125 * @deprecated You should use the parallel API from Gap directly and refer to 01126 * Gap::setDeviceName(). A former call to 01127 * ble.setDeviceName() should be replaced with 01128 * ble.gap().setDeviceName(). 01129 */ 01130 MBED_DEPRECATED("Use ble.gap().setDeviceName(...)") 01131 ble_error_t setDeviceName(const uint8_t *deviceName) { 01132 return gap().setDeviceName(deviceName); 01133 } 01134 01135 /** 01136 * Get the value of the device name characteristic in the Gap service. 01137 * @param[out] deviceName 01138 * Pointer to an empty buffer where the UTF-8 *non NULL- 01139 * terminated* string will be placed. Set this 01140 * value to NULL to obtain the deviceName-length 01141 * from the 'length' parameter. 01142 * 01143 * @param[in,out] lengthP 01144 * (on input) Length of the buffer pointed to by deviceName; 01145 * (on output) the complete device name length (without the 01146 * null terminator). 01147 * 01148 * @note If the device name is longer than the size of the supplied buffer, 01149 * the length will return the complete device name length and not the 01150 * number of bytes actually returned in deviceName. The application may 01151 * use this information to retry with a suitable buffer size. 01152 * 01153 * @deprecated You should use the parallel API from Gap directly and refer to 01154 * Gap::getDeviceName(). A former call to 01155 * ble.getDeviceName() should be replaced with 01156 * ble.gap().getDeviceName(). 01157 */ 01158 MBED_DEPRECATED("Use ble.gap().getDeviceName(...)") 01159 ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP) { 01160 return gap().getDeviceName(deviceName, lengthP); 01161 } 01162 01163 /** 01164 * Set the appearance characteristic in the Gap service. 01165 * @param[in] appearance 01166 * The new value for the device-appearance. 01167 * 01168 * @deprecated You should use the parallel API from Gap directly and refer to 01169 * Gap::setAppearance(). A former call to 01170 * ble.setAppearance() should be replaced with 01171 * ble.gap().setAppearance(). 01172 */ 01173 MBED_DEPRECATED("Use ble.gap().setAppearance(...)") 01174 ble_error_t setAppearance(GapAdvertisingData::Appearance appearance) { 01175 return gap().setAppearance(appearance); 01176 } 01177 01178 /** 01179 * Get the appearance characteristic in the Gap service. 01180 * @param[out] appearanceP 01181 * The new value for the device-appearance. 01182 * 01183 * @deprecated You should use the parallel API from Gap directly, refer to 01184 * Gap::getAppearance(). A former call to 01185 * ble.getAppearance() should be replaced with 01186 * ble.gap().getAppearance(). 01187 */ 01188 MBED_DEPRECATED("Use ble.gap().getAppearance(...)") 01189 ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP) { 01190 return gap().getAppearance(appearanceP); 01191 } 01192 01193 /** 01194 * Set the radio's transmit power. 01195 * @param[in] txPower Radio transmit power in dBm. 01196 * 01197 * @deprecated You should use the parallel API from Gap directly and refer to 01198 * Gap::setTxPower(). A former call to 01199 * ble.setTxPower() should be replaced with 01200 * ble.gap().setTxPower(). 01201 */ 01202 MBED_DEPRECATED("Use ble.gap().setTxPower(...)") 01203 ble_error_t setTxPower(int8_t txPower) { 01204 return gap().setTxPower(txPower); 01205 } 01206 01207 /** 01208 * Query the underlying stack for permitted arguments for setTxPower(). 01209 * 01210 * @param[out] valueArrayPP 01211 * Out parameter to receive the immutable array of Tx values. 01212 * @param[out] countP 01213 * Out parameter to receive the array's size. 01214 * 01215 * @deprecated You should use the parallel API from Gap directly, refer to 01216 * Gap::getPermittedTxPowerValues(). A former call to 01217 * ble.getPermittedTxPowerValues() should be replaced with 01218 * ble.gap().getPermittedTxPowerValues(). 01219 */ 01220 MBED_DEPRECATED("Use ble.gap().getPermittedTxPowerValues(...)") 01221 void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP) { 01222 gap().getPermittedTxPowerValues(valueArrayPP, countP); 01223 } 01224 01225 /** 01226 * Add a service declaration to the local server ATT table. Also add the 01227 * characteristics contained within. 01228 * 01229 * @deprecated You should use the parallel API from GattServer directly, refer to 01230 * GattServer::addService(). A former call 01231 * to ble.addService() should be replaced with 01232 * ble.gattServer().addService(). 01233 */ 01234 MBED_DEPRECATED("Use ble.gattServer().addService(...)") 01235 ble_error_t addService(GattService &service) { 01236 return gattServer().addService(service); 01237 } 01238 01239 /** 01240 * Read the value of a characteristic from the local GattServer. 01241 * @param[in] attributeHandle 01242 * Attribute handle for the value attribute of the characteristic. 01243 * @param[out] buffer 01244 * A buffer to hold the value being read. 01245 * @param[in,out] lengthP 01246 * Length of the buffer being supplied. If the attribute 01247 * value is longer than the size of the supplied buffer, 01248 * this variable will return the total attribute value length 01249 * (excluding offset). The application may use this 01250 * information to allocate a suitable buffer size. 01251 * 01252 * @return BLE_ERROR_NONE if a value was read successfully into the buffer. 01253 * 01254 * @deprecated You should use the parallel API from GattServer directly, 01255 * GattServer::read(GattAttribute::Handle_t,uint8_t,uint16_t). A former call 01256 * to ble.readCharacteristicValue() should be replaced with 01257 * ble.gattServer().read(). 01258 */ 01259 MBED_DEPRECATED("Use ble.gattServer().read(...)") 01260 ble_error_t readCharacteristicValue(GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) { 01261 return gattServer().read(attributeHandle, buffer, lengthP); 01262 } 01263 01264 /** 01265 * Read the value of a characteristic from the local GattServer. 01266 * @param[in] connectionHandle 01267 * Connection Handle. 01268 * @param[in] attributeHandle 01269 * Attribute handle for the value attribute of the characteristic. 01270 * @param[out] buffer 01271 * A buffer to hold the value being read. 01272 * @param[in,out] lengthP 01273 * Length of the buffer being supplied. If the attribute 01274 * value is longer than the size of the supplied buffer, 01275 * this variable will return the total attribute value length 01276 * (excluding offset). The application may use this 01277 * information to allocate a suitable buffer size. 01278 * 01279 * @return BLE_ERROR_NONE if a value was read successfully into the buffer. 01280 * 01281 * @note This API is a version of the above, with an additional connection handle 01282 * parameter to allow fetches for connection-specific multivalued 01283 * attributes (such as the CCCDs). 01284 * 01285 * @deprecated You should use the parallel API from GattServer directly, refer to 01286 * GattServer::read(Gap::Handle_t,GattAttribute::Handle_t,uint8_t,uint16_t). 01287 * A former call to ble.readCharacteristicValue() should be replaced with 01288 * ble.gattServer().read(). 01289 */ 01290 MBED_DEPRECATED("Use ble.gattServer().read(...)") 01291 ble_error_t readCharacteristicValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) { 01292 return gattServer().read(connectionHandle, attributeHandle, buffer, lengthP); 01293 } 01294 01295 /** 01296 * Update the value of a characteristic on the local GattServer. 01297 * 01298 * @param[in] attributeHandle 01299 * Handle for the value attribute of the characteristic. 01300 * @param[in] value 01301 * A pointer to a buffer holding the new value. 01302 * @param[in] size 01303 * Size of the new value (in bytes). 01304 * @param[in] localOnly 01305 * Should this update be kept on the local 01306 * GattServer regardless of the state of the 01307 * notify/indicate flag in the CCCD for this 01308 * characteristic? If set to true, no notification 01309 * or indication is generated. 01310 * 01311 * @return BLE_ERROR_NONE if we have successfully set the value of the attribute. 01312 * 01313 * @deprecated You should use the parallel API from GattServer directly and refer to 01314 * GattServer::write(GattAttribute::Handle_t,const uint8_t,uint16_t,bool). 01315 * A former call to ble.updateCharacteristicValue() should be replaced with 01316 * ble.gattServer().write(). 01317 */ 01318 MBED_DEPRECATED("Use ble.gattServer().write(...)") 01319 ble_error_t updateCharacteristicValue(GattAttribute::Handle_t attributeHandle, 01320 const uint8_t *value, 01321 uint16_t size, 01322 bool localOnly = false) { 01323 return gattServer().write(attributeHandle, value, size, localOnly); 01324 } 01325 01326 /** 01327 * Update the value of a characteristic on the local GattServer. A version 01328 * of the above, with a connection handle parameter to allow updates 01329 * for connection-specific multivalued attributes (such as the CCCDs). 01330 * 01331 * @param[in] connectionHandle 01332 * Connection Handle. 01333 * @param[in] attributeHandle 01334 * Handle for the value attribute of the Characteristic. 01335 * @param[in] value 01336 * A pointer to a buffer holding the new value. 01337 * @param[in] size 01338 * Size of the new value (in bytes). 01339 * @param[in] localOnly 01340 * Should this update be kept on the local 01341 * GattServer regardless of the state of the 01342 * notify/indicate flag in the CCCD for this 01343 * Characteristic? If set to true, no notification 01344 * or indication is generated. 01345 * 01346 * @return BLE_ERROR_NONE if we have successfully set the value of the attribute. 01347 * 01348 * @deprecated You should use the parallel API from GattServer directly and refer to 01349 * GattServer::write(Gap::Handle_t,GattAttribute::Handle_t,const uint8_t,uint16_t,bool). 01350 * A former call to ble.updateCharacteristicValue() should be replaced with 01351 * ble.gattServer().write(). 01352 */ 01353 MBED_DEPRECATED("Use ble.gattServer().write(...)") 01354 ble_error_t updateCharacteristicValue(Gap::Handle_t connectionHandle, 01355 GattAttribute::Handle_t attributeHandle, 01356 const uint8_t *value, 01357 uint16_t size, 01358 bool localOnly = false) { 01359 return gattServer().write(connectionHandle, attributeHandle, value, size, localOnly); 01360 } 01361 01362 /** 01363 * Enable the BLE stack's Security Manager. The Security Manager implements 01364 * the cryptographic algorithms and protocol exchanges that allow two 01365 * devices to securely exchange data and privately detect each other. 01366 * Calling this API is a prerequisite for encryption and pairing (bonding). 01367 * 01368 * @param[in] enableBonding Allow for bonding. 01369 * @param[in] requireMITM Require protection against man-in-the-middle attacks. 01370 * @param[in] iocaps To specify the I/O capabilities of this peripheral, 01371 * such as availability of a display or keyboard, to 01372 * support out-of-band exchanges of security data. 01373 * @param[in] passkey To specify a static passkey. 01374 * 01375 * @return BLE_ERROR_NONE on success. 01376 * 01377 * @deprecated You should use the parallel API from SecurityManager directly, refer to 01378 * SecurityManager.init(). A former 01379 * call to ble.initializeSecurity(...) should be replaced with 01380 * ble.securityManager().init(...). 01381 */ 01382 MBED_DEPRECATED("Use ble.gattServer().write(...)") 01383 ble_error_t initializeSecurity(bool enableBonding = true, 01384 bool requireMITM = true, 01385 SecurityManager::SecurityIOCapabilities_t iocaps = SecurityManager::IO_CAPS_NONE, 01386 const SecurityManager::Passkey_t passkey = NULL) { 01387 return securityManager().init(enableBonding, requireMITM, iocaps, passkey); 01388 } 01389 01390 /** 01391 * Get the security status of a connection. 01392 * 01393 * @param[in] connectionHandle Handle to identify the connection. 01394 * @param[out] securityStatusP Security status. 01395 * 01396 * @return BLE_SUCCESS or appropriate error code indicating the reason of failure. 01397 * 01398 * @deprecated You should use the parallel API from SecurityManager directly, refer to 01399 * SecurityManager::getLinkSecurity(). A former 01400 * call to ble.getLinkSecurity(...) should be replaced with 01401 * ble.securityManager().getLinkSecurity(...). 01402 */ 01403 MBED_DEPRECATED("ble.securityManager().getLinkSecurity(...)") 01404 ble_error_t getLinkSecurity(Gap::Handle_t connectionHandle, SecurityManager::LinkSecurityStatus_t *securityStatusP) { 01405 return securityManager().getLinkSecurity (connectionHandle, securityStatusP); 01406 } 01407 01408 /** 01409 * Delete all peer device context and all related bonding information from 01410 * the database within the security manager. 01411 * 01412 * @retval BLE_ERROR_NONE On success; else returns an error code indicating the reason for the failure. 01413 * @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization or 01414 * application registration. 01415 * 01416 * @deprecated You should use the parallel API from SecurityManager directly and refer to 01417 * SecurityManager::purgeAllBondingState(). A former 01418 * call to ble.purgeAllBondingState() should be replaced with 01419 * ble.securityManager().purgeAllBondingState(). 01420 */ 01421 MBED_DEPRECATED("ble.securityManager().purgeAllBondingState(...)") 01422 ble_error_t purgeAllBondingState(void) { 01423 return securityManager().purgeAllBondingState(); 01424 } 01425 01426 /** 01427 * Set up a callback for timeout events. Refer to Gap::TimeoutSource_t for 01428 * possible event types. 01429 * 01430 * @deprecated You should use the parallel API from Gap directly and refer to 01431 * Gap::onTimeout(). A former call 01432 * to ble.onTimeout(callback) should be replaced with 01433 * ble.gap().onTimeout(callback). 01434 */ 01435 MBED_DEPRECATED("ble.gap().onTimeout(callback)") 01436 void onTimeout(Gap::TimeoutEventCallback_t timeoutCallback) { 01437 gap().onTimeout(timeoutCallback); 01438 } 01439 01440 /** 01441 * Set up a callback for connection events. Refer to Gap::ConnectionEventCallback_t. 01442 * 01443 * @deprecated You should use the parallel API from Gap directly, refer to 01444 * Gap::onConnection(). A former call 01445 * to ble.onConnection(callback) should be replaced with 01446 * ble.gap().onConnection(callback). 01447 */ 01448 MBED_DEPRECATED("ble.gap().onConnection(callback)") 01449 void onConnection(Gap::ConnectionEventCallback_t connectionCallback) { 01450 gap().onConnection(connectionCallback); 01451 } 01452 01453 /** 01454 * Append to a chain of callbacks to be invoked upon GAP disconnection. 01455 * 01456 * @deprecated You should use the parallel API from Gap directly and refer to 01457 * Gap::onDisconnection(). A former call 01458 * to ble.onDisconnection(callback) should be replaced with 01459 * ble.gap().onDisconnection(callback). 01460 */ 01461 MBED_DEPRECATED("ble.gap().onDisconnection(callback)") 01462 void onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback) { 01463 gap().onDisconnection(disconnectionCallback); 01464 } 01465 01466 /** 01467 * The same as onDisconnection() but allows an object reference and member function 01468 * to be added to the chain of callbacks. 01469 * 01470 * @deprecated You should use the parallel API from Gap directly and refer to 01471 * Gap::onDisconnection(). A former call 01472 * to ble.onDisconnection(callback) should be replaced with 01473 * ble.gap().onDisconnection(callback). 01474 */ 01475 template<typename T> 01476 MBED_DEPRECATED("ble.gap().onDisconnection(callback)") 01477 void onDisconnection(T *tptr, void (T::*mptr)(const Gap::DisconnectionCallbackParams_t*)) { 01478 gap().onDisconnection(tptr, mptr); 01479 } 01480 01481 /** 01482 * Radio Notification is a feature that enables ACTIVE and INACTIVE 01483 * (nACTIVE) signals from the stack. These notify the application when the 01484 * radio is in use. The signal is sent using software interrupt. 01485 * 01486 * The ACTIVE signal is sent before the radio event starts. The nACTIVE 01487 * signal is sent at the end of the radio event. These signals can be used 01488 * by the application programmer to synchronize application logic with radio 01489 * activity. For example, the ACTIVE signal can be used to shut off external 01490 * devices to manage peak current drawn during periods when the radio is on, 01491 * or to trigger sensor data collection for transmission in the radio event. 01492 * 01493 * @param callback 01494 * The application handler to be invoked in response to a radio 01495 * ACTIVE/INACTIVE event. 01496 * 01497 * @deprecated You should use the parallel API from Gap directly, refer to 01498 * Gap::onRadioNotification(). A former call 01499 * to ble.onRadioNotification(...) should be replaced with 01500 * ble.gap().onRadioNotification(...). 01501 */ 01502 MBED_DEPRECATED("ble.gap().onRadioNotification(...)") 01503 void onRadioNotification(void (*callback)(bool)) { 01504 gap().onRadioNotification(callback); 01505 } 01506 01507 /** 01508 * Add a callback for the GATT event DATA_SENT (which is triggered when 01509 * updates are sent out by GATT in the form of notifications). 01510 * 01511 * @note It is possible to chain together multiple onDataSent callbacks 01512 * (potentially from different modules of an application) to receive updates 01513 * to characteristics. 01514 * 01515 * @note It is also possible to set up a callback into a member function of 01516 * some object. 01517 * 01518 * @deprecated You should use the parallel API from GattServer directly and refer to 01519 * GattServer::onDataSent(). A former call 01520 * to ble.onDataSent(...) should be replaced with 01521 * ble.gattServer().onDataSent(...). 01522 */ 01523 MBED_DEPRECATED("ble.gattServer().onDataSent(...)") 01524 void onDataSent(void (*callback)(unsigned count)) { 01525 gattServer().onDataSent(callback); 01526 } 01527 01528 /** 01529 * The same as onDataSent() but allows an object reference and member function 01530 * to be added to the chain of callbacks. 01531 * 01532 * @deprecated You should use the parallel API from GattServer directly and refer to 01533 * GattServer::onDataSent(). A former call 01534 * to ble.onDataSent(...) should be replaced with 01535 * ble.gattServer().onDataSent(...). 01536 */ 01537 template <typename T> 01538 MBED_DEPRECATED("ble.gattServer().onDataSent(...)") 01539 void onDataSent(T * objPtr, void (T::*memberPtr)(unsigned count)) { 01540 gattServer().onDataSent(objPtr, memberPtr); 01541 } 01542 01543 /** 01544 * Set up a callback for when an attribute has its value updated by or at the 01545 * connected peer. For a peripheral, this callback is triggered when the local 01546 * GATT server has an attribute updated by a write command from the peer. 01547 * For a Central, this callback is triggered when a response is received for 01548 * a write request. 01549 * 01550 * @note It is possible to chain together multiple onDataWritten callbacks 01551 * (potentially from different modules of an application) to receive updates 01552 * to characteristics. Many services, such as DFU and UART, add their own 01553 * onDataWritten callbacks behind the scenes to trap interesting events. 01554 * 01555 * @note It is also possible to set up a callback into a member function of 01556 * some object. 01557 * 01558 * @deprecated You should use the parallel API from GattServer directly and refer to 01559 * GattServer::onDataWritten(). A former call 01560 * to ble.onDataWritten(...) should be replaced with 01561 * ble.gattServer().onDataWritten(...). 01562 */ 01563 MBED_DEPRECATED("ble.gattServer().onDataWritten(...)") 01564 void onDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP)) { 01565 gattServer().onDataWritten(callback); 01566 } 01567 01568 /** 01569 * The same as onDataWritten() but allows an object reference and member function 01570 * to be added to the chain of callbacks. 01571 * 01572 * @deprecated You should use the parallel API from GattServer directly, refer to 01573 * GattServer::onDataWritten(). A former call 01574 * to ble.onDataWritten(...) should be replaced with 01575 * ble.gattServer().onDataWritten(...). 01576 */ 01577 template <typename T> 01578 MBED_DEPRECATED("ble.gattServer().onDataWritten(...)") 01579 void onDataWritten(T * objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context)) { 01580 gattServer().onDataWritten(objPtr, memberPtr); 01581 } 01582 01583 /** 01584 * Set up a callback to be invoked on the peripheral when an attribute is 01585 * being read by a remote client. 01586 * 01587 * @note This functionality may not be available on all underlying stacks. 01588 * You could use GattCharacteristic::setReadAuthorizationCallback() as an 01589 * alternative. 01590 * 01591 * @note It is possible to chain together multiple onDataRead callbacks 01592 * (potentially from different modules of an application) to receive updates 01593 * to characteristics. Services may add their own onDataRead callbacks 01594 * behind the scenes to trap interesting events. 01595 * 01596 * @note It is also possible to set up a callback into a member function of 01597 * some object. 01598 * 01599 * @return BLE_ERROR_NOT_IMPLEMENTED if this functionality isn't available; 01600 * else BLE_ERROR_NONE. 01601 * 01602 * @deprecated You should use the parallel API from GattServer directly and refer to 01603 * GattServer::onDataRead(). A former call 01604 * to ble.onDataRead(...) should be replaced with 01605 * ble.gattServer().onDataRead(...). 01606 */ 01607 MBED_DEPRECATED("ble.gattServer().onDataRead(...)") 01608 ble_error_t onDataRead(void (*callback)(const GattReadCallbackParams *eventDataP)) { 01609 return gattServer().onDataRead(callback); 01610 } 01611 01612 /** 01613 * The same as onDataRead() but allows an object reference and member function 01614 * to be added to the chain of callbacks. 01615 * 01616 * @deprecated You should use the parallel API from GattServer directly and refer to 01617 * GattServer::onDataRead(). A former call 01618 * to ble.onDataRead(...) should be replaced with 01619 * ble.gattServer().onDataRead(...). 01620 */ 01621 template <typename T> 01622 MBED_DEPRECATED("ble.gattServer().onDataRead(...)") 01623 ble_error_t onDataRead(T * objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context)) { 01624 return gattServer().onDataRead(objPtr, memberPtr); 01625 } 01626 01627 /** 01628 * Set up a callback for when notifications or indications are enabled for a 01629 * characteristic on the local GattServer. 01630 * 01631 * @deprecated You should use the parallel API from GattServer directly and refer to 01632 * GattServer::onUpdatesEnabled(). A former call 01633 * to ble.onUpdatesEnabled(callback) should be replaced with 01634 * ble.gattServer().onUpdatesEnabled(callback). 01635 */ 01636 MBED_DEPRECATED("ble.gattServer().onUpdatesEnabled(...)") 01637 void onUpdatesEnabled(GattServer::EventCallback_t callback) { 01638 gattServer().onUpdatesEnabled(callback); 01639 } 01640 01641 /** 01642 * Set up a callback for when notifications or indications are disabled for a 01643 * characteristic on the local GattServer. 01644 * 01645 * @deprecated You should use the parallel API from GattServer directly and refer to 01646 * GattServer::onUpdatesDisabled(). A former call 01647 * to ble.onUpdatesDisabled(callback) should be replaced with 01648 * ble.gattServer().onUpdatesDisabled(callback). 01649 */ 01650 MBED_DEPRECATED("ble.gattServer().onUpdatesDisabled(...)") 01651 void onUpdatesDisabled(GattServer::EventCallback_t callback) { 01652 gattServer().onUpdatesDisabled(callback); 01653 } 01654 01655 /** 01656 * Set up a callback for when the GATT server receives a response for an 01657 * indication event sent previously. 01658 * 01659 * @deprecated You should use the parallel API from GattServer directly and refer to 01660 * GattServer::onConfirmationReceived(). A former call 01661 * to ble.onConfirmationReceived(callback) should be replaced with 01662 * ble.gattServer().onConfirmationReceived(callback). 01663 */ 01664 MBED_DEPRECATED("ble.gattServer().onConfirmationReceived(...)") 01665 void onConfirmationReceived(GattServer::EventCallback_t callback) { 01666 gattServer().onConfirmationReceived(callback); 01667 } 01668 01669 /** 01670 * Set up a callback for when the security setup procedure (key generation 01671 * and exchange) for a link has started. This will be skipped for bonded 01672 * devices. The callback is passed in parameters received from the peer's 01673 * security request: bool allowBonding, bool requireMITM and 01674 * SecurityIOCapabilities_t. 01675 * 01676 * @deprecated You should use the parallel API from SecurityManager directly and refer to 01677 * SecurityManager::onSecuritySetupInitiated(). A former 01678 * call to ble.onSecuritySetupInitiated(callback) should be replaced with 01679 * ble.securityManager().onSecuritySetupInitiated(callback). 01680 */ 01681 MBED_DEPRECATED("ble.securityManager().onSecuritySetupInitiated(callback)") 01682 void onSecuritySetupInitiated(SecurityManager::SecuritySetupInitiatedCallback_t callback) { 01683 securityManager().onSecuritySetupInitiated (callback); 01684 } 01685 01686 /** 01687 * Set up a callback for when the security setup procedure (key generation 01688 * and exchange) for a link has completed. This will be skipped for bonded 01689 * devices. The callback is passed in the success/failure status of the 01690 * security setup procedure. 01691 * 01692 * @deprecated You should use the parallel API from SecurityManager directly and refer to 01693 * SecurityManager::onSecuritySetupCompleted(). A former 01694 * call to ble.onSecuritySetupCompleted(callback) should be replaced with 01695 * ble.securityManager().onSecuritySetupCompleted(callback). 01696 */ 01697 MBED_DEPRECATED("ble.securityManager().onSecuritySetupCompleted(callback)") 01698 void onSecuritySetupCompleted(SecurityManager::SecuritySetupCompletedCallback_t callback) { 01699 securityManager().onSecuritySetupCompleted (callback); 01700 } 01701 01702 /** 01703 * Set up a callback for when a link with the peer is secured. For bonded 01704 * devices, subsequent reconnections with a bonded peer will result only in 01705 * this callback when the link is secured, and setup procedures will not 01706 * occur unless the bonding information is either lost or deleted on either 01707 * or both sides. The callback is passed in a SecurityManager::SecurityMode_t according 01708 * to the level of security in effect for the secured link. 01709 * 01710 * @deprecated You should use the parallel API from SecurityManager directly and refer to 01711 * SecurityManager::onLinkSecured(). A former 01712 * call to ble.onLinkSecured(callback) should be replaced with 01713 * ble.securityManager().onLinkSecured(callback). 01714 */ 01715 MBED_DEPRECATED("ble.securityManager().onLinkSecured(callback)") 01716 void onLinkSecured(SecurityManager::LinkSecuredCallback_t callback) { 01717 securityManager().onLinkSecured (callback); 01718 } 01719 01720 /** 01721 * Set up a callback for successful bonding, meaning that link-specific security 01722 * context is stored persistently for a peer device. 01723 * 01724 * @deprecated You should use the parallel API from SecurityManager directly and refer to 01725 * SecurityManager::onSecurityContextStored(). A former 01726 * call to ble.onSecurityContextStored(callback) should be replaced with 01727 * ble.securityManager().onSecurityContextStored(callback). 01728 */ 01729 MBED_DEPRECATED("ble.securityManager().onSecurityContextStored(callback)") 01730 void onSecurityContextStored(SecurityManager::HandleSpecificEvent_t callback) { 01731 securityManager().onSecurityContextStored (callback); 01732 } 01733 01734 /** 01735 * Set up a callback for when the passkey needs to be displayed on a 01736 * peripheral with DISPLAY capability. This happens when security is 01737 * configured to prevent man-in-the-middle attacks, and the peers need to exchange 01738 * a passkey (or PIN) to authenticate the connection 01739 * attempt. 01740 * 01741 * @deprecated You should use the parallel API from SecurityManager directly and refer to 01742 * SecurityManager::onPasskeyDisplay(). A former 01743 * call to ble.onPasskeyDisplay(callback) should be replaced with 01744 * ble.securityManager().onPasskeyDisplay(callback). 01745 */ 01746 MBED_DEPRECATED("ble.securityManager().onPasskeyDisplay(callback)") 01747 void onPasskeyDisplay(SecurityManager::PasskeyDisplayCallback_t callback) { 01748 return securityManager().onPasskeyDisplay (callback); 01749 } 01750 01751 private: 01752 friend class BLEInstanceBase; 01753 01754 /** 01755 * This function allows the BLE stack to signal that there is work to do and 01756 * event processing should be done (BLE::processEvent()). 01757 * 01758 * @note This function should be called by the port of BLE_API. It is not 01759 * meant to be used by end users. 01760 */ 01761 void signalEventsToProcess(); 01762 01763 /** 01764 * Implementation of init() [internal to BLE_API]. 01765 * 01766 * The implementation is separated into a private method because it isn't 01767 * suitable to be included in the header. 01768 */ 01769 ble_error_t initImplementation( 01770 FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback 01771 ); 01772 01773 private: 01774 // Prevent copy construction and copy assignment of BLE. 01775 BLE(const BLE&); 01776 BLE &operator=(const BLE &); 01777 01778 private: 01779 InstanceID_t instanceID; 01780 BLEInstanceBase *transport; /* The device-specific backend */ 01781 OnEventsToProcessCallback_t whenEventsToProcess; 01782 bool event_signaled; 01783 }; 01784 01785 /** 01786 * @deprecated This type alias is retained for the sake of compatibility with 01787 * older code. This will be dropped at some point. 01788 */ 01789 typedef BLE BLEDevice ; 01790 01791 /** 01792 * @namespace ble Entry namespace for all %BLE API definitions. 01793 */ 01794 01795 /** 01796 * @} 01797 */ 01798 01799 #endif /* ifndef MBED_BLE_H__ */
Generated on Tue Jul 12 2022 12:43:36 by
