Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PalGap.h Source File

PalGap.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2017-2017 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_PAL_GAP_H_
00018 #define BLE_PAL_GAP_H_
00019 
00020 #include "ble/common/StaticInterface.h"
00021 #include "platform/Callback.h"
00022 #include "ble/pal/GapTypes.h"
00023 #include "GapEvents.h"
00024 #include "blecommon.h"
00025 
00026 namespace ble {
00027 namespace pal {
00028 
00029 template<class Impl>
00030 struct GapEventHandler : StaticInterface<Impl, GapEventHandler> {
00031 
00032     using StaticInterface<Impl, ble::pal::GapEventHandler>::impl;
00033 
00034 public:
00035     /**
00036      * @copydoc Gap::EventHandler::onReadPhy
00037      */
00038     void on_read_phy(
00039         pal::hci_error_code_t status,
00040         connection_handle_t connectionHandle,
00041         ble::phy_t tx_phy,
00042         ble::phy_t rx_phy
00043     ) {
00044         impl ()->on_read_phy_(status, connectionHandle, tx_phy, rx_phy);
00045     }
00046 
00047     /**
00048      * @copydoc Gap::EventHandler::onDataLengthChange
00049      */
00050     void on_data_length_change(
00051         connection_handle_t connection_handle,
00052         uint16_t tx_size,
00053         uint16_t rx_size
00054     ) {
00055         impl ()->on_data_length_change_(connection_handle, tx_size, rx_size);
00056     }
00057 
00058     /**
00059      * @copydoc Gap::EventHandler::onPhyUpdateComplete
00060      */
00061     void on_phy_update_complete(
00062         pal::hci_error_code_t status,
00063         connection_handle_t connection_handle,
00064         ble::phy_t tx_phy,
00065         ble::phy_t rx_phy
00066     ) {
00067         impl ()->on_phy_update_complete_(status, connection_handle, tx_phy, rx_phy);
00068     }
00069 
00070     /**
00071      * Should be invoked by the Gap implementation when an enhanced
00072      * connection complete event happens.
00073      *
00074      * @param status hci_error_code::SUCCESS in case of success or an error
00075      * code.
00076      *
00077      * @param connection_handle The handle of the connection created.
00078      *
00079      * @param own_role Indicate if the local device operates as slave or
00080      * master.
00081      *
00082      * @param peer_address_type Type of address of the peer.
00083      *
00084      * @param peer_address Address of the peer connected.
00085      *
00086      * @param local_resolvable_private_address Resolvable private address
00087      * being used by the controller. If not applicable, the address is full
00088      * of zeroes.
00089      *
00090      * @param peer_resolvable_private_address Resolvable private address
00091      * being used by the peer. If not applicable, the address is full of
00092      * zeroes.
00093      *
00094      * @param connection_interval Interval between two connection events.
00095      * Unit is 1.25ms.
00096      *
00097      * @param connection_latency Slave latency for the connection in number
00098      * of connection events.
00099      *
00100      * @param supervision_timeout Connection supervision timeout. Unit is
00101      * 10ms.
00102      *
00103      * @param master_clock_accuracy This parameter is only valid for a slave.
00104      * On a master it must be set to 0x00.
00105      *
00106      * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.10 LE enhanced connection
00107      * complete event.
00108      */
00109     void on_enhanced_connection_complete(
00110         hci_error_code_t status,
00111         connection_handle_t connection_handle,
00112         connection_role_t own_role,
00113         connection_peer_address_type_t peer_address_type,
00114         const address_t &peer_address,
00115         const address_t &local_resolvable_private_address,
00116         const address_t &peer_resolvable_private_address,
00117         uint16_t connection_interval,
00118         uint16_t connection_latency,
00119         uint16_t supervision_timeout,
00120         clock_accuracy_t master_clock_accuracy
00121     ) {
00122         impl ()->on_enhanced_connection_complete_(
00123             status,
00124             connection_handle,
00125             own_role,
00126             peer_address_type,
00127             peer_address,
00128             local_resolvable_private_address,
00129             peer_resolvable_private_address,
00130             connection_interval,
00131             connection_latency,
00132             supervision_timeout,
00133             master_clock_accuracy
00134         );
00135     }
00136 
00137     /** Called on advertising report event.
00138      *
00139      * @param event_type Type of advertising used.
00140      * @param address_type Peer address type of advertiser.
00141      * @param address Peer address of advertiser.
00142      * @param primary_phy PHY used on the primary channels.
00143      * @param secondary_phy PHY used on secondary channels.
00144      * @param advertising_sid Set identification number.
00145      * @param tx_power Transmission power reported by the packet.
00146      * @param rssi Measured signal strength.
00147      * @param periodic_advertising_interval Interval of periodic advertising.
00148      * @param direct_address_type Directed advertising target address type.
00149      * @param direct_address Directed advertising target address.
00150      * @param data_length Advertising payload length.
00151      * @param data Advertising payload.
00152      *
00153      * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.13 LE extended advertising
00154      * report event.
00155      */
00156     void on_extended_advertising_report(
00157         advertising_event_t event_type,
00158         const connection_peer_address_type_t *address_type,
00159         const address_t &address,
00160         phy_t primary_phy,
00161         const phy_t *secondary_phy,
00162         advertising_sid_t advertising_sid,
00163         advertising_power_t tx_power,
00164         rssi_t rssi,
00165         uint16_t periodic_advertising_interval,
00166         direct_address_type_t direct_address_type,
00167         const address_t &direct_address,
00168         uint8_t data_length,
00169         const uint8_t *data_size
00170     ) {
00171         impl ()->on_extended_advertising_report_(
00172             event_type,
00173             address_type,
00174             address,
00175             primary_phy,
00176             secondary_phy,
00177             advertising_sid,
00178             tx_power,
00179             rssi,
00180             periodic_advertising_interval,
00181             direct_address_type,
00182             direct_address,
00183             data_length,
00184             data_size
00185         );
00186     }
00187 
00188     /** Called on advertising sync event.
00189      *
00190      * @param error SUCCESS if synchronisation was achieved.
00191      * @param sync_handle Advertising sync handle.
00192      * @param advertising_sid Advertising set identifier.
00193      * @param advertiser_address_type Peer address type.
00194      * @param advertiser_address Peer address.
00195      * @param advertiser_phy PHY used for advertisements.
00196      * @param periodic_advertising_interval Periodic advertising interval.
00197      * @param clock_accuracy Peer clock accuracy.
00198      */
00199     void on_periodic_advertising_sync_established(
00200         pal::hci_error_code_t error,
00201         pal::sync_handle_t sync_handle,
00202         advertising_sid_t advertising_sid,
00203         connection_peer_address_type_t advertiser_address_type,
00204         const ble::address_t &advertiser_address,
00205         phy_t advertiser_phy,
00206         uint16_t periodic_advertising_interval,
00207         pal::clock_accuracy_t clock_accuracy
00208     ) {
00209         impl ()->on_periodic_advertising_sync_established_(
00210             error,
00211             sync_handle,
00212             advertising_sid,
00213             advertiser_address_type,
00214             advertiser_address,
00215             advertiser_phy,
00216             periodic_advertising_interval,
00217             clock_accuracy
00218         );
00219     }
00220 
00221     /** Called after a periodic advertising report event.
00222      *
00223      * @param sync_handle Periodic advertising sync handle
00224      * @param tx_power TX power.
00225      * @param rssi Received signal strength.
00226      * @param data_status Status to indicate the completeness of the payload.
00227      * @param data_length Periodic advertisement payload length.
00228      * @param data Periodic advertisement payload.
00229      */
00230     void on_periodic_advertising_report(
00231         sync_handle_t sync_handle,
00232         advertising_power_t tx_power,
00233         rssi_t rssi,
00234         advertising_data_status_t data_status,
00235         uint8_t data_length,
00236         const uint8_t *data
00237     ) {
00238         impl ()->on_periodic_advertising_report_(
00239             sync_handle,
00240             tx_power,
00241             rssi,
00242             data_status,
00243             data_length,
00244             data
00245         );
00246     }
00247 
00248     /** Called on periodic advertising sync loss event.
00249      *
00250      * @param sync_handle Advertising sync handle'
00251      */
00252     void on_periodic_advertising_sync_loss(
00253         sync_handle_t sync_handle
00254     ) {
00255         impl ()->on_periodic_advertising_sync_loss_(sync_handle);
00256     }
00257 
00258     /** Called when scanning times out.
00259      */
00260     void on_scan_timeout() {
00261         impl ()->on_scan_timeout_();
00262     }
00263 
00264     /** Called when advertising set stops advertising.
00265      *
00266      * @param status SUCCESS if connection has been established.
00267      * @param advertising_handle Advertising set handle.
00268      * @param advertising_handle Connection handle.
00269      * @param number_of_completed_extended_advertising_events Number of events created during before advertising end.
00270      */
00271     void on_advertising_set_terminated(
00272         hci_error_code_t status,
00273         advertising_handle_t advertising_handle,
00274         connection_handle_t connection_handle,
00275         uint8_t number_of_completed_extended_advertising_events
00276     ) {
00277         impl ()->on_advertising_set_terminated_(
00278             status,
00279             advertising_handle,
00280             connection_handle,
00281             number_of_completed_extended_advertising_events
00282         );
00283     }
00284 
00285     /** Called when a device receives a scan request from an active scanning device.
00286      *
00287      * @param advertising_handle Advertising set handle.
00288      * @param scanner_address_type Peer address type.
00289      * @param address Peer address.
00290      */
00291     void on_scan_request_received(
00292         advertising_handle_t advertising_handle,
00293         connection_peer_address_type_t scanner_address_type,
00294         const address_t &address
00295     ) {
00296         impl ()->on_scan_request_received_(
00297             advertising_handle,
00298             scanner_address_type,
00299             address
00300         );
00301     }
00302 
00303     void on_connection_update_complete(
00304         hci_error_code_t status,
00305         connection_handle_t connection_handle,
00306         uint16_t connection_interval,
00307         uint16_t connection_latency,
00308         uint16_t supervision_timeout
00309     ) {
00310         impl ()->on_connection_update_complete_(
00311             status,
00312             connection_handle,
00313             connection_interval,
00314             connection_latency,
00315             supervision_timeout
00316         );
00317     }
00318 
00319     void on_remote_connection_parameter(
00320         connection_handle_t connection_handle,
00321         uint16_t connection_interval_min,
00322         uint16_t connection_interval_max,
00323         uint16_t connection_latency,
00324         uint16_t supervision_timeout
00325     ) {
00326         impl ()->on_remote_connection_parameter_(
00327             connection_handle,
00328             connection_interval_min,
00329             connection_interval_max,
00330             connection_latency,
00331             supervision_timeout
00332         );
00333     }
00334 };
00335 
00336 /**
00337  * Adaptation interface for the GAP layer.
00338  *
00339  * Define the primitive necessary to realize GAP operations. the API and event
00340  * follow closely the definition of the HCI commands and events used
00341  * by that layer.
00342  */
00343 template<typename Impl, class EventHandler>
00344 struct Gap {
00345 private:
00346 
00347     Impl* impl() {
00348         return static_cast<Impl*>(this);
00349     }
00350 
00351 public:
00352 
00353     /**
00354      * Initialisation of the instance. An implementation can use this function
00355      * to initialise the subsystems needed to realize the operations of this
00356      * interface.
00357      *
00358      * This function has to be called before any other operations.
00359      *
00360      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00361      * appropriate error otherwise.
00362      */
00363     ble_error_t initialize() {
00364         return impl()->initialize_();
00365     }
00366 
00367     /**
00368      * Termination of the instance. An implementation can use this function
00369      * to release the subsystems initialised to realise the operations of
00370      * this interface.
00371      *
00372      * After a call to this function, initialise should be called again to
00373      * allow use of the interface.
00374      *
00375      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00376      * appropriate error otherwise.
00377      */
00378     ble_error_t terminate() {
00379         return impl()->terminate_();
00380     }
00381 
00382     /**
00383      * Return the public device address.
00384      *
00385      * @note The public device address is usually acquired at initialization and
00386      * stored in the instance.
00387      *
00388      * @return the public device address.
00389      */
00390     address_t get_device_address() {
00391         return impl()->get_device_address_();
00392     }
00393 
00394     /**
00395      * Return the current random address.
00396      *
00397      * @note The random address is usually acquired at initialization and stored
00398      * in the instance.
00399      *
00400      * @return the random device address.
00401      */
00402     address_t get_random_address() {
00403         return impl()->get_random_address_();
00404     }
00405 
00406     /**
00407      * Set the random address which will used be during scan, connection or
00408      * advertising process if the own address type selected is random.
00409      *
00410      * Changing the address during scan, connection or advertising process is
00411      * forbiden.
00412      *
00413      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.4 LE set random address command.
00414      *
00415      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00416      * appropriate error otherwise.
00417      */
00418     ble_error_t set_random_address(const address_t &address) {
00419         return impl()->set_random_address_(address);
00420     }
00421 
00422     /**
00423      * Set the random device address used by an advertising set.
00424      *
00425      * @pre No connectable advertising set should be enabled.
00426      *
00427      * @post The new random address should be used when @p advertising_set_handle
00428      * is enabled.
00429      *
00430      * @param advertising_handle Handle to the advertising set that will be
00431      * advertised with the address @p address.
00432      *
00433      * @param address The random address to use when @p advertising_set_handle
00434      * is in use.
00435      *
00436      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00437      * appropriate error otherwise.
00438      *
00439      * @note See Bluetooth 5 Vol 2, Part E: 7.8.52 LE Set Advertising Set Random
00440      * Address Command
00441      */
00442     ble_error_t set_advertising_set_random_address(
00443         advertising_handle_t advertising_handle,
00444         const address_t &address
00445     ) {
00446         return impl()->set_advertising_set_random_address_(
00447             advertising_handle,
00448             address
00449         );
00450     }
00451 
00452     /**
00453      * Set the advertising parameters which will be used during the advertising
00454      * process.
00455      *
00456      * @param advertising_interval_min: Minimum advertising interval which can
00457      * be used during undirected and low duty cycle directed advertising. This
00458      * parameter shall be less than or equal to advertising_interval_max. This
00459      * parameter shall be in the range [0x20 : 0x4000] where each unit is equal
00460      * to 0.625ms.
00461      * This parameter is not used by directed high duty cycle advertising.
00462      *
00463      * @param advertising_interval_max: Maximum advertising interval which can
00464      * be used during undirected and low duty cycle directed advertising. This
00465      * parameter shall be more than or equal to advertising_interval_min. This
00466      * parameter shall be in the range [0x20 : 0x4000] where each unit is equal
00467      * to 0.625ms.
00468      * This parameter is not used by directed high duty cycle advertising.
00469      *
00470      * @param advertising_type Packet type that is used during the
00471      * advertising process. Direct advertising require valid peer addresses
00472      * parameters and ignore the filter policy set.
00473      * If the High duty cycle advertising is used then the advertising parameter
00474      * intervals are ignored.
00475      *
00476      * @param own_address_type Own address type used during advertising.
00477      * If own address type is equal to RESOLVABLE_PRIVATE_ADDRESS_PUBLIC_FALLBACK
00478      * or RESOLVABLE_PRIVATE_ADDRESS_RANDOM_FALLBACK then the peer address
00479      * parameters (type and address) will be used to find the local IRK.
00480      *
00481      * @param peer_address_type Address type of the peer.
00482      * This parameter shall be valid if directed advertising is used (
00483      * ADV_DIRECT_IND or ADV_DIRECT_IND_LOW_DUTY_CYCLE). This parameter should
00484      * be valid if the own address type is equal to 0x02 or 0x03.
00485      * In other cases, this parameter is ignored.
00486      *
00487      * @param peer_address Public device address, Random device addres, Public
00488      * identity address or Random static identity address of the device targeted
00489      * by the advertising.
00490      * This parameter shall be valid if directed advertising is used (
00491      * ADV_DIRECT_IND or ADV_DIRECT_IND_LOW_DUTY_CYCLE). This parameter should
00492      * be valid if the own address type is equal to 0x02 or 0x03.
00493      * In other cases, this parameter is ignored.
00494      *
00495      * @param advertising_channel_map Map of the channel used to send
00496      * advertising data.
00497      *
00498      * @param advertising_filter_policy Filter policy applied during the
00499      * advertising process. The subsystem should use the whitelist to apply the
00500      * policy. This parameter is ignored if the advertising type is directed (
00501      * ADV_DIRECT_IND or ADV_DIRECT_IND_LOW_DUTY_CYCLE).
00502      *
00503      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00504      * appropriate error otherwise.
00505      *
00506      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.5 LE set advertising parameters
00507      * command.
00508      */
00509     ble_error_t set_advertising_parameters(
00510         uint16_t advertising_interval_min,
00511         uint16_t advertising_interval_max,
00512         advertising_type_t advertising_type,
00513         own_address_type_t own_address_type,
00514         advertising_peer_address_type_t peer_address_type,
00515         const address_t &peer_address,
00516         advertising_channel_map_t advertising_channel_map,
00517         advertising_filter_policy_t advertising_filter_policy
00518     ) {
00519         return impl()->set_advertising_parameters_(
00520             advertising_interval_min,
00521             advertising_interval_max,
00522             advertising_type,
00523             own_address_type,
00524             peer_address_type,
00525             peer_address,
00526             advertising_channel_map,
00527             advertising_filter_policy
00528         );
00529     }
00530 
00531     /**
00532      * Define the advertising parameters of an advertising set.
00533      *
00534      * @param advertising_handle Identify the advertising set being configured.
00535      *
00536      * @param event_properties Describe the type of advertising event and its
00537      * properties.
00538      *
00539      * @param primary_advertising_interval_min, primary_advertising_interval_max
00540      * Advertising interval range for undirected and low duty cycle advertising.
00541      * This parameter is not considered if @p event_properties.high_duty_cycle is
00542      * set.
00543      *
00544      * @param primary_advertising_channel_map Map of the advertising channel to
00545      * use while advertising.
00546      *
00547      * @param own_address_type The type of address being used by the local
00548      * controller. If this parameter is a resolvable address then the peer
00549      * address should be an identity address.
00550      *
00551      * @param peer_address_type, peer_address Address of the peer. This parameter
00552      * is not evaluated if @p event_properties.directed is not set.
00553      *
00554      * @param advertising_filter_policy Filter applied to scan and connection
00555      * requests. It is ignored for directed advertising (@p
00556      * event_properties.directed set).
00557      *
00558      * @param advertising_power Maximum power level used during advertising.
00559      * The controller select a power level lower than or equal to this value.
00560      * The special value 127 should be used if the host as no preference towards
00561      * the transmit power used.
00562      *
00563      * @param primary_advertising_phy PHY used to transmit data on the primary
00564      * advertising channel. Accepted values are: phy_t::LE_1M and phy_t::LE_CODED.
00565      *
00566      * @param secondary_advertising_max_skip Maximum number of advertising events
00567      * that can be skipped before the AUX_ADV_IND can be sent.
00568      *
00569      * @param secondary_phy PHY used to transmit data on the secondary advertising
00570      * channel.
00571      *
00572      * @param advertising_sid 4bit value identifying the advertising set over the
00573      * air. It is not used by legacy advertising.
00574      *
00575      * @param scan_request_notification Indicate if the host wants to receive
00576      * scan request notification events.
00577      *
00578      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00579      * appropriate error otherwise.
00580      *
00581      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.53 LE Set Extended Advertising
00582      * Parameters Command.
00583      *
00584      * @note If the advertising set does not exist on the controller, it is
00585      * created.
00586      *
00587      * @pre @p advertising_handle should not be enabled when this command is
00588      * issued.
00589      */
00590     ble_error_t set_extended_advertising_parameters(
00591         advertising_handle_t advertising_handle,
00592         advertising_event_properties_t event_properties,
00593         advertising_interval_t primary_advertising_interval_min,
00594         advertising_interval_t primary_advertising_interval_max,
00595         advertising_channel_map_t primary_advertising_channel_map,
00596         own_address_type_t own_address_type,
00597         advertising_peer_address_type_t peer_address_type,
00598         const address_t &peer_address,
00599         advertising_filter_policy_t advertising_filter_policy,
00600         advertising_power_t advertising_power,
00601         phy_t primary_advertising_phy,
00602         uint8_t secondary_advertising_max_skip,
00603         phy_t secondary_phy,
00604         uint8_t advertising_sid,
00605         bool scan_request_notification
00606     ) {
00607         return impl()->set_extended_advertising_parameters_(
00608             advertising_handle,
00609             event_properties,
00610             primary_advertising_interval_min,
00611             primary_advertising_interval_max,
00612             primary_advertising_channel_map,
00613             own_address_type,
00614             peer_address_type,
00615             peer_address,
00616             advertising_filter_policy,
00617             advertising_power,
00618             primary_advertising_phy,
00619             secondary_advertising_max_skip,
00620             secondary_phy,
00621             advertising_sid,
00622             scan_request_notification
00623         );
00624     }
00625 
00626     /**
00627      * Configure periodic advertising parameters of an advertising set.
00628      *
00629      * @pre The advertising handle must exist on the controller @see
00630      * set_extended_advertising_parameters .
00631      *
00632      * @pre Periodic advertising of @p advertising_handle should not be enabled
00633      * when this function is called.
00634      *
00635      * @pre The advertising set identified by @p advertising_handle should not
00636      * be configured as anonymous advertising.
00637      *
00638      * @param advertising_handle The advertising set being configured.
00639      *
00640      * @param periodic_advertising_min, periodic_advertising_max Advertising
00641      * interval range for periodic advertising of this set.
00642      *
00643      * @param advertise_power If true, the transmission power should be included
00644      * in the advertising PDU.
00645      *
00646      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00647      * appropriate error otherwise.
00648      *
00649      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.61 LE Set Periodic Advertising
00650      * Parameters Command
00651      */
00652     ble_error_t set_periodic_advertising_parameters(
00653         advertising_handle_t advertising_handle,
00654         periodic_advertising_interval_t periodic_advertising_min,
00655         periodic_advertising_interval_t periodic_advertising_max,
00656         bool advertise_power
00657     ) {
00658         return impl()->set_periodic_advertising_parameters_(
00659             advertising_handle,
00660             periodic_advertising_min,
00661             periodic_advertising_max,
00662             advertise_power
00663         );
00664     }
00665 
00666     /**
00667      * Set the data sends in advertising packet. If the advertising is
00668      * currently enabled, the data shall be used when a new advertising packet
00669      * is issued.
00670      *
00671      * @param advertising_data_length Number of significant bytes in the
00672      * advertising data.
00673      *
00674      * @param advertising_data The data sends in advertising packets. Non
00675      * significant bytes shall be equal to 0.
00676      *
00677      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00678      * appropriate error otherwise.
00679      *
00680      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.5 LE set advertising data
00681      * command.
00682      */
00683     ble_error_t set_advertising_data(
00684         uint8_t advertising_data_length,
00685         const advertising_data_t &advertising_data
00686     ) {
00687         return impl()->set_advertising_data_(
00688             advertising_data_length,
00689             advertising_data
00690         );
00691     }
00692 
00693     /**
00694      * Set data in advertising PDUs.
00695      *
00696      * @note this command can be called at anytime, whether the advertising set
00697      * is enabled or not.
00698      *
00699      * @note the extended scan response can be set in one or more command.
00700      *
00701      * @pre @p advertising_handle should exist. To create it call
00702      * set_extended_scan_parameters.
00703      *
00704      * @post The data inserted is used for subsequent advertising events.
00705      *
00706      * @param advertising_handle The handle identifying the advertising set
00707      * associated with the data.
00708      *
00709      * @param operation Description of the operation to apply to @p
00710      * advertising_handle data.
00711      *
00712      * @param minimize_fragmentation Hint for the controller to minimize
00713      * fragmentation of data sent over the air.
00714      *
00715      * @param advertising_data_size, advertising_data The data to associate to @p
00716      * advertising_handle.
00717      *
00718      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00719      * appropriate error otherwise.
00720      *
00721      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.54 LE set extended advertising
00722      * data command.
00723      */
00724     ble_error_t set_extended_advertising_data(
00725         advertising_handle_t advertising_handle,
00726         advertising_fragment_description_t operation,
00727         bool minimize_fragmentation,
00728         uint8_t advertising_data_size,
00729         const uint8_t *advertising_data
00730     ) {
00731         return impl()->set_extended_advertising_data_(
00732             advertising_handle,
00733             operation,
00734             minimize_fragmentation,
00735             advertising_data_size,
00736             advertising_data
00737         );
00738     }
00739 
00740     /**
00741      * Set the data used in periodic advertising PDUs.
00742      *
00743      * @note the extended scan response can be set in one or more command.
00744      *
00745      * @pre @p advertising_handle must exist. See set_extended_advertising_parameters.
00746      *
00747      * @pre @p advertising_handle must be configured for periodic advertising.
00748      * See set_periodic_advertising_parameters .
00749      *
00750      * @param advertising_handle The handle identifying the advertising set
00751      * associated with the data.
00752      *
00753      * @param fragment_description Description of the operation to apply to @p
00754      * advertising_handle data.
00755      *
00756      * @param advertising_data_size, advertising_data The data to associate to @p
00757      * advertising_handle.
00758      *
00759      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00760      * appropriate error otherwise.
00761      *
00762      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.62 LE set periodic advertising
00763      * data command.
00764      */
00765     ble_error_t set_periodic_advertising_data(
00766         advertising_handle_t advertising_handle,
00767         advertising_fragment_description_t fragment_description,
00768         uint8_t advertising_data_size,
00769         const uint8_t *advertising_data
00770     ) {
00771         return impl()->set_periodic_advertising_data_(
00772             advertising_handle,
00773             fragment_description,
00774             advertising_data_size,
00775             advertising_data
00776         );
00777     }
00778 
00779     /**
00780      * Set the data sends in scan response packets. If the advertising is
00781      * currently enabled, the data shall be used when a new scan response is
00782      * issued.
00783      *
00784      * @param scan_response_data_length Number of significant bytes in the
00785      * scan response data.
00786      *
00787      * @param scan_response_data The data sends in scan response packets. Non
00788      * significant bytes shall be equal to 0.
00789      *
00790      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00791      * appropriate error otherwise.
00792      *
00793      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.8 LE set scan response data
00794      * command.
00795      */
00796     ble_error_t set_scan_response_data(
00797         uint8_t scan_response_data_length,
00798         const advertising_data_t &scan_response_data
00799     ) {
00800         return impl()->set_scan_response_data_(
00801             scan_response_data_length,
00802             scan_response_data
00803         );
00804     }
00805 
00806     /**
00807      * Set the data sends in extended scan response packets.  If the advertising
00808      * is currently enabled, the data shall be used when a new extended scan
00809      * response is issued.
00810      *
00811      * @note the extended scan response can be set in one or more command.
00812      *
00813      * @param advertising_handle The advertising handle that owns the scan
00814      * response data.
00815      *
00816      * @param operation Description of the operation to apply to @p
00817      * advertising_handle data.
00818      *
00819      * @param minimize_fragmentation Hint for the controller to minimize
00820      * fragmentation of data sent over the air.
00821      *
00822      * @param scan_response_data_size, scan_response_data The data to associate
00823      * to @p advertising_handle.
00824      *
00825      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00826      * appropriate error otherwise.
00827      *
00828      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.55 LE set extended scan response
00829      * data command.
00830      */
00831     ble_error_t set_extended_scan_response_data(
00832         advertising_handle_t advertising_handle,
00833         advertising_fragment_description_t operation,
00834         bool minimize_fragmentation,
00835         uint8_t scan_response_data_size,
00836         const uint8_t *scan_response_data
00837     ) {
00838         return impl()->set_extended_scan_response_data_(
00839             advertising_handle,
00840             operation,
00841             minimize_fragmentation,
00842             scan_response_data_size,
00843             scan_response_data
00844         );
00845     }
00846 
00847     /**
00848      * Start or stop advertising.
00849      *
00850      * The process use advertising and scan response data set with
00851      * set_advertising_data and set_scan_response_data while the parameters used
00852      * are the one set by set_advertising_parameters.
00853      *
00854      * The advertising shall continue until:
00855      *     - The advertising is manually disabled (advertising_enable(false)).
00856      *     - A connection is created.
00857      *     - Time out in case of high duty cycle directed advertising.
00858      *
00859      * If the random address has not been set and the advertising parameter
00860      * own_address_type is set to 0x01 then the procedure shall fail.
00861      *
00862      * If the random address has not been set and the advertising parameter
00863      * own_address_type is set to RESOLVABLE_PRIVATE_ADDRESS_RANDOM_FALLBACK and
00864      * the peer address is not in the resolving list then the procedure shall
00865      * fail.
00866      *
00867      * @param enable If true start the advertising process, if the process was
00868      * already runing and own_address_type is equal to 0x02 or 0x03, the
00869      * subsystem can change the random address.
00870      * If false and the advertising is running then the process should be
00871      * stoped.
00872      *
00873      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00874      * appropriate error otherwise.
00875      *
00876      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.9 LE set advertising enable
00877      * command.
00878      *
00879      * @note If the advertising type is ADV_DIRECT_IND and the connection is not
00880      * created during the time allowed to the procedure then a
00881      * ConnectionComplete event shall be emmited with its error code set to
00882      * ADVERTISING_TIMEOUT.
00883      *
00884      * @note Successfull connection shall emit a ConnectionComplete event. It
00885      * also means advertising is disabled.
00886      */
00887     ble_error_t advertising_enable(bool enable) {
00888         return impl()->advertising_enable_(enable);
00889     }
00890 
00891     /**
00892      * Start of stop advertising of extended advertising sets.
00893      *
00894      * @pre advertising handles present in @p handles must exist.
00895      *
00896      * @pre advertising or scan response data must be complete for advertising
00897      * handles in @p handles.
00898      *
00899      * @note Disabling the advertising set identified by @p handle[i] does not
00900      * disable any periodic advertising associated with that set.
00901      *
00902      * @param enable If true, start advertising of the advertising sets pointed
00903      * by @p handles. If false stop advertising for the advertising sets pointed
00904      * by @p handles.
00905      *
00906      * @param number_of_sets Number of advertising sets concerned by the operation.
00907      * @p handles, @p durations and @p max_extended_advertising_events should
00908      * contain @p number_of_sets elements.
00909      *
00910      * @param handles Handle of advertising sets to start or stop.
00911      *
00912      * @param durations Advertising duration for @p handle. The unit is 10ms and
00913      * the special value 0x000 disable advertising timeout.
00914      *
00915      * @param max_extended_advertising_events Maximum number of extended
00916      * advertising events the controller must attempt to send prior to
00917      * terminating the extended advertising. The special value 0 indicate that
00918      * there is no maximum.
00919      *
00920      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00921      * appropriate error otherwise.
00922      *
00923      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.56 LE extended advertising enable
00924      * command.
00925      */
00926     ble_error_t extended_advertising_enable(
00927         bool enable,
00928         uint8_t number_of_sets,
00929         const advertising_handle_t *handles,
00930         const uint16_t *durations,
00931         const uint8_t *max_extended_advertising_events
00932     ) {
00933         return impl()->extended_advertising_enable_(
00934             enable,
00935             number_of_sets,
00936             handles,
00937             durations,
00938             max_extended_advertising_events
00939         );
00940     }
00941 
00942     /**
00943      * Enable or disable periodic advertising of an advertising set.
00944      *
00945      * @param enable If true enable periodic advertising of @p advertising_handle
00946      * otherwise disable it.
00947      *
00948      * @param advertising_handle Handle to the advertising set to enable or
00949      * disable.
00950      *
00951      * @return BLE_ERROR_NONE if the request has been successfully sent or the
00952      * appropriate error otherwise.
00953      *
00954      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.63 LE periodic advertising enable
00955      * command.
00956      */
00957     ble_error_t periodic_advertising_enable(
00958         bool enable,
00959         advertising_handle_t advertising_handle
00960     ) {
00961         return impl()->periodic_advertising_enable_(enable, advertising_handle);
00962     }
00963 
00964     /**
00965      * Query the maximum data length the controller supports in an advertising
00966      * set.
00967      *
00968      * @return The length in byte the controller can support in an advertising
00969      * set.
00970      *
00971      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.57 LE read maximum advertising
00972      * data length command.
00973      */
00974     uint16_t get_maximum_advertising_data_length() {
00975         return impl()->get_maximum_advertising_data_length_();
00976     }
00977 
00978     /**
00979      * Query the maximum data length the controller supports in an advertising set
00980      * using connectable advertising.
00981      *
00982      * @return The length in byte the controller can support in an advertising set
00983      * for connectable advertising.
00984      */
00985     uint16_t get_maximum_connectable_advertising_data_length() {
00986         return impl()->get_maximum_connectable_advertising_data_length_();
00987     }
00988 
00989     /**
00990      * Query the maximum payload length for a single HCI packet carrying partial
00991      * (or complete if it fits) data for advertising set.
00992      *
00993      * @return Max size of the HCI packet transporting the data.
00994      */
00995     uint8_t get_maximum_hci_advertising_data_length() {
00996         return impl()->get_maximum_hci_advertising_data_length_();
00997     }
00998 
00999     /**
01000      * Query the maximum number of concurrent advertising sets that is supported
01001      * by the controller.
01002      *
01003      * @return The number of concurrent advertising sets supported by the
01004      * controller.
01005      *
01006      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.58 LE number of supported
01007      * advertising sets command.
01008      */
01009     uint8_t get_max_number_of_advertising_sets() {
01010         return impl()->get_max_number_of_advertising_sets_();
01011     }
01012 
01013     /**
01014      * Remove an advertising set from the controller.
01015      *
01016      * After this operation, configuration and data associated with @p
01017      * advertising_handle are lost.
01018      *
01019      * @pre @p advertising_handle must exist.
01020      *
01021      * @pre Advertising of @p advertising_handle must be disabled.
01022      *
01023      * @param advertising_handle The advertising handle to destroy.
01024      *
01025      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01026      * appropriate error otherwise.
01027      *
01028      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.59 LE remove advertising set
01029      * command.
01030      */
01031     ble_error_t remove_advertising_set(
01032         advertising_handle_t advertising_handle
01033     ) {
01034         return impl()->remove_advertising_set_(advertising_handle);
01035     }
01036 
01037     /**
01038      * Remove all advertising sets maintained by the controller.
01039      *
01040      * @pre Advertising of all advertising sets must be disabled.
01041      *
01042      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01043      * appropriate error otherwise.
01044      *
01045      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.60 LE clear advertising sets
01046      * command.
01047      */
01048     ble_error_t clear_advertising_sets() {
01049         return impl()->clear_advertising_sets_();
01050     }
01051 
01052 
01053     /**
01054      * Set the parameter of the scan process.
01055      *
01056      * This command shall not be effective when the scanning process is running.
01057      *
01058      * @param active_scanning If true the subsystem does active scanning and
01059      * the bluetooth subsystem shall send scanning PDUs. It shall also listen
01060      * to scan responses. If false no scanning PDUs are sent during the scan
01061      * process.
01062      *
01063      * @param scan_interval The time interval between two subsequent LE scans in
01064      * unit of 0.625ms. This parameter shall be in the range [0x0004 : 0x4000].
01065      *
01066      * @param scan_window Duration of the LE scan. It shall be less than or
01067      * equal to scan_interval value. This parameter shall be in the range
01068      * [0x0004 : 0x4000] and is in unit of 0.625ms.
01069      *
01070      * @param own_address_type Own address type used in scan request packets.
01071      *
01072      * @param filter_policy Filter policy applied when scanning.
01073      *
01074      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01075      * appropriate error otherwise.
01076      *
01077      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.10 LE set scan parameters
01078      * command.
01079      */
01080     ble_error_t set_scan_parameters(
01081         bool active_scanning,
01082         uint16_t scan_interval,
01083         uint16_t scan_window,
01084         own_address_type_t own_address_type,
01085         scanning_filter_policy_t filter_policy
01086     ) {
01087         return impl()->set_scan_parameters_(
01088             active_scanning,
01089             scan_interval,
01090             scan_window,
01091             own_address_type,
01092             filter_policy
01093         );
01094     }
01095 
01096     /**
01097      * Set extended scan parameters to be used on advertising channels.
01098      *
01099      * @param own_address_type Type of the address used in scan requests.
01100      *
01101      * @param filter_policy Scanning filter policy.
01102      *
01103      * @param scanning_phys The phy affected by the parameter change. Just
01104      * LE_1M and LE_CODED can be set. If two phys are set then @p active_scanning,
01105      * @p scan_interval and @p scan_window must contain two elements. The first
01106      * being applied to LE_1M and the second being applied to LE_CODED.
01107      *
01108      * @param active_scanning If true, active scanning is used for the
01109      * correcponding PHY.
01110      *
01111      * @param scan_interval Interval between two subsequent scan. This parameter
01112      * shall be in the range [0x0004 : 0x4000] and is in unit of 0.625ms.
01113      *
01114      * @param scan_window Duration of the LE scan. It shall be less than or
01115      * equal to scan_interval value. This parameter shall be in the range
01116      * [0x0004 : 0x4000] and is in unit of 0.625ms.
01117      *
01118      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01119      * appropriate error otherwise.
01120      *
01121      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.64 LE set extended scan parameters
01122      * command.
01123      */
01124     ble_error_t set_extended_scan_parameters(
01125         own_address_type_t own_address_type,
01126         scanning_filter_policy_t filter_policy,
01127         phy_set_t scanning_phys,
01128         const bool *active_scanning,
01129         const uint16_t *scan_interval,
01130         const uint16_t *scan_window
01131     ) {
01132         return impl()->set_extended_scan_parameters_(
01133             own_address_type,
01134             filter_policy,
01135             scanning_phys,
01136             active_scanning,
01137             scan_interval,
01138             scan_window
01139         );
01140     }
01141 
01142     /**
01143      * Start/stop scanning process.
01144      *
01145      * Parameters of the scanning process shall be set before the scan launch
01146      * by using the function set_scan_parameters.
01147      *
01148      * @parameter enable Start the scanning process if true and stop it if
01149      * false. If the scan process is already started, enabling it again will
01150      * only update the duplicate filtering; based on the new parameter.
01151      *
01152      * @parameter filter_duplicates Enable duplicate filtering if true,
01153      * otherwise disable it.
01154      *
01155      * @attention advertising data or scan response data is not considered
01156      * significant when determining duplicate advertising reports.
01157      *
01158      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01159      * appropriate error otherwise.
01160      *
01161      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.11 LE set scan enable command.
01162      */
01163     ble_error_t scan_enable(
01164         bool enable,
01165         bool filter_duplicates
01166     ) {
01167         return impl()->scan_enable_(enable, filter_duplicates);
01168     }
01169 
01170     /**
01171      * Enable or disable extended scanning.
01172      *
01173      * @param enable If true enable scanning and disable it otherwise.
01174      *
01175      * @param filter_duplicates If true filter out duplicate scan reports.
01176      *
01177      * @param duration Duration of the scan operation. The unit is 10ms and
01178      * the special value 0 indicate continuous scan until explicitly disabled.
01179      *
01180      * @param period Interval between two scan operations. The unit is 1.28s and
01181      * the special value 0 can be used to disable periodic scanning. If @p
01182      * filter_duplicates is equal to duplicates_filter_t::PERIODIC_RESET then
01183      * the duplicate cache is reset whenever a scan operation starts.
01184      *
01185      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01186      * appropriate error otherwise.
01187      *
01188      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.65 LE set extended scan enable
01189      * command.
01190      */
01191     ble_error_t extended_scan_enable(
01192         bool enable,
01193         duplicates_filter_t filter_duplicates,
01194         uint16_t duration,
01195         uint16_t period
01196     ) {
01197         return impl()->extended_scan_enable_(
01198             enable,
01199             filter_duplicates,
01200             duration,
01201             period
01202         );
01203     }
01204 
01205     /**
01206      * Synchronize an observer with a periodic advertising broadcaster.
01207      *
01208      * One the synchronization is establish the function
01209      * EventHandler::on_periodic_advertising_sync_established is called and for
01210      * every periodic advertising received is reported via the function
01211      * EventHandler::on_periodic_advertising_report .
01212      *
01213      * @param use_periodic_advertiser_list Determine if the periodic advertiser
01214      * list is used or ignored.
01215      *
01216      * @param advertising_sid SID to sync with.
01217      *
01218      * @param peer_address_type, peer_address Address of the advertiser. If @p
01219      * use_periodic_advertiser_list is true then these parameters are ignored.
01220      *
01221      * @param allowed_skip Number of periodic advertisement that can be skipped
01222      * after a successful receive by the local device.
01223      *
01224      * @param sync_timeout Specifies the maximum permitted time between two
01225      * successful receives. If this time is exceeded then the synchronization is
01226      * considered lost and EventHandler::on_periodic_advertising_loss is called.
01227      *
01228      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01229      * appropriate error otherwise.
01230      *
01231      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.67 LE periodic advertising create
01232      * sync command.
01233      */
01234     ble_error_t periodic_advertising_create_sync(
01235         bool use_periodic_advertiser_list,
01236         uint8_t advertising_sid,
01237         peer_address_type_t peer_address_type,
01238         const address_t &peer_address,
01239         uint16_t allowed_skip,
01240         uint16_t sync_timeout
01241     ) {
01242         return impl()->periodic_advertising_create_sync_(
01243             use_periodic_advertiser_list,
01244             advertising_sid,
01245             peer_address_type,
01246             peer_address,
01247             allowed_skip,
01248             sync_timeout
01249         );
01250     }
01251 
01252     /**
01253      * Cancel the establishment of synchronization with a periodic advertising
01254      * broadcaster.
01255      *
01256      * @pre There should be an ongoing sync establishment operation.
01257      *
01258      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01259      * appropriate error otherwise.
01260      *
01261      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.68 LE periodic advertising create
01262      * sync cancel command.
01263      */
01264     ble_error_t cancel_periodic_advertising_create_sync() {
01265         return impl()->cancel_periodic_advertising_create_sync_();
01266     }
01267 
01268     /**
01269      * Stop reception of the periodic advertising identified by @p sync_handle.
01270      *
01271      * @param sync_handle The handle identifying the periodic advertiser. It is
01272      * obtained when EventHandler::on_periodic_advertising_sync_established is
01273      * called.
01274      *
01275      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01276      * appropriate error otherwise.
01277      *
01278      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.69 LE periodic advertising
01279      * terminate sync command.
01280      */
01281     ble_error_t periodic_advertising_terminate_sync(
01282         sync_handle_t sync_handle
01283     ) {
01284         return impl()->periodic_advertising_terminate_sync_(sync_handle);
01285     }
01286 
01287     /**
01288      * Add a device to the periodic advertiser list stored in the controller.
01289      * This list may be used to create a periodic advertiser sync.
01290      *
01291      * @pre The device should not be in the periodic advertiser list.
01292      *
01293      * @pre Create sync operation should not be pending
01294      *
01295      * @pre The periodic advertising list of the controller should not be full.
01296      *
01297      * @param advertiser_address_type The address type of the device to add.
01298      *
01299      * @param advertiser_address The address value of the device to add.
01300      *
01301      * @param advertising_sid The SID field used to identify periodic advertising
01302      * from the device.
01303      *
01304      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01305      * appropriate error otherwise.
01306      *
01307      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.70 LE add device to periodic
01308      * advertising list command.
01309      */
01310     ble_error_t add_device_to_periodic_advertiser_list(
01311         advertising_peer_address_type_t advertiser_address_type,
01312         const address_t &advertiser_address,
01313         uint8_t advertising_sid
01314     ) {
01315         return impl()->add_device_to_periodic_advertiser_list_(
01316             advertiser_address_type,
01317             advertiser_address,
01318             advertising_sid
01319         );
01320     }
01321 
01322     /**
01323      * Remove a device from the periodic advertiser list.
01324      *
01325      * @pre Create sync operation should not be pending
01326      *
01327      * @param advertiser_address_type The address type of the device to remove.
01328      *
01329      * @param advertiser_address The address value of the device to remove.
01330      *
01331      * @param advertising_sid The SID field used to identify periodic advertising
01332      * from the device.
01333      *
01334      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01335      * appropriate error otherwise.
01336      *
01337      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.71 LE remove device from periodic
01338      * advertising list command.
01339      */
01340     ble_error_t remove_device_from_periodic_advertiser_list(
01341         advertising_peer_address_type_t advertiser_address_type,
01342         const address_t &advertiser_address,
01343         uint8_t advertising_sid
01344     ) {
01345         return impl()->remove_device_from_periodic_advertiser_list_(
01346             advertiser_address_type,
01347             advertiser_address,
01348             advertising_sid
01349         );
01350     }
01351 
01352     /**
01353      * Clear all devices from the list of periodic advertisers.
01354      *
01355      * @pre Create sync operation should not be pending
01356      *
01357      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01358      * appropriate error otherwise.
01359      *
01360      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.72 LE clear periodic advertising
01361      * list command.
01362      */
01363     ble_error_t clear_periodic_advertiser_list() {
01364         return impl()->clear_periodic_advertiser_list_();
01365     }
01366 
01367     /**
01368      * Return the total number of entries that can be stored by the periodic
01369      * advertiser list.
01370      *
01371      * @return The capacity of the periodic advertiser list.
01372      *
01373      * @note We (wrongfully) assume that value doesn't change over time.
01374      */
01375     uint8_t read_periodic_advertiser_list_size() {
01376         return impl()->read_periodic_advertiser_list_size_();
01377     }
01378 
01379     /**
01380      * Create a new le connection to a connectable advertiser.
01381      *
01382      * @param scan_interval Hint to the le subsystem indicating how
01383      * frequently it should scan for the peer address. It represent the time
01384      * interval between two subsequent scan for the peer. It shall be in the
01385      * range [0x0004 : 0x4000] and the time is in unit of 0.625ms.
01386      *
01387      * @param scan_window Hint to the le subsystem indicating for how long it
01388      * should scan during a scan interval. The value shall be smaller or equal
01389      * to scan_interval. If it is equal to scan_interval then scanning should
01390      * run continuously. It shall be in the range [0x0004 : 0x4000] and the time
01391      * is in unit of 0.625ms.
01392      *
01393      * @param initiator_policy Used to determine if the whitelist is used to
01394      * determine the address to connect to. If the whitelist is not used, the
01395      * connection shall be made against an advertiser matching the peer_address
01396      * and the peer_address_type parameters. Otherwise those parameters are
01397      * ignored.
01398      *
01399      * @param peer_address_type Type of address used by the advertiser. Not used
01400      * if initiator_policy use the whitelist.
01401      *
01402      * @param Address used by the advertiser in its advertising packets. Not
01403      * used if initiator_policy use the whitelist.
01404      *
01405      * @param own_address_type Type of address used in the connection request
01406      * packet.
01407      *
01408      * @param connection_interval_min Minimum interval between two connection
01409      * events allowed for the connection. It shall be less than or equal to
01410      * connection_interval_max. This value shall be in range [0x0006 : 0x0C80]
01411      * and is in unit of 1.25ms.
01412      *
01413      * @param connection_interval_max Maximum interval between two connection
01414      * events allowed for the connection. It shall be greater than or equal to
01415      * connection_interval_min. This value shall be in range [0x0006 : 0x0C80]
01416      * and is in unit of 1.25ms.
01417      *
01418      * @param connection_latency Number of connection events the slave can drop
01419      * if it has nothing to communicate to the master. This value shall be in
01420      * the range [0x0000 : 0x01F3].
01421      *
01422      * @param supervision_timeout Link supervision timeout for the connection.
01423      * It shall be larger than:
01424      *        (1 + connection_latency) * connection_interval_max * 2
01425      * Note: connection_interval_max is in ms in this formulae.
01426      * Everytime the master or the slave receive a valid packet from the peer,
01427      * the supervision timer is reset. If the supervision timer reaches
01428      * supervision_timeout then the connection is considered lost and a
01429      * disconnect event shall be emmited.
01430      * This value shall be in the range [0x000A : 0x0C80] and is in unit of 10
01431      * ms.
01432      *
01433      * @param minimum_connection_event_length Informative parameter of the
01434      * minimum length a connection event. It shall be less than or equal to
01435      * maximum_connection_event_length. It shall be in the range
01436      * [0x0000 : 0xFFFF]. It should also be less than the expected connection
01437      * interval. The unit is 0.625ms.
01438      *
01439      * @param maximum_connection_event_length Informative parameter of the
01440      * maximum length a connection event. It shall be more than or equal to
01441      * minimum_connection_event_length. It shall be in the range
01442      * [0x0000 : 0xFFFF]. It should also be less than the expected connection
01443      * interval. The unit is 0.625ms.
01444      *
01445      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01446      * appropriate error otherwise.
01447      *
01448      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.12 LE create connection command.
01449      */
01450     ble_error_t create_connection(
01451         uint16_t scan_interval,
01452         uint16_t scan_window,
01453         initiator_policy_t initiator_policy,
01454         connection_peer_address_type_t peer_address_type,
01455         const address_t &peer_address,
01456         own_address_type_t own_address_type,
01457         uint16_t connection_interval_min,
01458         uint16_t connection_interval_max,
01459         uint16_t connection_latency,
01460         uint16_t supervision_timeout,
01461         uint16_t minimum_connection_event_length,
01462         uint16_t maximum_connection_event_length
01463     ) {
01464         return impl()->create_connection_(
01465             scan_interval,
01466             scan_window,
01467             initiator_policy,
01468             peer_address_type,
01469             peer_address,
01470             own_address_type,
01471             connection_interval_min,
01472             connection_interval_max,
01473             connection_latency,
01474             supervision_timeout,
01475             minimum_connection_event_length,
01476             maximum_connection_event_length
01477         );
01478     }
01479 
01480     /**
01481      * Create a new le connection to a connectable advertiser.
01482      *
01483      * @param initiator_policy Used to determine if the whitelist is used to
01484      * determine the address to connect to. If the whitelist is not used, the
01485      * connection shall be made against an advertiser matching the peer_address
01486      * and the peer_address_type parameters. Otherwise those parameters are
01487      * ignored.
01488      *
01489      * @param own_address_type Type of address used in the connection request
01490      * packet.
01491      *
01492      * @param peer_address_type Type of address used by the advertiser. Not used
01493      * if initiator_policy use the whitelist.
01494      *
01495      * @param peer_address Address used by the advertiser in its advertising
01496      * packets. Not used if initiator_policy use the whitelist.
01497      *
01498      * @param initiating_phys Indicates the advertising PHYs and the controller
01499      * may use find the target and establish the connection. Subsequent
01500      * parameters are arrays of value associated with phys present in @p
01501      * initiating_phys. The order of phys is 1M, 2M, Coded.
01502      *
01503      * @param scan_intervals Hint to the le subsystem indicating how
01504      * frequently it should scan for the peer address. It represent the time
01505      * interval between two subsequent scan for the peer. It shall be in the
01506      * range [0x0004 : 0x4000] and the time is in unit of 0.625ms.
01507      *
01508      * @param scan_windows Hint to the le subsystem indicating for how long it
01509      * should scan during a scan interval. The value shall be smaller or equal
01510      * to scan_interval. If it is equal to scan_interval then scanning should
01511      * run continuously. It shall be in the range [0x0004 : 0x4000] and the time
01512      * is in unit of 0.625ms.
01513      *
01514      * @param connection_intervals_min Minimum interval between two connection
01515      * events allowed for the connection. It shall be less than or equal to
01516      * connection_interval_max. This value shall be in range [0x0006 : 0x0C80]
01517      * and is in unit of 1.25ms.
01518      *
01519      * @param connection_intervals_max Maximum interval between two connection
01520      * events allowed for the connection. It shall be greater than or equal to
01521      * connection_interval_min. This value shall be in range [0x0006 : 0x0C80]
01522      * and is in unit of 1.25ms.
01523      *
01524      * @param connection_latencies Number of connection events the slave can drop
01525      * if it has nothing to communicate to the master. This value shall be in
01526      * the range [0x0000 : 0x01F3].
01527      *
01528      * @param supervision_timeouts Link supervision timeout for the connection.
01529      * It shall be larger than:
01530      *        (1 + connection_latency) * connection_interval_max * 2
01531      * Note: connection_interval_max is in ms in this formulae.
01532      * Everytime the master or the slave receive a valid packet from the peer,
01533      * the supervision timer is reset. If the supervision timer reaches
01534      * supervision_timeout then the connection is considered lost and a
01535      * disconnect event shall be emmited.
01536      * This value shall be in the range [0x000A : 0x0C80] and is in unit of 10
01537      * ms.
01538      *
01539      * @param minimum_connection_event_lengths Informative parameter of the
01540      * minimum length a connection event. It shall be less than or equal to
01541      * maximum_connection_event_length. It shall be in the range
01542      * [0x0000 : 0xFFFF]. It should also be less than the expected connection
01543      * interval. The unit is 0.625ms.
01544      *
01545      * @param maximum_connection_event_lengths Informative parameter of the
01546      * maximum length a connection event. It shall be more than or equal to
01547      * minimum_connection_event_length. It shall be in the range
01548      * [0x0000 : 0xFFFF]. It should also be less than the expected connection
01549      * interval. The unit is 0.625ms.
01550      *
01551      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01552      * appropriate error otherwise.
01553      *
01554      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.66 LE extended create connection
01555      * command.
01556      */
01557     ble_error_t extended_create_connection(
01558         initiator_policy_t initiator_policy,
01559         own_address_type_t own_address_type,
01560         peer_address_type_t peer_address_type,
01561         const address_t &peer_address,
01562         phy_set_t initiating_phys,
01563         const uint16_t *scan_intervals,
01564         const uint16_t *scan_windows,
01565         const uint16_t *connection_intervals_min,
01566         const uint16_t *connection_intervals_max,
01567         const uint16_t *connection_latencies,
01568         const uint16_t *supervision_timeouts,
01569         const uint16_t *minimum_connection_event_lengths,
01570         const uint16_t *maximum_connection_event_lengths
01571     ) {
01572         return impl()->extended_create_connection_(
01573             initiator_policy,
01574             own_address_type,
01575             peer_address_type,
01576             peer_address,
01577             initiating_phys,
01578             scan_intervals,
01579             scan_windows,
01580             connection_intervals_min,
01581             connection_intervals_max,
01582             connection_latencies,
01583             supervision_timeouts,
01584             minimum_connection_event_lengths,
01585             maximum_connection_event_lengths
01586         );
01587     }
01588 
01589     /**
01590      * Cancel the ongoing connection creation process.
01591      *
01592      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01593      * appropriate error otherwise.
01594      *
01595      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.13 LE create connection cancel
01596      * command.
01597      */
01598     ble_error_t cancel_connection_creation() {
01599         return impl()->cancel_connection_creation_();
01600     }
01601 
01602     /**
01603      * Return the number of total whitelist entries that can be stored in the
01604      * le subsystem.
01605      *
01606      * @note The value returned can change over time.
01607      *
01608      * @return The number of entries that can be stored in the LE subsystem. It
01609      * range from 0x01 to 0xFF.
01610      *
01611      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.14 LE read white list size
01612      * command.
01613      */
01614     uint8_t read_white_list_capacity() {
01615         return impl()->read_white_list_capacity_();
01616     }
01617 
01618     /**
01619      * Clear the whitelist stored in the LE subsystem.
01620      *
01621      * @attention This command shall not be issued if the whitelist is being
01622      * used by the advertising, scanning or connection creation procedure.
01623      *
01624      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01625      * appropriate error otherwise.
01626      *
01627      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.15 LE clear white list command.
01628      */
01629     ble_error_t clear_whitelist() {
01630         return impl()->clear_whitelist_();
01631     }
01632 
01633     /**
01634      * Add a device to the LE subsystem Whitelist.
01635      *
01636      * @param address_type address_type Type of the address to add in the
01637      * whitelist.
01638      *
01639      * @param address Address of the device.
01640      *
01641      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01642      * appropriate error otherwise.
01643      *
01644      * @attention This command shall not be issued if the whitelist is being
01645      * used by the advertising, scanning or connection creation procedure.
01646      *
01647      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.16 LE add device to white list
01648      * command.
01649      */
01650     ble_error_t add_device_to_whitelist(
01651         whitelist_address_type_t address_type,
01652         address_t address
01653     ) {
01654         return impl()->add_device_to_whitelist_(
01655             address_type,
01656             address
01657         );
01658     }
01659 
01660     /**
01661      * Remove a device from the LE subsystem Whitelist.
01662      *
01663      * @param address_type address_type Type of the address of the device to
01664      * remove from the whitelist.
01665      *
01666      * @param address Address of the device to remove from the whitelist
01667      *
01668      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01669      * appropriate error otherwise.
01670      *
01671      * @attention This command shall not be issued if the whitelist is being
01672      * used by the advertising, scanning or connection creation procedure.
01673      *
01674      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.17 LE remove device from white
01675      * list command.
01676      */
01677     ble_error_t remove_device_from_whitelist(
01678         whitelist_address_type_t address_type,
01679         address_t address
01680     ) {
01681         return impl()->remove_device_from_whitelist_(
01682             address_type,
01683             address
01684         );
01685     }
01686 
01687     /**
01688      * Start a connection update procedure.
01689      *
01690      * This procedure change the parameter used for a connection it can be
01691      * master or slave initiated.
01692      *
01693      * The peer will received a connection parameters request and will either
01694      * accept or reject the new parameters for the connection.
01695      *
01696      * Once the peer response has been received, the procedure ends and a
01697      * Connection update complete event is emmited.
01698      *
01699      * @param connection Handle of the connection.
01700      *
01701      * @param connection_interval_min Minimum interval between two connection
01702      * events allowed for the connection. It shall be less than or equal to
01703      * connection_interval_max. This value shall be in range [0x0006 : 0x0C80]
01704      * and is in unit of 1.25ms.
01705      *
01706      * @param connection_interval_max Maximum interval between two connection
01707      * events allowed for the connection. It shall be greater than or equal to
01708      * connection_interval_min. This value shall be in range [0x0006 : 0x0C80]
01709      * and is in unit of 1.25ms.
01710      *
01711      * @param connection_latency Number of connection events the slave can drop
01712      * if it has nothing to communicate to the master. This value shall be in
01713      * the range [0x0000 : 0x01F3].
01714      *
01715      * @param supervision_timeout Link supervision timeout for the connection.
01716      * It shall be larger than:
01717      *        (1 + connection_latency) * connection_interval_max * 2
01718      * Note: connection_interval_max is in ms in this formulae.
01719      * Everytime the master or the slave receive a valid packet from the peer,
01720      * the supervision timer is reset. If the supervision timer reaches
01721      * supervision_timeout then the connection is considered lost and a
01722      * disconnect event shall be emmited.
01723      * This value shall be in the range [0x000A : 0x0C80] and is in unit of 10
01724      * ms.
01725      *
01726      * @param minimum_connection_event_length Informative parameter of the
01727      * minimum length a connection event. It shall be less than or equal to
01728      * maximum_connection_event_length. It shall be in the range
01729      * [0x0000 : 0xFFFF]. It should also be less than the expected connection
01730      * interval. The unit is 0.625ms.
01731      *
01732      * @param maximum_connection_event_length Informative parameter of the
01733      * maximum length a connection event. It shall be more than or equal to
01734      * minimum_connection_event_length. It shall be in the range
01735      * [0x0000 : 0xFFFF]. It should also be less than the expected connection
01736      * interval. The unit is 0.625ms.
01737      *
01738      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01739      * appropriate error otherwise.
01740      *
01741      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.18 LE Connection update command.
01742      *
01743      */
01744     ble_error_t connection_parameters_update(
01745         connection_handle_t connection,
01746         uint16_t connection_interval_min,
01747         uint16_t connection_interval_max,
01748         uint16_t connection_latency,
01749         uint16_t supervision_timeout,
01750         uint16_t minimum_connection_event_length,
01751         uint16_t maximum_connection_event_length
01752     ) {
01753         return impl()->connection_parameters_update_(
01754             connection,
01755             connection_interval_min,
01756             connection_interval_max,
01757             connection_latency,
01758             supervision_timeout,
01759             minimum_connection_event_length,
01760             maximum_connection_event_length
01761         );
01762     }
01763 
01764     /**
01765      * Accept connection parameter request.
01766      *
01767      * This command sends a positive response to a connection parameter request
01768      * from a peer.
01769      *
01770      * @param connection Handle of the connection.
01771      *
01772      * @param connection_interval_min Minimum interval between two connection
01773      * events allowed for the connection. It shall be less than or equal to
01774      * connection_interval_max. This value shall be in range [0x0006 : 0x0C80]
01775      * and is in unit of 1.25ms.
01776      *
01777      * @param connection_interval_max Maximum interval between two connection
01778      * events allowed for the connection. It shall be greater than or equal to
01779      * connection_interval_min. This value shall be in range [0x0006 : 0x0C80]
01780      * and is in unit of 1.25ms.
01781      *
01782      * @param connection_latency Number of connection events the slave can drop
01783      * if it has nothing to communicate to the master. This value shall be in
01784      * the range [0x0000 : 0x01F3].
01785      *
01786      * @param supervision_timeout Link supervision timeout for the connection.
01787      * It shall be larger than:
01788      *        (1 + connection_latency) * connection_interval_max * 2
01789      * Note: connection_interval_max is in ms in this formulae.
01790      * Everytime the master or the slave receive a valid packet from the peer,
01791      * the supervision timer is reset. If the supervision timer reaches
01792      * supervision_timeout then the connection is considered lost and a
01793      * disconnect event shall be emmited.
01794      * This value shall be in the range [0x000A : 0x0C80] and is in unit of 10
01795      * ms.
01796      *
01797      * @param minimum_connection_event_length Informative parameter of the
01798      * minimum length a connection event. It shall be less than or equal to
01799      * maximum_connection_event_length. It shall be in the range
01800      * [0x0000 : 0xFFFF]. It should also be less than the expected connection
01801      * interval. The unit is 0.625ms.
01802      *
01803      * @param maximum_connection_event_length Informative parameter of the
01804      * maximum length a connection event. It shall be more than or equal to
01805      * minimum_connection_event_length. It shall be in the range
01806      * [0x0000 : 0xFFFF]. It should also be less than the expected connection
01807      * interval. The unit is 0.625ms.
01808      *
01809      * @note Usually parameters of this function match the connection parameters
01810      * received in the connection parameter request event.
01811      *
01812      * @attention: Once the new connection parameters are in used a Connection
01813      * Update Complete event shall be emmited.
01814      *
01815      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01816      * appropriate error otherwise.
01817      *
01818      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.31 LE remote connection parameter
01819      * request reply command.
01820      */
01821     ble_error_t accept_connection_parameter_request(
01822         connection_handle_t connection_handle,
01823         uint16_t interval_min,
01824         uint16_t interval_max,
01825         uint16_t latency,
01826         uint16_t supervision_timeout,
01827         uint16_t minimum_connection_event_length,
01828         uint16_t maximum_connection_event_length
01829     ) {
01830         return impl()->accept_connection_parameter_request_(
01831             connection_handle,
01832             interval_min,
01833             interval_max,
01834             latency,
01835             supervision_timeout,
01836             minimum_connection_event_length,
01837             maximum_connection_event_length
01838         );
01839     }
01840 
01841     /**
01842      * Reject a connection parameter update request.
01843      *
01844      * @param connection_handle handle to the peer which has issued the
01845      * connection parameter request.
01846      *
01847      * @param rejection_reason Indicate to the peer why the proposed connection
01848      * parameters were rejected.
01849      *
01850      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01851      * appropriate error otherwise.
01852      *
01853      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.32 LE Remote Connection Parameter
01854      * Request Negative Reply Command.
01855      */
01856     ble_error_t reject_connection_parameter_request(
01857         connection_handle_t connection_handle,
01858         hci_error_code_t rejection_reason
01859     ) {
01860         return impl()->reject_connection_parameter_request_(
01861             connection_handle,
01862             rejection_reason
01863         );
01864     }
01865 
01866     /**
01867      * Start a disconnection procedure.
01868      *
01869      * Once the procedure is complete it should emit a disconnection complete
01870      * event.
01871      *
01872      * @param connection Handle of the connection to terminate.
01873      *
01874      * @param disconnection_reason Indicates the reason for ending the
01875      * connection.
01876      *
01877      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01878      * appropriate error otherwise.
01879      *
01880      * @note: See Bluetooth 5 Vol 2 PartE: 7.1.6 disconenct command.
01881      */
01882     ble_error_t disconnect(
01883         connection_handle_t connection,
01884         disconnection_reason_t disconnection_reason
01885     ) {
01886         return impl()->disconnect_(connection, disconnection_reason);
01887     }
01888 
01889     /** Check if privacy feature is supported by implementation
01890      *  
01891      * @return true if privacy is supported, false otherwise.
01892      * 
01893      * @note: See Bluetooth 5 Vol 3 Part C: 10.7 Privacy feature.
01894      */
01895     bool is_privacy_supported() {
01896         return impl()->is_privacy_supported_();
01897     }
01898 
01899     /** Enable or disable private addresses resolution
01900      *
01901      * @param enable whether to enable private addresses resolution
01902      *  
01903      * @return BLE_ERROR_NONE if the request has been successfully sent or the
01904      * appropriate error otherwise.
01905      * 
01906      * @note: See Bluetooth 5 Vol 2 PartE: 7.8.44 LE Set Address Resolution Enable command.
01907      */
01908     ble_error_t set_address_resolution(
01909         bool enable
01910     ) {
01911         return impl()->set_address_resolution_(enable);
01912     }
01913 
01914     /**
01915      * Checked support for a feature in the link controller.
01916      *
01917      * @param feature feature to be checked.
01918      * @return TRUE if feature is supported.
01919      */
01920     bool is_feature_supported(
01921         controller_supported_features_t feature
01922     ) {
01923         return impl()->is_feature_supported_(feature);
01924     }
01925 
01926     /**
01927     * @see Gap::readPhy
01928     */
01929     ble_error_t read_phy (connection_handle_t connection) {
01930         return impl()->read_phy_(connection);
01931     }
01932 
01933     /**
01934     * @see Gap::setPreferredPhys
01935     */
01936     ble_error_t set_preferred_phys (
01937         const phy_set_t &tx_phys,
01938         const phy_set_t &rx_phys
01939     ) {
01940         return impl()->set_preferred_phys_(tx_phys, rx_phys);
01941     }
01942 
01943     /**
01944     * @see Gap::setPhy
01945     */
01946     ble_error_t set_phy (
01947         connection_handle_t connection,
01948         const phy_set_t &tx_phys,
01949         const phy_set_t &rx_phys,
01950         coded_symbol_per_bit_t coded_symbol
01951     ) {
01952         return impl()->set_phy_(
01953             connection,
01954             tx_phys,
01955             rx_phys,
01956             coded_symbol
01957         );
01958     }
01959 
01960     /**
01961      * Register a callback which will handle Gap events.
01962      *
01963      * @param cb The callback object which will handle Gap events from the
01964      * LE subsystem.
01965      * It accept a single parameter in input: The event received.
01966      */
01967     void when_gap_event_received(mbed::Callback<void(const GapEvent &)> cb)
01968     {
01969         _gap_event_cb = cb;
01970     }
01971 
01972 public:
01973     /**
01974     * Sets the event handler that us called by the PAL porters to notify the stack of events
01975     * which will in turn be passed onto the user application when appropriate.
01976     *
01977     * @param[in] event_handler the new event handler interface implementation. Memory
01978     * owned by caller who is responsible for updating this pointer if interface changes.
01979     */
01980     void set_event_handler(EventHandler *event_handler)
01981     {
01982         _pal_event_handler = event_handler;
01983     }
01984 
01985     EventHandler *get_event_handler()
01986     {
01987         return _pal_event_handler;
01988     }
01989 
01990 protected:
01991     EventHandler *_pal_event_handler;
01992 
01993 protected:
01994     Gap() : _pal_event_handler(NULL)
01995     {
01996     }
01997 
01998     ~Gap()
01999     {
02000     }
02001 
02002     /**
02003      * Implementation shall call this function whenever the LE subsystem
02004      * generate a Gap event.
02005      *
02006      * @param gap_event The event to emit to higher layer.
02007      */
02008     void emit_gap_event(const GapEvent &gap_event)
02009     {
02010         if (_gap_event_cb) {
02011             _gap_event_cb(gap_event);
02012         }
02013     }
02014 
02015 public:
02016     /**
02017      * Create an ALL_PHYS parameter used in LE Set PHY Command
02018      * and LE Set Default PHY Command.
02019      * @see BLUETOOTH SPECIFICATION Version 5.0 | Vol 2, Part E - 7.8.49
02020      */
02021     static uint8_t create_all_phys_value(
02022         const phy_set_t &tx_phys,
02023         const phy_set_t &rx_phys
02024     )
02025     {
02026         /* if phy set is empty set corresponding all_phys bit to 1 */
02027         uint8_t all_phys = 0;
02028         if (tx_phys.value() == 0) {
02029             all_phys |= 0x01;
02030         }
02031         if (rx_phys.value() == 0) {
02032             all_phys |= 0x02;
02033         }
02034         return all_phys;
02035     }
02036 
02037 private:
02038     /**
02039      * Callback called when an event is emitted by the LE subsystem.
02040      */
02041     mbed::Callback<void(const GapEvent &)> _gap_event_cb;
02042 
02043 private:
02044     // Disallow copy construction and copy assignment.
02045     Gap(const Gap &);
02046 
02047     Gap &operator=(const Gap &);
02048 };
02049 
02050 } // namespace pal
02051 } // namespace ble
02052 
02053 #endif /* BLE_PAL_GAP_H_ */