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.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
Gap.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2018-2018 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 BLE_GAP_GAP_H 00018 #define BLE_GAP_GAP_H 00019 00020 #include "BLERoles.h" 00021 #include "ble/common/StaticInterface.h" 00022 #include "ble/BLETypes.h" 00023 #include "ble/BLEProtocol.h" 00024 #include "ble/gap/AdvertisingDataBuilder.h" 00025 #include "ble/gap/AdvertisingDataSimpleBuilder.h" 00026 #include "ble/gap/ConnectionParameters.h" 00027 #include "ble/gap/ScanParameters.h" 00028 #include "ble/gap/AdvertisingParameters.h" 00029 #include "ble/gap/Events.h" 00030 00031 namespace ble { 00032 #if !defined(DOXYGEN_ONLY) 00033 namespace interface { 00034 #endif 00035 00036 /** 00037 * @addtogroup ble 00038 * @{ 00039 * @addtogroup gap 00040 * @{ 00041 */ 00042 00043 /** 00044 * Define device discovery, connection and link management procedures. 00045 * 00046 * - Device discovery: A device can advertise to nearby peers its existence, 00047 * identity and capabilities. Similarly, a device can scan its environment to 00048 * find advertising peers. The information acquired during the scan helps to 00049 * identify peers and understand their use. A scanner may acquire more information 00050 * about an advertising peer by sending a scan request. If the peer accepts scan 00051 * requests, it may reply with additional information about its state. 00052 * 00053 * - Connection: A bluetooth device can establish a connection to a connectable 00054 * advertising peer. Once the connection is established, both devices can 00055 * communicate using the GATT protocol. The GATT protocol allows connected 00056 * devices to expose a set of states that the other peer can discover, read and write. 00057 * 00058 * - Link Management: Connected devices may drop the connection and may adjust 00059 * connection parameters according to the power envelop needed for their 00060 * application. 00061 * 00062 * @par Accessing gap 00063 * 00064 * Instance of a Gap class for a given BLE device should be accessed using 00065 * BLE::gap(). The reference returned remains valid until the BLE instance 00066 * shut down (see BLE::shutdown()). 00067 * 00068 * @code 00069 * // assuming ble_device has been initialized 00070 * BLE& ble_device; 00071 * 00072 * ble::Gap& gap = ble_device.gap(); 00073 * @endcode 00074 * 00075 * @par Advertising 00076 * 00077 * Advertising consists of broadcasting at a regular interval a small amount of 00078 * data containing valuable information about the device. These packets may be 00079 * scanned by peer devices listening on BLE advertising channels. 00080 * 00081 * Scanners may also request additional information from a device advertising by 00082 * sending a scan request. If the broadcaster accepts scan requests, it can reply 00083 * with a scan response packet containing additional information. 00084 * 00085 * Advertising parameters are updated using setAdvertisingParams(). The main 00086 * advertising payload is updated using setAdvertisingPayload(), and the scan response 00087 * is updated using setAdvertisingScanResponse(). If the advertising is already 00088 * updated, the data will take effect from the next advertising event. 00089 * 00090 * To create a valid advertising payload and scan response, you may use 00091 * AdvertisingDataBuilder. You must first allocate memory and create an mbed::Span and 00092 * pass that into the AdvertisingDataBuilder, which will only be able to add as much 00093 * data as fits in the provided buffer. The builder accepts any size of the buffer, 00094 * but for the created data to be usable, it must be smaller than the maximum data 00095 * length returned from getMaxAdvertisingDataLength(). 00096 * 00097 * Another option is to use AdvertisingDataSimpleBuilder, which allocates memory 00098 * on the stack and offers a fluent interface at the expense of a reduced set of 00099 * APIs and error management options. 00100 * 00101 * @note Prior to Bluetooth 5, advertising and scanning payload size were limited 00102 * to LEGACY_ADVERTISING_MAX_SIZE. It changed with Bluetooth 5, and now the maximum 00103 * size of data that can be advertised depends on the controller. If you wish 00104 * to be compatible with older devices, you may wish to advertise with the 00105 * LEGACY_ADVERTISING_HANDLE. This uses payloads no larger than LEGACY_ADVERTISING_MAX_SIZE 00106 * with that advertising set. 00107 * 00108 * @par Extended advertising 00109 * 00110 * Extended advertising allows for a wider choice of options than legacy advertising. 00111 * You can send bigger payloads and use different PHYs. This allows for bigger throughput 00112 * or longer range. 00113 * 00114 * Extended advertising may be split across many packets and takes place on both the 00115 * regular advertising channels and the rest of the 37 channels normally used by 00116 * connected devices. 00117 * 00118 * The 3 channels used in legacy advertising are called primary advertisement channels. 00119 * The remaining 37 channels are used for secondary advertising. Unlike sending data 00120 * during a connection, this allows the device to broadcast data to multiple devices. 00121 * 00122 * The advertising starts on the primary channels (which you may select) and continues 00123 * on the secondary channels as indicated in the packet sent on the primary channel. 00124 * This way, the advertising can send large payloads without saturating the advertising 00125 * channels. Primary channels are limited to 1M and coded PHYs, but secondary channels 00126 * may use the increased throughput 2M PHY. 00127 * 00128 * @par Periodic advertising 00129 * 00130 * Similarly, you can use periodic advertising to transfer regular data to multiple 00131 * devices. 00132 * 00133 * The advertiser uses primary channels to advertise the information needed to 00134 * listen to the periodic advertisements on secondary channels. This sync information 00135 * will be used by the scanner who can now optimize for power consumption and only 00136 * listen for the periodic advertisements at specified times. 00137 * 00138 * Like extended advertising, periodic advertising offers extra PHY options of 2M 00139 * and coded. The payload may be updated at any time and will be updated on the next 00140 * advertisement event when the periodic advertising is active. 00141 * 00142 * @par Advertising sets 00143 * 00144 * Advertisers may advertise multiple payloads at the same time. The configuration 00145 * and identification of these is done through advertising sets. Use a handle 00146 * obtained from createAvertisingSet() for advertising operations. After ending 00147 * all advertising operations, remove the handle from the system using 00148 * destroyAdvertisingHandle(). 00149 * 00150 * Extended advertising and periodic advertising is an optional feature, and not all 00151 * devices support it. Some will only be able to see the now-called legacy advertising. 00152 * 00153 * Legacy advertising is available through a special handle, LEGACY_ADVERTISING_HANDLE. 00154 * This handle is always available, doesn't need to be created and can't be 00155 * destroyed. 00156 * 00157 * There is a limited number of advertising sets available because they require support 00158 * from the controller. Their availability is dynamic and may be queried at any time 00159 * using getMaxAdvertisingSetNumber(). Advertising sets take up resources even if 00160 * they are not actively advertising right now, so it's important to destroy the set 00161 * when you're done with it (or reuse it in the next advertisement). 00162 * 00163 * Periodic advertising and extended advertising share the same set but not the same 00164 * data. Extended advertising carries out periodic advertising synchronization 00165 * information. Therefore, to let other devices be aware that your device 00166 * exposes periodic advertising, you should start extended advertising of the set. 00167 * Subsequently, you may disable extended advertising, and the periodic advertising 00168 * will continue. If you start periodic advertising while extended advertising is 00169 * inactive, periodic advertising won't start until you start extended advertising 00170 * at a later time. 00171 * 00172 * @par Privacy 00173 * 00174 * Privacy is a feature that allows a device to avoid being tracked by other 00175 * (untrusted) devices. The device achieves it by periodically generating a 00176 * new random address. The random address may be a resolvable random address, 00177 * enabling trusted devices to recognize it as belonging to the same 00178 * device. These trusted devices receive an Identity Resolution Key (IRK) 00179 * during pairing. This is handled by the SecurityManager and relies on the 00180 * other device accepting and storing the IRK. 00181 * 00182 * You need to enable privacy by calling enablePrivacy() after having 00183 * initialized the SecurityManager because privacy requires SecurityManager 00184 * to handle IRKs. The behavior of privacy enabled devices is set by 00185 * using setCentralPrivacyConfiguration(), which specifies what the device 00186 * should be with devices using random addresses. Random addresses 00187 * generated by privacy enabled devices can be of two types: resolvable 00188 * (by devices who have the IRK) and unresolvable. Unresolvable addresses 00189 * can't be used for connecting and connectable advertising. Therefore, a 00190 * resolvable one will be used for these regardless of the privacy 00191 * configuration. 00192 * 00193 * @par Scanning 00194 * 00195 * Scanning consists of listening for peer advertising packets. From a scan, a 00196 * device can identify devices available in its environment. 00197 * 00198 * If the device scans actively, then it will send scan request to scannable 00199 * advertisers and collect their scan responses. 00200 * 00201 * Scanning is done by creating ScanParameters and applying them with 00202 * setScanParameters(). One configured, you may call startScan(). 00203 * 00204 * When a scanning device receives an advertising packet, it will call 00205 * onAdvertisingReport() in the registered event handler. A whitelist may be used 00206 * to limit the advertising reports by setting the correct policy in the scan 00207 * parameters. 00208 * 00209 * @par Connection event handling 00210 * 00211 * A peer may connect device advertising connectable packets. The advertising 00212 * procedure ends as soon as the device is connected. If an advertising timeout 00213 * has been set in the advertising parameters then onAdvertisingEnd will be called 00214 * in the registered eventHandler when it runs out. 00215 * 00216 * A device accepting a connection request from a peer is named a peripheral, 00217 * and the device initiating the connection is named a central. 00218 * 00219 * Connection is initiated by central devices. A call to connect() will result in 00220 * the device scanning on any PHYs set in ConectionParamters passed in. 00221 * 00222 * Peripheral and central receive a connection event when the connection is 00223 * effective. If successful will result in a call to onConnectionComplete in the 00224 * EventHandler registered with the Gap. 00225 * 00226 * It the connection attempt fails it will result in onConnectionComplete called 00227 * on the central device with the event carrying the error flag. 00228 * 00229 * @par Changing the PHYsical transport of a connection 00230 * 00231 * Once a connection has been established, it is possible to change the physical 00232 * transport used between the local and the distant device. Changing the transport 00233 * can either increase the bandwidth or increase the communication range. 00234 * An increased bandwidth equals a better power consumption but also a loss in 00235 * sensibility and therefore a degraded range. 00236 * 00237 * Symmetrically an increased range means a lowered bandwidth and a degraded power 00238 * consumption. 00239 * 00240 * Applications can change the PHY used by calling the function setPhy. Once the 00241 * update has been made the result is forwarded to the application by calling the 00242 * function onPhyUpdateComplete of the event handler registered. 00243 * 00244 * @par disconnection 00245 * 00246 * The application code initiates a disconnection when it calls the 00247 * disconnect(Handle_t, DisconnectionReason_t) function. 00248 * 00249 * Disconnection may also be initiated by the remote peer or the local 00250 * controller/stack. To catch all disconnection events, application code may 00251 * set up an handler taking care of disconnection events by calling 00252 * onDisconnection(). 00253 * 00254 * @par Modulation Schemes 00255 * 00256 * When supported by the host and controller you can select different modulation 00257 * schemes (@see BLUETOOTH SPECIFICATION Version 5.0 | Vol 1, Part A - 1.2): 00258 * - LE 1M PHY 00259 * - LE 2M PHY 00260 * - LE coded PHY 00261 * 00262 * You may set preferred PHYs (separately for RX and TX) using setPreferredPhys(). 00263 * You may also set the currently used PHYs on a selected connection using setPhy(). 00264 * Both of these settings are only advisory and the controller is allowed to make 00265 * its own decision on the best PHY to use based on your request, the peer's 00266 * supported features and the connection's physical conditions. 00267 * 00268 * You may query the currently used PHY using readPhy() which will return the 00269 * result through a call to the registered event handler. You may register the 00270 * handler with setEventHandler(). The events inform about the currently used 00271 * PHY and of any changes to PHYs which may be triggered autonomously by the 00272 * controller or by the peer. 00273 */ 00274 #if defined(DOXYGEN_ONLY) 00275 class Gap { 00276 #else 00277 template<class Impl> 00278 class Gap : public StaticInterface<Impl, Gap> { 00279 #endif 00280 using StaticInterface<Impl, ::ble::interface::Gap>::impl; 00281 00282 public: 00283 00284 /** 00285 * Definition of the general handler of Gap related events. 00286 */ 00287 struct EventHandler { 00288 /** 00289 * Called when an advertising device receive a scan response. 00290 * 00291 * @param event Scan request event. 00292 * 00293 * @version: 5+. 00294 * 00295 * @see AdvertisingParameters::setScanRequestNotification(). 00296 */ 00297 virtual void onScanRequestReceived(const ScanRequestEvent &event) 00298 { 00299 } 00300 00301 /** 00302 * Called when advertising ends. 00303 * 00304 * Advertising ends when the process timeout or if it is stopped by the 00305 * application or if the local device accepts a connection request. 00306 * 00307 * @param event Advertising end event. 00308 * 00309 * @see startAdvertising() 00310 * @see stopAdvertising() 00311 * @see onConnectionComplete() 00312 */ 00313 virtual void onAdvertisingEnd(const AdvertisingEndEvent &event) 00314 { 00315 } 00316 00317 /** 00318 * Called when a scanner receives an advertising or a scan response packet. 00319 * 00320 * @param event Advertising report. 00321 * 00322 * @see startScan() 00323 */ 00324 virtual void onAdvertisingReport(const AdvertisingReportEvent &event) 00325 { 00326 } 00327 00328 /** 00329 * Called when scan times out. 00330 * 00331 * @param event Associated event. 00332 * 00333 * @see startScan() 00334 */ 00335 virtual void onScanTimeout(const ScanTimeoutEvent &event) 00336 { 00337 } 00338 00339 /** 00340 * Called when first advertising packet in periodic advertising is received. 00341 * 00342 * @param event Periodic advertising sync event. 00343 * 00344 * @version: 5+. 00345 * 00346 * @see createSync() 00347 */ 00348 virtual void onPeriodicAdvertisingSyncEstablished( 00349 const PeriodicAdvertisingSyncEstablishedEvent &event 00350 ) 00351 { 00352 } 00353 00354 /** 00355 * Called when a periodic advertising packet is received. 00356 * 00357 * @param event Periodic advertisement event. 00358 * 00359 * @version: 5+. 00360 * 00361 * @see createSync() 00362 */ 00363 virtual void onPeriodicAdvertisingReport( 00364 const PeriodicAdvertisingReportEvent &event 00365 ) 00366 { 00367 } 00368 00369 /** 00370 * Called when a periodic advertising sync has been lost. 00371 * 00372 * @param event Details of the event. 00373 * 00374 * @version: 5+. 00375 * 00376 * @see createSync() 00377 */ 00378 virtual void onPeriodicAdvertisingSyncLoss( 00379 const PeriodicAdvertisingSyncLoss &event 00380 ) 00381 { 00382 } 00383 00384 /** 00385 * Called when connection attempt ends or an advertising device has been 00386 * connected. 00387 * 00388 * @see startAdvertising() 00389 * @see connect() 00390 * 00391 * @param event Connection event. 00392 */ 00393 virtual void onConnectionComplete(const ConnectionCompleteEvent &event) 00394 { 00395 } 00396 00397 /** 00398 * Called when the peer request connection parameters updates. 00399 * 00400 * Application must accept the update with acceptConnectionParametersUpdate() 00401 * or reject it with rejectConnectionParametersUpdate(). 00402 * 00403 * @param event The connection parameters requested by the peer. 00404 * 00405 * @version 4.1+. 00406 * 00407 * @note This event is not generated if connection parameters update 00408 * is managed by the middleware. 00409 * 00410 * @see manageConnectionParametersUpdateRequest() 00411 * @see acceptConnectionParametersUpdate() 00412 * @see rejectConnectionParametersUpdate() 00413 */ 00414 virtual void onUpdateConnectionParametersRequest( 00415 const UpdateConnectionParametersRequestEvent &event 00416 ) 00417 { 00418 } 00419 00420 /** 00421 * Called when connection parameters have been updated. 00422 * 00423 * @param event The new connection parameters. 00424 * 00425 * @see updateConnectionParameters() 00426 * @see acceptConnectionParametersUpdate() 00427 */ 00428 virtual void onConnectionParametersUpdateComplete( 00429 const ConnectionParametersUpdateCompleteEvent &event 00430 ) 00431 { 00432 } 00433 00434 /** 00435 * Called when a connection has been disconnected. 00436 * 00437 * @param event Details of the event. 00438 * 00439 * @see disconnect() 00440 */ 00441 virtual void onDisconnectionComplete(const DisconnectionCompleteEvent &event) 00442 { 00443 } 00444 00445 /** 00446 * Function invoked when the current transmitter and receiver PHY have 00447 * been read for a given connection. 00448 * 00449 * @param status Status of the operation: BLE_ERROR_NONE in case of 00450 * success or an appropriate error code. 00451 * 00452 * @param connectionHandle: The handle of the connection for which the 00453 * PHYs have been read. 00454 * 00455 * @param txPhy PHY used by the transmitter. 00456 * 00457 * @param rxPhy PHY used by the receiver. 00458 * 00459 * @see readPhy(). 00460 * 00461 * @version: 5+. 00462 */ 00463 virtual void onReadPhy( 00464 ble_error_t status, 00465 connection_handle_t connectionHandle, 00466 phy_t txPhy, 00467 phy_t rxPhy 00468 ) 00469 { 00470 } 00471 00472 /** 00473 * Function invoked when the update process of the PHY has been completed. 00474 * 00475 * The process can be initiated by a call to the function setPhy, the 00476 * local bluetooth subsystem or the peer. 00477 * 00478 * @param status Status of the operation: BLE_ERROR_NONE in case of 00479 * success or an appropriate error code. 00480 * 00481 * @param connectionHandle: The handle of the connection on which the 00482 * operation was made. 00483 * 00484 * @param txPhy PHY used by the transmitter. 00485 * 00486 * @param rxPhy PHY used by the receiver. 00487 * 00488 * @note Success doesn't mean the PHY has been updated it means both 00489 * ends have negotiated the best PHY according to their configuration and 00490 * capabilities. The PHY currently used are present in the txPhy and 00491 * rxPhy parameters. 00492 * 00493 * @see setPhy() 00494 * 00495 * @version: 5+. 00496 */ 00497 virtual void onPhyUpdateComplete( 00498 ble_error_t status, 00499 connection_handle_t connectionHandle, 00500 phy_t txPhy, 00501 phy_t rxPhy 00502 ) 00503 { 00504 } 00505 00506 /** 00507 * Function invoked when the connections changes the maximum number of octets 00508 * that can be sent or received by the controller in a single packet. A single 00509 * L2CAP packet can be fragmented across many such packets. 00510 * 00511 * @note This only triggers if controller supports data length extension and 00512 * negotiated data length is longer than the default 23. 00513 * 00514 * @param connectionHandle The handle of the connection that changed the size. 00515 * @param txSize Number of octets we can send on this connection in a single packet. 00516 * @param rxSize Number of octets we can receive on this connection in a single packet. 00517 */ 00518 virtual void onDataLengthChange( 00519 connection_handle_t connectionHandle, 00520 uint16_t txSize, 00521 uint16_t rxSize 00522 ) 00523 { 00524 } 00525 protected: 00526 /** 00527 * Prevent polymorphic deletion and avoid unnecessary virtual destructor 00528 * as the Gap class will never delete the instance it contains. 00529 */ 00530 ~EventHandler() 00531 { 00532 } 00533 }; 00534 00535 /** 00536 * Assign the event handler implementation that will be used by the gap 00537 * module to signal events back to the application. 00538 * 00539 * @param handler Application implementation of an EventHandler. 00540 */ 00541 void setEventHandler(EventHandler *handler) 00542 { 00543 _eventHandler = handler; 00544 } 00545 00546 /** Check controller support for a specific feature. 00547 * 00548 * @param feature Feature to check. 00549 * @return True if feature is supported. 00550 */ 00551 bool isFeatureSupported(controller_supported_features_t feature); 00552 00553 /* advertising */ 00554 #if BLE_ROLE_BROADCASTER 00555 /** Return currently available number of supported advertising sets. 00556 * This may change at runtime. 00557 * 00558 * @note Devices that do not support Bluetooth 5 still offers one advertising 00559 * set that has the handle LEGACY_ADVERTISING_HANDLE. 00560 * 00561 * @return Number of advertising sets that may be created at the same time. 00562 */ 00563 uint8_t getMaxAdvertisingSetNumber(); 00564 00565 /** Return maximum advertising data length supported. 00566 * 00567 * @return Maximum advertising data length supported. 00568 */ 00569 uint16_t getMaxAdvertisingDataLength(); 00570 00571 /** Return maximum advertising data length supported for connectable advertising. 00572 * 00573 * @return Maximum advertising data length supported for connectable advertising. 00574 */ 00575 uint16_t getMaxConnectableAdvertisingDataLength(); 00576 00577 /** Return maximum advertising data length you may set if advertising set is active. 00578 * 00579 * @return Maximum advertising data length you may set if advertising set is active. 00580 */ 00581 uint16_t getMaxActiveSetAdvertisingDataLength(); 00582 00583 #if BLE_FEATURE_EXTENDED_ADVERTISING 00584 /** Create an advertising set and apply the passed in parameters. The handle returned 00585 * by this function must be used for all other calls that accept an advertising handle. 00586 * When done with advertising, remove from the system using destroyAdvertisingSet(). 00587 * 00588 * @note The exception is the LEGACY_ADVERTISING_HANDLE which may be used at any time. 00589 * 00590 * @param[out] handle Advertising handle returned, valid only if function returned success. 00591 * @param parameters Advertising parameters for the newly created set. 00592 * @return BLE_ERROR_NONE on success. 00593 * 00594 * @version 5+ 00595 */ 00596 ble_error_t createAdvertisingSet( 00597 advertising_handle_t *handle, 00598 const AdvertisingParameters ¶meters 00599 ); 00600 00601 /** Remove the advertising set (resets its set parameters). The advertising set must not 00602 * be active. 00603 * 00604 * @note LEGACY_ADVERTISING_HANDLE may not be destroyed. 00605 * 00606 * @param handle Advertising set handle. 00607 * @return BLE_ERROR_NONE on success. 00608 * 00609 * @version 5+ 00610 */ 00611 ble_error_t destroyAdvertisingSet(advertising_handle_t handle); 00612 #endif // BLE_FEATURE_EXTENDED_ADVERTISING 00613 00614 /** Set advertising parameters of an existing set. 00615 * 00616 * @param handle Advertising set handle. 00617 * @param params New advertising parameters. 00618 * @return BLE_ERROR_NONE on success. 00619 */ 00620 ble_error_t setAdvertisingParameters( 00621 advertising_handle_t handle, 00622 const AdvertisingParameters ¶ms 00623 ); 00624 00625 /** Set new advertising payload for a given advertising set. 00626 * 00627 * @param handle Advertising set handle. 00628 * @param payload Advertising payload. 00629 * 00630 * @note If advertising set is active you may only set payload of length equal or less 00631 * than getMaxActiveSetAdvertisingDataLength(). If you require a longer payload you must 00632 * stop the advertising set, set the payload and restart the set. 00633 * 00634 * @return BLE_ERROR_NONE on success. 00635 * 00636 * @see ble::AdvertisingDataBuilder to build a payload. 00637 */ 00638 ble_error_t setAdvertisingPayload( 00639 advertising_handle_t handle, 00640 mbed::Span<const uint8_t> payload 00641 ); 00642 00643 /** Set new advertising scan response for a given advertising set. This will be sent to 00644 * device who perform active scanning. 00645 * 00646 * @param handle Advertising set handle. 00647 * @param response Advertising scan response. 00648 * 00649 * @note If advertising set is active you may only set payload of length equal or less 00650 * than getMaxActiveSetAdvertisingDataLength(). If you require a longer payload you must 00651 * stop the advertising set, set the payload and restart the set. 00652 * 00653 * @return BLE_ERROR_NONE on success. 00654 * 00655 * @see ble::AdvertisingDataBuilder to build a payload. 00656 */ 00657 ble_error_t setAdvertisingScanResponse( 00658 advertising_handle_t handle, 00659 mbed::Span<const uint8_t> response 00660 ); 00661 00662 /** Start advertising using the given advertising set. 00663 * 00664 * @param handle Advertising set handle. 00665 * @param maxDuration Max duration for advertising (in units of 10ms) - 0 means no limit. 00666 * @param maxEvents Max number of events produced during advertising - 0 means no limit. 00667 * @return BLE_ERROR_NONE on success. 00668 * 00669 * @see EventHandler::onScanRequestReceived when a scan request is received. 00670 * @see EventHandler::onAdvertisingEnd when the advertising ends. 00671 * @see EventHandler::onConnectionComplete when the device gets connected 00672 * by a peer. 00673 */ 00674 ble_error_t startAdvertising( 00675 advertising_handle_t handle, 00676 adv_duration_t maxDuration = adv_duration_t::forever(), 00677 uint8_t maxEvents = 0 00678 ); 00679 00680 /** Stop advertising given advertising set. This is separate from periodic advertising 00681 * which will not be affected. 00682 * 00683 * @param handle Advertising set handle. 00684 * @return BLE_ERROR_NONE on success. 00685 */ 00686 ble_error_t stopAdvertising(advertising_handle_t handle); 00687 00688 /** Check if advertising is active for a given advertising set. 00689 * 00690 * @param handle Advertising set handle. 00691 * @return True if advertising is active on this set. 00692 */ 00693 bool isAdvertisingActive(advertising_handle_t handle); 00694 #endif // BLE_ROLE_BROADCASTER 00695 00696 #if BLE_ROLE_BROADCASTER 00697 #if BLE_FEATURE_PERIODIC_ADVERTISING 00698 /** Set periodic advertising parameters for a given advertising set. 00699 * 00700 * @param handle Advertising set handle. 00701 * @param periodicAdvertisingIntervalMin Minimum interval for periodic advertising. 00702 * @param periodicAdvertisingIntervalMax Maximum interval for periodic advertising. 00703 * @param advertiseTxPower Include transmission power in the advertisements. 00704 * @return BLE_ERROR_NONE on success. 00705 * 00706 * @version 5+ 00707 */ 00708 ble_error_t setPeriodicAdvertisingParameters( 00709 advertising_handle_t handle, 00710 periodic_interval_t periodicAdvertisingIntervalMin, 00711 periodic_interval_t periodicAdvertisingIntervalMax, 00712 bool advertiseTxPower = true 00713 ); 00714 00715 /** Set new periodic advertising payload for a given advertising set. 00716 * 00717 * @param handle Advertising set handle. 00718 * @param payload Advertising payload. 00719 * @return BLE_ERROR_NONE on success. 00720 * 00721 * @note If advertising set is active you may only set payload of length equal or less 00722 * than getMaxActiveSetAdvertisingDataLength(). If you require a longer payload you must 00723 * stop the advertising set, set the payload and restart the set. Stopping the set will 00724 * cause peers to lose sync on the periodic set. 00725 * 00726 * @see ble::AdvertisingDataBuilder to build a payload. 00727 * 00728 * @version 5+ 00729 */ 00730 ble_error_t setPeriodicAdvertisingPayload( 00731 advertising_handle_t handle, 00732 mbed::Span<const uint8_t> payload 00733 ); 00734 00735 /** Start periodic advertising for a given set. Periodic advertising will not start until 00736 * normal advertising is running but will continue to run after normal advertising has stopped. 00737 * 00738 * @param handle Advertising set handle. 00739 * @return BLE_ERROR_NONE on success. 00740 * 00741 * @version 5+ 00742 */ 00743 ble_error_t startPeriodicAdvertising(advertising_handle_t handle); 00744 00745 /** Stop periodic advertising for a given set. 00746 * 00747 * @param handle Advertising set handle. 00748 * @return BLE_ERROR_NONE on success. 00749 * 00750 * @version 5+ 00751 */ 00752 ble_error_t stopPeriodicAdvertising(advertising_handle_t handle); 00753 00754 /** Check if periodic advertising is active for a given advertising set. 00755 * 00756 * @param handle Advertising set handle. 00757 * @return True if periodic advertising is active on this set. 00758 * 00759 * @version 5+ 00760 */ 00761 bool isPeriodicAdvertisingActive(advertising_handle_t handle); 00762 #endif // BLE_ROLE_BROADCASTER 00763 #endif // BLE_FEATURE_PERIODIC_ADVERTISING 00764 00765 /* scanning */ 00766 #if BLE_ROLE_OBSERVER 00767 /** Set new scan parameters. 00768 * 00769 * @param params Scan parameters, @see GapScanParameters for details. 00770 * @return BLE_ERROR_NONE on success. 00771 */ 00772 ble_error_t setScanParameters(const ScanParameters ¶ms); 00773 00774 /** Start scanning. 00775 * 00776 * @param duration How long to scan for. Special value 0 means scan forever. 00777 * @param filtering Filtering policy. 00778 * @param period How long to scan for in single period. If the period is 0 and duration 00779 * is nonzero the scan will last for single duration. 00780 * 00781 * @note When the duration and period parameters are non-zero scanning will last for 00782 * the duration within the period. After the scan period has expired a new scan period 00783 * will begin and scanning. This will repeat until stopScan() is called. 00784 * 00785 * @return BLE_ERROR_NONE on success. 00786 * 00787 * @see EventHandler::onAdvertisingReport to collect advertising reports. 00788 * @see EventHandler::onScanTimeout when scanning timeout. 00789 */ 00790 ble_error_t startScan( 00791 scan_duration_t duration = scan_duration_t::forever(), 00792 duplicates_filter_t filtering = duplicates_filter_t::DISABLE, 00793 scan_period_t period = scan_period_t(0) 00794 ); 00795 00796 /** 00797 * Stop the ongoing scanning procedure. 00798 * 00799 * The current scanning parameters remain in effect. 00800 * 00801 * @retval BLE_ERROR_NONE if successfully stopped scanning procedure. 00802 */ 00803 ble_error_t stopScan(); 00804 #endif // BLE_ROLE_OBSERVER 00805 00806 #if BLE_ROLE_OBSERVER 00807 #if BLE_FEATURE_PERIODIC_ADVERTISING 00808 /** Synchronize with periodic advertising from an advertiser and begin receiving periodic 00809 * advertising packets. 00810 * 00811 * @param peerAddressType Peer address type. 00812 * @param peerAddress Peer address. 00813 * @param sid Advertiser set identifier. 00814 * @param maxPacketSkip Number of consecutive periodic advertising packets that the receiver 00815 * may skip after successfully receiving a periodic advertising packet. 00816 * @param timeout Maximum permitted time between successful receptions. If this time is 00817 * exceeded, synchronisation is lost. 00818 * @return BLE_ERROR_NONE on success. 00819 * 00820 * @see EventHandler::onPeriodicAdvertisingSyncEstablished when the sync is 00821 * effective. 00822 * @see EventHandler::onPeriodicAdvertisingReport when data are issued by the 00823 * peer. 00824 * @see EventHandler::onPeriodicAdvertisingSyncLoss when the sync has been 00825 * loss. 00826 * 00827 * @version 5+ 00828 */ 00829 ble_error_t createSync( 00830 peer_address_type_t peerAddressType, 00831 const address_t &peerAddress, 00832 uint8_t sid, 00833 slave_latency_t maxPacketSkip, 00834 sync_timeout_t timeout 00835 ); 00836 00837 /** Synchronize with periodic advertising from an advertiser and begin receiving periodic 00838 * advertising packets. Use periodic advertising sync list to determine who to sync with. 00839 * 00840 * @param maxPacketSkip Number of consecutive periodic advertising packets that the receiver 00841 * may skip after successfully receiving a periodic advertising packet. 00842 * @param timeout Maximum permitted time between successful receives. 00843 * If this time is exceeded, synchronisation is lost. 00844 * @return BLE_ERROR_NONE on success. 00845 * 00846 * @see EventHandler::onPeriodicAdvertisingSyncEstablished when the sync is 00847 * effective. 00848 * @see EventHandler::onPeriodicAdvertisingReport when data are issued by the 00849 * peer. 00850 * @see EventHandler::onPeriodicAdvertisingSyncLoss when the sync has been 00851 * loss. 00852 * 00853 * @version 5+ 00854 */ 00855 ble_error_t createSync( 00856 slave_latency_t maxPacketSkip, 00857 sync_timeout_t timeout 00858 ); 00859 00860 /** Cancel sync attempt. 00861 * 00862 * @return BLE_ERROR_NONE on success. 00863 */ 00864 ble_error_t cancelCreateSync(); 00865 00866 /** Stop reception of the periodic advertising identified by the handle. 00867 * 00868 * @param handle Periodic advertising synchronisation handle. 00869 * @return BLE_ERROR_NONE on success. 00870 */ 00871 ble_error_t terminateSync(periodic_sync_handle_t handle); 00872 00873 /** Add device to the periodic advertiser list. Cannot be called when sync is ongoing. 00874 * 00875 * @param peerAddressType Peer address type. 00876 * @param peerAddress Peer address. 00877 * @param sid Advertiser set identifier. 00878 * @return BLE_ERROR_NONE on success. 00879 */ 00880 ble_error_t addDeviceToPeriodicAdvertiserList( 00881 peer_address_type_t peerAddressType, 00882 const address_t &peerAddress, 00883 advertising_sid_t sid 00884 ); 00885 00886 /** Remove device from the periodic advertiser list. Cannot be called when sync is ongoing. 00887 * 00888 * @param peerAddressType Peer address type. 00889 * @param peerAddress Peer address. 00890 * @param sid Advertiser set identifier. 00891 * @return BLE_ERROR_NONE on success. 00892 */ 00893 ble_error_t removeDeviceFromPeriodicAdvertiserList( 00894 peer_address_type_t peerAddressType, 00895 const address_t &peerAddress, 00896 advertising_sid_t sid 00897 ); 00898 00899 /** Remove all devices from periodic advertiser list. 00900 * 00901 * @return BLE_ERROR_NONE on success. 00902 */ 00903 ble_error_t clearPeriodicAdvertiserList(); 00904 00905 /** Get number of devices that can be added to the periodic advertiser list. 00906 * @return Number of devices that can be added to the periodic advertiser list. 00907 */ 00908 uint8_t getMaxPeriodicAdvertiserListSize(); 00909 #endif // BLE_ROLE_OBSERVER 00910 #endif // BLE_FEATURE_PERIODIC_ADVERTISING 00911 00912 #if BLE_ROLE_CENTRAL 00913 /** 00914 * Initiate a connection to a peer. 00915 * 00916 * Once the connection is established an onConnectionComplete in the event handler 00917 * will be called. 00918 * 00919 * @param peerAddressType 00920 * @param peerAddress 00921 * @param connectionParams 00922 * 00923 * @return BLE_ERROR_NONE if connection establishment procedure is started 00924 * successfully. The connectionCallChain (if set) is invoked upon 00925 * a connection event. 00926 * 00927 * @see EventHandler::onConnectionComplete will be called whether the 00928 * connection process succeed or fail. 00929 * @see EventHandler::onDisconnectionComplete is called when the connection 00930 * ends. 00931 */ 00932 ble_error_t connect( 00933 peer_address_type_t peerAddressType, 00934 const address_t &peerAddress, 00935 const ConnectionParameters &connectionParams 00936 ); 00937 00938 /** Cancel the connection attempt. This is not guaranteed to succeed. As a result 00939 * onConnectionComplete in the event handler will be called. Check the success parameter 00940 * to see if the connection was created. 00941 * 00942 * @return BLE_ERROR_NONE if the connection attempt has been requested to be cancelled. 00943 */ 00944 ble_error_t cancelConnect(); 00945 #endif // BLE_ROLE_CENTRAL 00946 00947 #if BLE_FEATURE_CONNECTABLE 00948 /** 00949 * Update connection parameters of an existing connection. 00950 * 00951 * In the central role, this initiates a Link Layer connection parameter 00952 * update procedure. In the peripheral role, this sends the corresponding 00953 * L2CAP request and waits for the central to accept or reject the requested 00954 * connection parameters. 00955 * 00956 * @param connectionHandle The handle of the connection to update. 00957 * @param minConnectionInterval The minimum connection interval requested. 00958 * @param maxConnectionInterval The maximum connection interval requested. 00959 * @param slaveLatency The slave latency requested. 00960 * @param supervision_timeout The supervision timeout requested. 00961 * @param minConnectionEventLength The minimum connection event length requested. 00962 * @param maxConnectionEventLength The maximum connection event length requested. 00963 * 00964 * @return BLE_ERROR_NONE if the request has been sent and false otherwise. 00965 * 00966 * @see EventHandler::onUpdateConnectionParametersRequest when a central 00967 * receives a request to update the connection parameters. 00968 * @see EventHandler::onConnectionParametersUpdateComplete when connection 00969 * parameters have been updated. 00970 * 00971 * @version 4.0+ for central 00972 * @version 4.1+ for peripheral 00973 */ 00974 ble_error_t updateConnectionParameters( 00975 connection_handle_t connectionHandle, 00976 conn_interval_t minConnectionInterval, 00977 conn_interval_t maxConnectionInterval, 00978 slave_latency_t slaveLatency, 00979 supervision_timeout_t supervision_timeout, 00980 conn_event_length_t minConnectionEventLength = conn_event_length_t(0), 00981 conn_event_length_t maxConnectionEventLength = conn_event_length_t(0) 00982 ); 00983 00984 /** 00985 * Allows the application to accept or reject a connection parameters update 00986 * request. 00987 * 00988 * If this process is managed by the middleware; new connection parameters 00989 * from a slave are always accepted. 00990 * 00991 * @param userManageConnectionUpdateRequest true to let the application 00992 * manage the process and false to let the middleware manage it. 00993 * 00994 * @return BLE_ERROR_NONE in case of success or an appropriate error code. 00995 * 00996 * @version 4.1+ 00997 * 00998 * @see EventHandler::onUpdateConnectionParametersRequest when a central 00999 * receives a request to update the connection parameters. 01000 * 01001 * @see acceptConnectionParametersUpdate to accept the request. 01002 * @see rejectConnectionParametersUpdate to reject the request. 01003 */ 01004 ble_error_t manageConnectionParametersUpdateRequest( 01005 bool userManageConnectionUpdateRequest 01006 ); 01007 01008 /** 01009 * Accept update of the connection parameters. 01010 * 01011 * The central can adjust the new connection parameters. 01012 * 01013 * @param connectionHandle The handle of the connection that has initiated 01014 * the request. 01015 * @param minConnectionInterval The minimum connection interval to be applied. 01016 * @param maxConnectionInterval The maximum connection interval to be applied. 01017 * @param slaveLatency The slave latency to be applied. 01018 * @param supervision_timeout The supervision timeout to be applied. 01019 * @param minConnectionEventLength The minimum connection event length to be 01020 * applied. 01021 * @param maxConnectionEventLength The maximum connection event length to be 01022 * applied. 01023 * 01024 * @return BLE_ERROR_NONE in case of success or an appropriate error code. 01025 * 01026 * @version 4.1+ 01027 * 01028 * @see manageConnectionParametersUpdateRequest To let the application 01029 * manage the process. 01030 * 01031 * @see EventHandler::onUpdateConnectionParametersRequest Called when a 01032 * request to update the connection parameters is received. 01033 * 01034 * @see EventHandler::onConnectionParametersUpdateComplete Called when the 01035 * new connection parameters are effective. 01036 */ 01037 ble_error_t acceptConnectionParametersUpdate( 01038 connection_handle_t connectionHandle, 01039 conn_interval_t minConnectionInterval, 01040 conn_interval_t maxConnectionInterval, 01041 slave_latency_t slaveLatency, 01042 supervision_timeout_t supervision_timeout, 01043 conn_event_length_t minConnectionEventLength = conn_event_length_t(0), 01044 conn_event_length_t maxConnectionEventLength = conn_event_length_t(0) 01045 ); 01046 01047 /** 01048 * Reject a request to change the connection parameters. 01049 * 01050 * @param connectionHandle The handle of the connection that has initiated 01051 * the request. 01052 * 01053 * @return BLE_ERROR_NONE in case of success or an appropriate error code. 01054 * 01055 * @version 4.1+ 01056 * 01057 * @see manageConnectionParametersUpdateRequest To let the application 01058 * manage the process. 01059 * 01060 * @see EventHandler::onUpdateConnectionParametersRequest Called when a 01061 * request to update the connection parameters is received. 01062 */ 01063 ble_error_t rejectConnectionParametersUpdate( 01064 connection_handle_t connectionHandle 01065 ); 01066 01067 /** 01068 * Initiate a disconnection procedure. 01069 * 01070 * Once the disconnection procedure has completed a 01071 * DisconnectionCallbackParams_t, the event is emitted to handlers that 01072 * have been registered with onDisconnection(). 01073 * 01074 * @param[in] reason Reason of the disconnection transmitted to the peer. 01075 * @param[in] connectionHandle Handle of the connection to end. 01076 * 01077 * @return BLE_ERROR_NONE if the disconnection procedure successfully 01078 * started. 01079 * 01080 * @see EventHandler::onDisconnectionComplete when the disconnection is 01081 * effective. 01082 */ 01083 ble_error_t disconnect( 01084 connection_handle_t connectionHandle, 01085 local_disconnection_reason_t reason 01086 ); 01087 #endif // BLE_FEATURE_CONNECTABLE 01088 #if BLE_FEATURE_PHY_MANAGEMENT 01089 /** 01090 * Read the PHY used by the transmitter and the receiver on a connection. 01091 * 01092 * Once the PHY has been read, it is reported back via the function onPhyRead 01093 * of the event handler registered by the application. 01094 * 01095 * @param connection Handle of the connection for which the PHY being used is 01096 * queried. 01097 * 01098 * @return BLE_ERROR_NONE if the read PHY procedure has been started or an 01099 * appropriate error code. 01100 * 01101 * @version 5+ 01102 * 01103 * @see EventHandler::onReadPhy is called when the phy has been read. 01104 */ 01105 ble_error_t readPhy(connection_handle_t connection); 01106 01107 /** 01108 * Set the preferred PHYs to use in a connection. 01109 * 01110 * @param txPhys: Set of PHYs preferred for tx operations. If NULL then no 01111 * preferred PHYs are set and the default value of the subsystem is used. 01112 * 01113 * @param rxPhys: Set of PHYs preferred for rx operations. If NULL then no 01114 * preferred PHYs are set and the default value of the subsystem is used. 01115 * 01116 * @return BLE_ERROR_NONE if the preferences have been set or an appropriate 01117 * error code. 01118 * 01119 * @version 5+ 01120 */ 01121 ble_error_t setPreferredPhys( 01122 const phy_set_t *txPhys, 01123 const phy_set_t *rxPhys 01124 ); 01125 01126 /** 01127 * Update the PHY used by a connection. 01128 * 01129 * Once the update process has been completed, it is reported back to the 01130 * application via the function onPhyUpdateComplete of the event handler 01131 * registered by the application. 01132 * 01133 * @param connection Handle of the connection to update. 01134 * 01135 * @param txPhys Set of PHYs preferred for tx operations. If NULL then the 01136 * choice is up to the Bluetooth subsystem. 01137 * 01138 * @param rxPhys Set of PHYs preferred for rx operations. If NULL then the 01139 * choice is up to the Bluetooth subsystem. 01140 * 01141 * @param codedSymbol Number of symbols used to code a bit when le coded is 01142 * used. If the value is UNDEFINED then the choice is up to the Bluetooth 01143 * subsystem. 01144 * 01145 * @return BLE_ERROR_NONE if the update PHY procedure has been successfully 01146 * started or an error code. 01147 * 01148 * @see EventHandler::onPhyUpdateComplete is called when the phy used by the 01149 * connection has been updated. 01150 */ 01151 ble_error_t setPhy( 01152 connection_handle_t connection, 01153 const phy_set_t *txPhys, 01154 const phy_set_t *rxPhys, 01155 coded_symbol_per_bit_t codedSymbol 01156 ); 01157 #endif // BLE_FEATURE_PHY_MANAGEMENT 01158 01159 /** 01160 * Default peripheral privacy configuration. 01161 */ 01162 static const peripheral_privacy_configuration_t 01163 default_peripheral_privacy_configuration; 01164 01165 /** 01166 * Default peripheral privacy configuration. 01167 */ 01168 static const central_privay_configuration_t 01169 default_central_privacy_configuration; 01170 01171 01172 #if BLE_FEATURE_PRIVACY 01173 /** 01174 * Enable or disable privacy mode of the local device. 01175 * 01176 * When privacy is enabled, the system use private addresses while it scans, 01177 * advertises or initiate a connection. The device private address is 01178 * renewed every 15 minutes. 01179 * 01180 * @par Configuration 01181 * 01182 * The privacy feature can be configured with the help of the functions 01183 * setPeripheralPrivacyConfiguration and setCentralPrivacyConfiguration 01184 * which respectively set the privacy configuration of the peripheral and 01185 * central role. 01186 * 01187 * @par Default configuration of peripheral role 01188 * 01189 * By default private resolvable addresses are used for all procedures; 01190 * including advertisement of nonconnectable packets. Connection request 01191 * from an unknown initiator with a private resolvable address triggers the 01192 * pairing procedure. 01193 * 01194 * @par Default configuration of central role 01195 * 01196 * By default private resolvable addresses are used for all procedures; 01197 * including active scanning. Addresses present in advertisement packet are 01198 * resolved and advertisement packets are forwarded to the application 01199 * even if the advertiser private address is unknown. 01200 * 01201 * @param[in] enable Should be set to true to enable the privacy mode and 01202 * false to disable it. 01203 * 01204 * @return BLE_ERROR_NONE in case of success or an appropriate error code. 01205 */ 01206 ble_error_t enablePrivacy(bool enable); 01207 01208 #if BLE_ROLE_BROADCASTER 01209 /** 01210 * Set the privacy configuration used by the peripheral role. 01211 * 01212 * @param[in] configuration The configuration to set. 01213 * 01214 * @return BLE_ERROR_NONE in case of success or an appropriate error code. 01215 */ 01216 ble_error_t setPeripheralPrivacyConfiguration( 01217 const peripheral_privacy_configuration_t *configuration 01218 ); 01219 01220 /** 01221 * Get the privacy configuration used by the peripheral role. 01222 * 01223 * @param[out] configuration The variable filled with the current 01224 * configuration. 01225 * 01226 * @return BLE_ERROR_NONE in case of success or an appropriate error code. 01227 */ 01228 ble_error_t getPeripheralPrivacyConfiguration( 01229 peripheral_privacy_configuration_t *configuration 01230 ); 01231 #endif // BLE_ROLE_BROADCASTER 01232 01233 #if BLE_ROLE_OBSERVER 01234 /** 01235 * Set the privacy configuration used by the central role. 01236 * 01237 * @param[in] configuration The configuration to set. 01238 * 01239 * @return BLE_ERROR_NONE in case of success or an appropriate error code. 01240 */ 01241 ble_error_t setCentralPrivacyConfiguration( 01242 const central_privay_configuration_t *configuration 01243 ); 01244 01245 /** 01246 * Get the privacy configuration used by the central role. 01247 * 01248 * @param[out] configuration The variable filled with the current 01249 * configuration. 01250 * 01251 * @return BLE_ERROR_NONE in case of success or an appropriate error code. 01252 */ 01253 ble_error_t getCentralPrivacyConfiguration( 01254 central_privay_configuration_t *configuration 01255 ); 01256 #endif // BLE_ROLE_OBSERVER 01257 #endif // BLE_FEATURE_PRIVACY 01258 01259 #if !defined(DOXYGEN_ONLY) 01260 protected: 01261 /** Can only be called if use_non_deprecated_scan_api() hasn't been called. 01262 * This guards against mixed use of deprecated and nondeprecated API. 01263 */ 01264 void useVersionOneAPI() const; 01265 01266 /** Can only be called if use_deprecated_scan_api() hasn't been called. 01267 * This guards against mixed use of deprecated and nondeprecated API. 01268 */ 01269 void useVersionTwoAPI() const; 01270 01271 /** 01272 * Construct a Gap instance. 01273 */ 01274 Gap(); 01275 01276 /* ----------------- API to override in derived class -------------- */ 01277 01278 bool isFeatureSupported_(controller_supported_features_t feature); 01279 uint8_t getMaxAdvertisingSetNumber_(); 01280 uint16_t getMaxAdvertisingDataLength_(); 01281 uint16_t getMaxConnectableAdvertisingDataLength_(); 01282 uint16_t getMaxActiveSetAdvertisingDataLength_(); 01283 ble_error_t createAdvertisingSet_( 01284 advertising_handle_t *handle, 01285 const AdvertisingParameters ¶meters 01286 ); 01287 ble_error_t destroyAdvertisingSet_(advertising_handle_t handle); 01288 ble_error_t setAdvertisingParameters_( 01289 advertising_handle_t handle, 01290 const AdvertisingParameters ¶ms 01291 ); 01292 ble_error_t setAdvertisingPayload_( 01293 advertising_handle_t handle, 01294 mbed::Span<const uint8_t> payload 01295 ); 01296 ble_error_t setAdvertisingScanResponse_( 01297 advertising_handle_t handle, 01298 mbed::Span<const uint8_t> response 01299 ); 01300 ble_error_t startAdvertising_( 01301 advertising_handle_t handle, 01302 adv_duration_t maxDuration, 01303 uint8_t maxEvents 01304 ); 01305 ble_error_t stopAdvertising_(advertising_handle_t handle); 01306 bool isAdvertisingActive_(advertising_handle_t handle); 01307 ble_error_t setPeriodicAdvertisingParameters_( 01308 advertising_handle_t handle, 01309 periodic_interval_t periodicAdvertisingIntervalMin, 01310 periodic_interval_t periodicAdvertisingIntervalMax, 01311 bool advertiseTxPower 01312 ); 01313 ble_error_t setPeriodicAdvertisingPayload_( 01314 advertising_handle_t handle, 01315 mbed::Span<const uint8_t> payload 01316 ); 01317 ble_error_t startPeriodicAdvertising_(advertising_handle_t handle); 01318 ble_error_t stopPeriodicAdvertising_(advertising_handle_t handle); 01319 bool isPeriodicAdvertisingActive_(advertising_handle_t handle); 01320 ble_error_t setScanParameters_(const ScanParameters ¶ms); 01321 ble_error_t startScan_( 01322 scan_duration_t duration, 01323 duplicates_filter_t filtering, 01324 scan_period_t period 01325 ); 01326 ble_error_t stopScan_(); 01327 ble_error_t createSync_( 01328 peer_address_type_t peerAddressType, 01329 const address_t &peerAddress, 01330 uint8_t sid, 01331 slave_latency_t maxPacketSkip, 01332 sync_timeout_t timeout 01333 ); 01334 ble_error_t createSync_( 01335 slave_latency_t maxPacketSkip, 01336 sync_timeout_t timeout 01337 ); 01338 ble_error_t cancelCreateSync_(); 01339 ble_error_t terminateSync_(periodic_sync_handle_t handle); 01340 ble_error_t addDeviceToPeriodicAdvertiserList_( 01341 peer_address_type_t peerAddressType, 01342 const address_t &peerAddress, 01343 advertising_sid_t sid 01344 ); 01345 ble_error_t removeDeviceFromPeriodicAdvertiserList_( 01346 peer_address_type_t peerAddressType, 01347 const address_t &peerAddress, 01348 advertising_sid_t sid 01349 ); 01350 ble_error_t clearPeriodicAdvertiserList_(); 01351 uint8_t getMaxPeriodicAdvertiserListSize_(); 01352 ble_error_t connect_( 01353 peer_address_type_t peerAddressType, 01354 const address_t &peerAddress, 01355 const ConnectionParameters &connectionParams 01356 ); 01357 ble_error_t cancelConnect_(); 01358 ble_error_t updateConnectionParameters_( 01359 connection_handle_t connectionHandle, 01360 conn_interval_t minConnectionInterval, 01361 conn_interval_t maxConnectionInterval, 01362 slave_latency_t slaveLatency, 01363 supervision_timeout_t supervision_timeout, 01364 conn_event_length_t minConnectionEventLength, 01365 conn_event_length_t maxConnectionEventLength 01366 ); 01367 ble_error_t manageConnectionParametersUpdateRequest_( 01368 bool userManageConnectionUpdateRequest 01369 ); 01370 ble_error_t acceptConnectionParametersUpdate_( 01371 connection_handle_t connectionHandle, 01372 conn_interval_t minConnectionInterval, 01373 conn_interval_t maxConnectionInterval, 01374 slave_latency_t slaveLatency, 01375 supervision_timeout_t supervision_timeout, 01376 conn_event_length_t minConnectionEventLength, 01377 conn_event_length_t maxConnectionEventLength 01378 ); 01379 ble_error_t rejectConnectionParametersUpdate_( 01380 connection_handle_t connectionHandle 01381 ); 01382 ble_error_t disconnect_( 01383 connection_handle_t connectionHandle, 01384 local_disconnection_reason_t reason 01385 ); 01386 ble_error_t readPhy_(connection_handle_t connection); 01387 ble_error_t setPreferredPhys_( 01388 const phy_set_t *txPhys, 01389 const phy_set_t *rxPhys 01390 ); 01391 ble_error_t setPhy_( 01392 connection_handle_t connection, 01393 const phy_set_t *txPhys, 01394 const phy_set_t *rxPhys, 01395 coded_symbol_per_bit_t codedSymbol 01396 ); 01397 ble_error_t enablePrivacy_(bool enable); 01398 ble_error_t setPeripheralPrivacyConfiguration_( 01399 const peripheral_privacy_configuration_t *configuration 01400 ); 01401 ble_error_t getPeripheralPrivacyConfiguration_( 01402 peripheral_privacy_configuration_t *configuration 01403 ); 01404 ble_error_t setCentralPrivacyConfiguration_( 01405 const central_privay_configuration_t *configuration 01406 ); 01407 ble_error_t getCentralPrivacyConfiguration_( 01408 central_privay_configuration_t *configuration 01409 ); 01410 void useVersionOneAPI_() const; 01411 void useVersionTwoAPI_() const; 01412 01413 protected: 01414 /** 01415 * Event handler provided by the application. 01416 */ 01417 EventHandler *_eventHandler; 01418 01419 #endif // !defined(DOXYGEN_ONLY) 01420 }; 01421 01422 /** 01423 * @} 01424 * @} 01425 */ 01426 01427 #if !defined(DOXYGEN_ONLY) 01428 } // namespace interface 01429 #endif 01430 } // namespace ble 01431 01432 #endif //BLE_GAP_GAP_H
Generated on Tue Jul 12 2022 13:54:23 by
