diff --git a/features/FEATURE_BLE/ble/pal/PalGap.h b/features/FEATURE_BLE/ble/pal/PalGap.h index 3598fdace2..fb4fa959b1 100644 --- a/features/FEATURE_BLE/ble/pal/PalGap.h +++ b/features/FEATURE_BLE/ble/pal/PalGap.h @@ -17,6 +17,7 @@ #ifndef BLE_PAL_GAP_H_ #define BLE_PAL_GAP_H_ +#include "ble/common/StaticInterface.h" #include "platform/Callback.h" #include "ble/pal/GapTypes.h" #include "GapEvents.h" @@ -25,6 +26,313 @@ namespace ble { namespace pal { +template +struct GapEventHandler : StaticInterface { + + using StaticInterface::impl; + +public: + /** + * @copydoc Gap::EventHandler::onReadPhy + */ + void on_read_phy( + pal::hci_error_code_t status, + connection_handle_t connectionHandle, + ble::phy_t tx_phy, + ble::phy_t rx_phy + ) { + impl()->on_read_phy_(status, connectionHandle, tx_phy, rx_phy); + } + + /** + * @copydoc Gap::EventHandler::onDataLengthChange + */ + void on_data_length_change( + connection_handle_t connection_handle, + uint16_t tx_size, + uint16_t rx_size + ) { + impl()->on_data_length_change_(connection_handle, tx_size, rx_size); + } + + /** + * @copydoc Gap::EventHandler::onPhyUpdateComplete + */ + void on_phy_update_complete( + pal::hci_error_code_t status, + connection_handle_t connection_handle, + ble::phy_t tx_phy, + ble::phy_t rx_phy + ) { + impl()->on_phy_update_complete(status, connection_handle, tx_phy, rx_phy); + } + + /** + * Should be invoked by the Gap implementation when an enhanced + * connection complete event happens. + * + * @param status hci_error_code::SUCCESS in case of success or an error + * code. + * + * @param connection_handle The handle of the connection created. + * + * @param own_role Indicate if the local device operates as slave or + * master. + * + * @param peer_address_type Type of address of the peer. + * + * @param peer_address Address of the peer connected. + * + * @param local_resolvable_private_address Resolvable private address + * being used by the controller. If not applicable, the address is full + * of zeroes. + * + * @param peer_resolvable_private_address Resolvable private address + * being used by the peer. If not applicable, the address is full of + * zeroes. + * + * @param connection_interval Interval between two connection events. + * Unit is 1.25ms. + * + * @param connection_latency Slave latency for the connection in number + * of connection events. + * + * @param supervision_timeout Connection supervision timeout. Unit is + * 10ms. + * + * @param master_clock_accuracy This parameter is only valid for a slave. + * On a master it must be set to 0x00. + * + * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.10 LE enhanced connection + * complete event. + */ + void on_enhanced_connection_complete( + hci_error_code_t status, + connection_handle_t connection_handle, + connection_role_t own_role, + connection_peer_address_type_t peer_address_type, + const address_t &peer_address, + const address_t &local_resolvable_private_address, + const address_t &peer_resolvable_private_address, + uint16_t connection_interval, + uint16_t connection_latency, + uint16_t supervision_timeout, + clock_accuracy_t master_clock_accuracy + ) { + impl()->on_enhanced_connection_complete_( + status, + connection_handle, + own_role, + peer_address_type, + peer_address, + local_resolvable_private_address, + peer_resolvable_private_address, + connection_interval, + connection_latency, + supervision_timeout, + master_clock_accuracy + ); + } + + /** Called on advertising report event. + * + * @param event_type Type of advertising used. + * @param address_type Peer address type of advertiser. + * @param address Peer address of advertiser. + * @param primary_phy PHY used on the primary channels. + * @param secondary_phy PHY used on secondary channels. + * @param advertising_sid Set identification number. + * @param tx_power Transmission power reported by the packet. + * @param rssi Measured signal strength. + * @param periodic_advertising_interval Interval of periodic advertising. + * @param direct_address_type Directed advertising target address type. + * @param direct_address Directed advertising target address. + * @param data_length Advertising payload length. + * @param data Advertising payload. + * + * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.13 LE extended advertising + * report event. + */ + void on_extended_advertising_report( + advertising_event_t event_type, + const connection_peer_address_type_t *address_type, + const address_t &address, + phy_t primary_phy, + const phy_t *secondary_phy, + advertising_sid_t advertising_sid, + advertising_power_t tx_power, + rssi_t rssi, + uint16_t periodic_advertising_interval, + direct_address_type_t direct_address_type, + const address_t &direct_address, + uint8_t data_length, + const uint8_t *data_size + ) { + impl()->on_extended_advertising_report_( + event_type, + address_type, + address, + primary_phy, + secondary_phy, + advertising_sid, + tx_power, + rssi, + periodic_advertising_interval, + direct_address_type, + direct_address, + data_length, + data_size + ); + } + + /** Called on advertising sync event. + * + * @param error SUCCESS if synchronisation was achieved. + * @param sync_handle Advertising sync handle. + * @param advertising_sid Advertising set identifier. + * @param advertiser_address_type Peer address type. + * @param advertiser_address Peer address. + * @param advertiser_phy PHY used for advertisements. + * @param periodic_advertising_interval Periodic advertising interval. + * @param clock_accuracy Peer clock accuracy. + */ + void on_periodic_advertising_sync_established( + pal::hci_error_code_t error, + pal::sync_handle_t sync_handle, + advertising_sid_t advertising_sid, + connection_peer_address_type_t advertiser_address_type, + const ble::address_t &advertiser_address, + phy_t advertiser_phy, + uint16_t periodic_advertising_interval, + pal::clock_accuracy_t clock_accuracy + ) { + impl()->on_periodic_advertising_sync_established_( + error, + sync_handle, + advertising_sid, + advertiser_address_type, + advertiser_address, + advertiser_phy, + periodic_advertising_interval, + clock_accuracy + ); + } + + /** Called after a periodic advertising report event. + * + * @param sync_handle Periodic advertising sync handle + * @param tx_power TX power. + * @param rssi Received signal strength. + * @param data_status Status to indicate the completeness of the payload. + * @param data_length Periodic advertisement payload length. + * @param data Periodic advertisement payload. + */ + void on_periodic_advertising_report( + sync_handle_t sync_handle, + advertising_power_t tx_power, + rssi_t rssi, + advertising_data_status_t data_status, + uint8_t data_length, + const uint8_t *data + ) { + impl()->on_periodic_advertising_report_( + sync_handle, + tx_power, + rssi, + data_status, + data_length, + data + ); + } + + /** Called on periodic advertising sync loss event. + * + * @param sync_handle Advertising sync handle' + */ + void on_periodic_advertising_sync_loss( + sync_handle_t sync_handle + ) { + impl()->on_periodic_advertising_sync_loss_(sync_handle); + } + + /** Called when scanning times out. + */ + void on_scan_timeout() { + impl()->on_scan_timeout_(); + } + + /** Called when advertising set stops advertising. + * + * @param status SUCCESS if connection has been established. + * @param advertising_handle Advertising set handle. + * @param advertising_handle Connection handle. + * @param number_of_completed_extended_advertising_events Number of events created during before advertising end. + */ + void on_advertising_set_terminated( + hci_error_code_t status, + advertising_handle_t advertising_handle, + connection_handle_t connection_handle, + uint8_t number_of_completed_extended_advertising_events + ) { + impl()->on_advertising_set_terminated_( + status, + advertising_handle, + connection_handle, + number_of_completed_extended_advertising_events + ); + } + + /** Called when a device receives a scan request from an active scanning device. + * + * @param advertising_handle Advertising set handle. + * @param scanner_address_type Peer address type. + * @param address Peer address. + */ + void on_scan_request_received( + advertising_handle_t advertising_handle, + connection_peer_address_type_t scanner_address_type, + const address_t &address + ) { + impl()->on_scan_request_received_( + advertising_handle, + scanner_address_type, + address + ); + } + + void on_connection_update_complete( + hci_error_code_t status, + connection_handle_t connection_handle, + uint16_t connection_interval, + uint16_t connection_latency, + uint16_t supervision_timeout + ) { + impl()->on_connection_update_complete_( + status, + connection_handle, + connection_interval, + connection_latency, + supervision_timeout + ); + } + + void on_remote_connection_parameter( + connection_handle_t connection_handle, + uint16_t connection_interval_min, + uint16_t connection_interval_max, + uint16_t connection_latency, + uint16_t supervision_timeout + ) { + impl()->on_remote_connection_parameter_( + connection_handle, + connection_interval_min, + connection_interval_max, + connection_latency, + supervision_timeout + ); + } +}; + /** * Adaptation interface for the GAP layer. * @@ -32,219 +340,15 @@ namespace pal { * follow closely the definition of the HCI commands and events used * by that layer. */ +template struct Gap { - struct EventHandler { - /** - * @copydoc Gap::EventHandler::onReadPhy - */ - virtual void on_read_phy( - pal::hci_error_code_t status, - connection_handle_t connectionHandle, - ble::phy_t tx_phy, - ble::phy_t rx_phy - ) = 0; +private: - /** - * @copydoc Gap::EventHandler::onDataLengthChange - */ - virtual void on_data_length_change( - connection_handle_t connection_handle, - uint16_t tx_size, - uint16_t rx_size - ) = 0; + Impl* impl() { + return static_cast(this); + } - /** - * @copydoc Gap::EventHandler::onPhyUpdateComplete - */ - virtual void on_phy_update_complete( - pal::hci_error_code_t status, - connection_handle_t connection_handle, - ble::phy_t tx_phy, - ble::phy_t rx_phy - ) = 0; - - /** - * Should be invoked by the Gap implementation when an enhanced - * connection complete event happens. - * - * @param status hci_error_code::SUCCESS in case of success or an error - * code. - * - * @param connection_handle The handle of the connection created. - * - * @param own_role Indicate if the local device operates as slave or - * master. - * - * @param peer_address_type Type of address of the peer. - * - * @param peer_address Address of the peer connected. - * - * @param local_resolvable_private_address Resolvable private address - * being used by the controller. If not applicable, the address is full - * of zeroes. - * - * @param peer_resolvable_private_address Resolvable private address - * being used by the peer. If not applicable, the address is full of - * zeroes. - * - * @param connection_interval Interval between two connection events. - * Unit is 1.25ms. - * - * @param connection_latency Slave latency for the connection in number - * of connection events. - * - * @param supervision_timeout Connection supervision timeout. Unit is - * 10ms. - * - * @param master_clock_accuracy This parameter is only valid for a slave. - * On a master it must be set to 0x00. - * - * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.10 LE enhanced connection - * complete event. - */ - virtual void on_enhanced_connection_complete( - hci_error_code_t status, - connection_handle_t connection_handle, - connection_role_t own_role, - connection_peer_address_type_t peer_address_type, - const address_t &peer_address, - const address_t &local_resolvable_private_address, - const address_t &peer_resolvable_private_address, - uint16_t connection_interval, - uint16_t connection_latency, - uint16_t supervision_timeout, - clock_accuracy_t master_clock_accuracy - ) = 0; - - /** Called on advertising report event. - * - * @param event_type Type of advertising used. - * @param address_type Peer address type of advertiser. - * @param address Peer address of advertiser. - * @param primary_phy PHY used on the primary channels. - * @param secondary_phy PHY used on secondary channels. - * @param advertising_sid Set identification number. - * @param tx_power Transmission power reported by the packet. - * @param rssi Measured signal strength. - * @param periodic_advertising_interval Interval of periodic advertising. - * @param direct_address_type Directed advertising target address type. - * @param direct_address Directed advertising target address. - * @param data_length Advertising payload length. - * @param data Advertising payload. - * - * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.13 LE extended advertising - * report event. - */ - virtual void on_extended_advertising_report( - advertising_event_t event_type, - const connection_peer_address_type_t *address_type, - const address_t &address, - phy_t primary_phy, - const phy_t *secondary_phy, - advertising_sid_t advertising_sid, - advertising_power_t tx_power, - rssi_t rssi, - uint16_t periodic_advertising_interval, - direct_address_type_t direct_address_type, - const address_t &direct_address, - uint8_t data_length, - const uint8_t *data_size - ) = 0; - - /** Called on advertising sync event. - * - * @param error SUCCESS if synchronisation was achieved. - * @param sync_handle Advertising sync handle. - * @param advertising_sid Advertising set identifier. - * @param advertiser_address_type Peer address type. - * @param advertiser_address Peer address. - * @param advertiser_phy PHY used for advertisements. - * @param periodic_advertising_interval Periodic advertising interval. - * @param clock_accuracy Peer clock accuracy. - */ - virtual void on_periodic_advertising_sync_established( - pal::hci_error_code_t error, - pal::sync_handle_t sync_handle, - advertising_sid_t advertising_sid, - connection_peer_address_type_t advertiser_address_type, - const ble::address_t &advertiser_address, - phy_t advertiser_phy, - uint16_t periodic_advertising_interval, - pal::clock_accuracy_t clock_accuracy - ) = 0; - - /** Called after a periodic advertising report event. - * - * @param sync_handle Periodic advertising sync handle - * @param tx_power TX power. - * @param rssi Received signal strength. - * @param data_status Status to indicate the completeness of the payload. - * @param data_length Periodic advertisement payload length. - * @param data Periodic advertisement payload. - */ - virtual void on_periodic_advertising_report( - sync_handle_t sync_handle, - advertising_power_t tx_power, - rssi_t rssi, - advertising_data_status_t data_status, - uint8_t data_length, - const uint8_t *data - ) = 0; - - /** Called on periodic advertising sync loss event. - * - * @param sync_handle Advertising sync handle' - */ - virtual void on_periodic_advertising_sync_loss( - sync_handle_t sync_handle - ) = 0; - - /** Called when scanning times out. - */ - virtual void on_scan_timeout() = 0; - - /** Called when advertising set stops advertising. - * - * @param status SUCCESS if connection has been established. - * @param advertising_handle Advertising set handle. - * @param advertising_handle Connection handle. - * @param number_of_completed_extended_advertising_events Number of events created during before advertising end. - */ - virtual void on_advertising_set_terminated( - hci_error_code_t status, - advertising_handle_t advertising_handle, - connection_handle_t connection_handle, - uint8_t number_of_completed_extended_advertising_events - ) = 0; - - /** Called when a device receives a scan request from an active scanning device. - * - * @param advertising_handle Advertising set handle. - * @param scanner_address_type Peer address type. - * @param address Peer address. - */ - virtual void on_scan_request_received( - advertising_handle_t advertising_handle, - connection_peer_address_type_t scanner_address_type, - const address_t &address - ) = 0; - - virtual void on_connection_update_complete( - hci_error_code_t status, - connection_handle_t connection_handle, - uint16_t connection_interval, - uint16_t connection_latency, - uint16_t supervision_timeout - ) = 0; - - virtual void on_remote_connection_parameter( - connection_handle_t connection_handle, - uint16_t connection_interval_min, - uint16_t connection_interval_max, - uint16_t connection_latency, - uint16_t supervision_timeout - ) = 0; - }; +public: /** * Initialisation of the instance. An implementation can use this function @@ -256,7 +360,9 @@ struct Gap { * @return BLE_ERROR_NONE if the request has been successfully sent or the * appropriate error otherwise. */ - virtual ble_error_t initialize() = 0; + ble_error_t initialize() { + return impl()->initialize_(); + } /** * Termination of the instance. An implementation can use this function @@ -269,7 +375,9 @@ struct Gap { * @return BLE_ERROR_NONE if the request has been successfully sent or the * appropriate error otherwise. */ - virtual ble_error_t terminate() = 0; + ble_error_t terminate() { + return impl()->terminate_(); + } /** * Return the public device address. @@ -279,7 +387,9 @@ struct Gap { * * @return the public device address. */ - virtual address_t get_device_address() = 0; + address_t get_device_address() { + return impl()->get_device_address_(); + } /** * Return the current random address. @@ -289,7 +399,9 @@ struct Gap { * * @return the random device address. */ - virtual address_t get_random_address() = 0; + address_t get_random_address() { + return impl()->get_random_address_(); + } /** * Set the random address which will used be during scan, connection or @@ -303,7 +415,9 @@ struct Gap { * @return BLE_ERROR_NONE if the request has been successfully sent or the * appropriate error otherwise. */ - virtual ble_error_t set_random_address(const address_t &address) = 0; + ble_error_t set_random_address(const address_t &address) { + return impl()->set_random_address_(address); + } /** * Set the random device address used by an advertising set. @@ -325,10 +439,15 @@ struct Gap { * @note See Bluetooth 5 Vol 2, Part E: 7.8.52 LE Set Advertising Set Random * Address Command */ - virtual ble_error_t set_advertising_set_random_address( + ble_error_t set_advertising_set_random_address( advertising_handle_t advertising_handle, const address_t &address - ) = 0; + ) { + return impl()->set_advertising_set_random_address_( + advertising_handle, + address + ); + } /** * Set the advertising parameters which will be used during the advertising @@ -387,7 +506,7 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.5 LE set advertising parameters * command. */ - virtual ble_error_t set_advertising_parameters( + ble_error_t set_advertising_parameters( uint16_t advertising_interval_min, uint16_t advertising_interval_max, advertising_type_t advertising_type, @@ -396,7 +515,18 @@ struct Gap { const address_t &peer_address, advertising_channel_map_t advertising_channel_map, advertising_filter_policy_t advertising_filter_policy - ) = 0; + ) { + return impl()->set_advertising_parameters_( + advertising_interval_min, + advertising_interval_max, + advertising_type, + own_address_type, + peer_address_type, + peer_address, + advertising_channel_map, + advertising_filter_policy + ); + } /** * Define the advertising parameters of an advertising set. @@ -457,7 +587,7 @@ struct Gap { * @pre @p advertising_handle should not be enabled when this command is * issued. */ - virtual ble_error_t set_extended_advertising_parameters( + ble_error_t set_extended_advertising_parameters( advertising_handle_t advertising_handle, advertising_event_properties_t event_properties, advertising_interval_t primary_advertising_interval_min, @@ -473,7 +603,25 @@ struct Gap { phy_t secondary_phy, uint8_t advertising_sid, bool scan_request_notification - ) = 0; + ) { + return impl()->set_extended_advertising_parameters_( + advertising_handle, + event_properties, + primary_advertising_interval_min, + primary_advertising_interval_max, + primary_advertising_channel_map, + own_address_type, + peer_address_type, + peer_address, + advertising_filter_policy, + advertising_power, + primary_advertising_phy, + secondary_advertising_max_skip, + secondary_phy, + advertising_sid, + scan_request_notification + ); + } /** * Configure periodic advertising parameters of an advertising set. @@ -501,12 +649,19 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.61 LE Set Periodic Advertising * Parameters Command */ - virtual ble_error_t set_periodic_advertising_parameters( + ble_error_t set_periodic_advertising_parameters( advertising_handle_t advertising_handle, periodic_advertising_interval_t periodic_advertising_min, periodic_advertising_interval_t periodic_advertising_max, bool advertise_power - ) = 0; + ) { + return impl()->set_periodic_advertising_parameters( + advertising_handle, + periodic_advertising_min, + periodic_advertising_max, + advertise_power + ); + } /** * Set the data sends in advertising packet. If the advertising is @@ -525,10 +680,15 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.5 LE set advertising data * command. */ - virtual ble_error_t set_advertising_data( + ble_error_t set_advertising_data( uint8_t advertising_data_length, const advertising_data_t &advertising_data - ) = 0; + ) { + return impl()->set_advertising_data_( + advertising_data_length, + advertising_data + ); + } /** * Set data in advertising PDUs. @@ -561,13 +721,21 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.54 LE set extended advertising * data command. */ - virtual ble_error_t set_extended_advertising_data( + ble_error_t set_extended_advertising_data( advertising_handle_t advertising_handle, advertising_fragment_description_t operation, bool minimize_fragmentation, uint8_t advertising_data_size, const uint8_t *advertising_data - ) = 0; + ) { + return impl()->set_extended_advertising_data_( + advertising_handle, + operation, + minimize_fragmentation, + advertising_data_size, + advertising_data + ); + } /** * Set the data used in periodic advertising PDUs. @@ -594,12 +762,19 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.62 LE set periodic advertising * data command. */ - virtual ble_error_t set_periodic_advertising_data( + ble_error_t set_periodic_advertising_data( advertising_handle_t advertising_handle, advertising_fragment_description_t fragment_description, uint8_t advertising_data_size, const uint8_t *advertising_data - ) = 0; + ) { + return impl()->set_periodic_advertising_data_( + advertising_handle, + fragment_description, + advertising_data_size, + advertising_data + ); + } /** * Set the data sends in scan response packets. If the advertising is @@ -618,10 +793,15 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.8 LE set scan response data * command. */ - virtual ble_error_t set_scan_response_data( + ble_error_t set_scan_response_data( uint8_t scan_response_data_length, const advertising_data_t &scan_response_data - ) = 0; + ) { + return impl()->set_scan_response_data_( + scan_response_data_length, + scan_response_data + ); + } /** * Set the data sends in extended scan response packets. If the advertising @@ -648,13 +828,21 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.55 LE set extended scan response * data command. */ - virtual ble_error_t set_extended_scan_response_data( + ble_error_t set_extended_scan_response_data( advertising_handle_t advertising_handle, advertising_fragment_description_t operation, bool minimize_fragmentation, uint8_t scan_response_data_size, const uint8_t *scan_response_data - ) = 0; + ) { + return impl()->set_extended_scan_response_data_( + advertising_handle, + operation, + minimize_fragmentation, + scan_response_data_size, + scan_response_data + ); + } /** * Start or stop advertising. @@ -696,7 +884,9 @@ struct Gap { * @note Successfull connection shall emit a ConnectionComplete event. It * also means advertising is disabled. */ - virtual ble_error_t advertising_enable(bool enable) = 0; + ble_error_t advertising_enable(bool enable) { + return impl()->advertising_enable_(enable); + } /** * Start of stop advertising of extended advertising sets. @@ -733,13 +923,21 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.56 LE extended advertising enable * command. */ - virtual ble_error_t extended_advertising_enable( + ble_error_t extended_advertising_enable( bool enable, uint8_t number_of_sets, const advertising_handle_t *handles, const uint16_t *durations, const uint8_t *max_extended_advertising_events - ) = 0; + ) { + return impl()->extended_advertising_enable_( + enable, + number_of_sets, + handles, + durations, + max_extended_advertising_events + ); + } /** * Enable or disable periodic advertising of an advertising set. @@ -756,10 +954,12 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.63 LE periodic advertising enable * command. */ - virtual ble_error_t periodic_advertising_enable( + ble_error_t periodic_advertising_enable( bool enable, advertising_handle_t advertising_handle - ) = 0; + ) { + return impl()->periodic_advertising_enable_(enable, advertising_handle); + } /** * Query the maximum data length the controller supports in an advertising @@ -771,7 +971,9 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.57 LE read maximum advertising * data length command. */ - virtual uint16_t get_maximum_advertising_data_length() = 0; + uint16_t get_maximum_advertising_data_length() { + return impl()->get_maximum_advertising_data_length_(); + } /** * Query the maximum data length the controller supports in an advertising set @@ -780,7 +982,9 @@ struct Gap { * @return The length in byte the controller can support in an advertising set * for connectable advertising. */ - virtual uint16_t get_maximum_connectable_advertising_data_length() = 0; + uint16_t get_maximum_connectable_advertising_data_length() { + return impl()->get_maximum_connectable_advertising_data_length_(); + } /** * Query the maximum payload length for a single HCI packet carrying partial @@ -788,7 +992,9 @@ struct Gap { * * @return Max size of the HCI packet transporting the data. */ - virtual uint8_t get_maximum_hci_advertising_data_length() = 0; + uint8_t get_maximum_hci_advertising_data_length() { + return impl()->get_maximum_hci_advertising_data_length_(); + } /** * Query the maximum number of concurrent advertising sets that is supported @@ -800,7 +1006,9 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.58 LE number of supported * advertising sets command. */ - virtual uint8_t get_max_number_of_advertising_sets() = 0; + uint8_t get_max_number_of_advertising_sets() { + return impl()->get_max_number_of_advertising_sets_(); + } /** * Remove an advertising set from the controller. @@ -820,9 +1028,11 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.59 LE remove advertising set * command. */ - virtual ble_error_t remove_advertising_set( + ble_error_t remove_advertising_set( advertising_handle_t advertising_handle - ) = 0; + ) { + return impl()->remove_advertising_set_(advertising_handle); + } /** * Remove all advertising sets maintained by the controller. @@ -835,7 +1045,9 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.60 LE clear advertising sets * command. */ - virtual ble_error_t clear_advertising_sets() = 0; + ble_error_t clear_advertising_sets() { + return impl()->clear_advertising_sets_(); + } /** @@ -865,13 +1077,21 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.10 LE set scan parameters * command. */ - virtual ble_error_t set_scan_parameters( + ble_error_t set_scan_parameters( bool active_scanning, uint16_t scan_interval, uint16_t scan_window, own_address_type_t own_address_type, scanning_filter_policy_t filter_policy - ) = 0; + ) { + return impl()->set_scan_parameters_( + active_scanning, + scan_interval, + scan_window, + own_address_type, + filter_policy + ); + } /** * Set extended scan parameters to be used on advertising channels. @@ -901,14 +1121,23 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.64 LE set extended scan parameters * command. */ - virtual ble_error_t set_extended_scan_parameters( + ble_error_t set_extended_scan_parameters( own_address_type_t own_address_type, scanning_filter_policy_t filter_policy, phy_set_t scanning_phys, const bool *active_scanning, const uint16_t *scan_interval, const uint16_t *scan_window - ) = 0; + ) { + return impl()->set_extended_scan_parameters_( + own_address_type, + filter_policy, + scanning_phys, + active_scanning, + scan_interval, + scan_window + ); + } /** * Start/stop scanning process. @@ -931,10 +1160,12 @@ struct Gap { * * @note: See Bluetooth 5 Vol 2 PartE: 7.8.11 LE set scan enable command. */ - virtual ble_error_t scan_enable( + ble_error_t scan_enable( bool enable, bool filter_duplicates - ) = 0; + ) { + return impl()->scan_enable_(enable, filter_duplicates); + } /** * Enable or disable extended scanning. @@ -957,12 +1188,19 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.65 LE set extended scan enable * command. */ - virtual ble_error_t extended_scan_enable( + ble_error_t extended_scan_enable( bool enable, duplicates_filter_t filter_duplicates, uint16_t duration, uint16_t period - ) = 0; + ) { + return impl()->extended_scan_enable_( + enable, + filter_duplicates, + duration, + period + ); + } /** * Synchronize an observer with a periodic advertising broadcaster. @@ -993,14 +1231,23 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.67 LE periodic advertising create * sync command. */ - virtual ble_error_t periodic_advertising_create_sync( + ble_error_t periodic_advertising_create_sync( bool use_periodic_advertiser_list, uint8_t advertising_sid, peer_address_type_t peer_address_type, const address_t &peer_address, uint16_t allowed_skip, uint16_t sync_timeout - ) = 0; + ) { + return impl()->periodic_advertising_create_sync_( + use_periodic_advertiser_list, + advertising_sid, + peer_address_type, + peer_address, + allowed_skip, + sync_timeout + ); + } /** * Cancel the establishment of synchronization with a periodic advertising @@ -1014,7 +1261,9 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.68 LE periodic advertising create * sync cancel command. */ - virtual ble_error_t cancel_periodic_advertising_create_sync() = 0; + ble_error_t cancel_periodic_advertising_create_sync() { + return impl()->cancel_periodic_advertising_create_sync_(); + } /** * Stop reception of the periodic advertising identified by @p sync_handle. @@ -1029,9 +1278,11 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.69 LE periodic advertising * terminate sync command. */ - virtual ble_error_t periodic_advertising_terminate_sync( + ble_error_t periodic_advertising_terminate_sync( sync_handle_t sync_handle - ) = 0; + ) { + return impl()->periodic_advertising_terminate_sync_(sync_handle); + } /** * Add a device to the periodic advertiser list stored in the controller. @@ -1056,11 +1307,17 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.70 LE add device to periodic * advertising list command. */ - virtual ble_error_t add_device_to_periodic_advertiser_list( + ble_error_t add_device_to_periodic_advertiser_list( advertising_peer_address_type_t advertiser_address_type, const address_t &advertiser_address, uint8_t advertising_sid - ) = 0; + ) { + return impl()->add_device_to_periodic_advertiser_list_( + advertiser_address_type, + advertiser_address, + advertising_sid + ); + } /** * Remove a device from the periodic advertiser list. @@ -1080,11 +1337,17 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.71 LE remove device from periodic * advertising list command. */ - virtual ble_error_t remove_device_from_periodic_advertiser_list( + ble_error_t remove_device_from_periodic_advertiser_list( advertising_peer_address_type_t advertiser_address_type, const address_t &advertiser_address, uint8_t advertising_sid - ) = 0; + ) { + return impl()->remove_device_from_periodic_advertiser_list_( + advertiser_address_type, + advertiser_address, + advertising_sid + ); + } /** * Clear all devices from the list of periodic advertisers. @@ -1097,7 +1360,9 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.72 LE clear periodic advertising * list command. */ - virtual ble_error_t clear_periodic_advertiser_list() = 0; + ble_error_t clear_periodic_advertiser_list() { + return impl()->clear_periodic_advertiser_list_(); + } /** * Return the total number of entries that can be stored by the periodic @@ -1107,7 +1372,9 @@ struct Gap { * * @note We (wrongfully) assume that value doesn't change over time. */ - virtual uint8_t read_periodic_advertiser_list_size() = 0; + uint8_t read_periodic_advertiser_list_size() { + return impl()->read_periodic_advertiser_list_size_(); + } /** * Create a new le connection to a connectable advertiser. @@ -1180,7 +1447,7 @@ struct Gap { * * @note: See Bluetooth 5 Vol 2 PartE: 7.8.12 LE create connection command. */ - virtual ble_error_t create_connection( + ble_error_t create_connection( uint16_t scan_interval, uint16_t scan_window, initiator_policy_t initiator_policy, @@ -1193,7 +1460,22 @@ struct Gap { uint16_t supervision_timeout, uint16_t minimum_connection_event_length, uint16_t maximum_connection_event_length - ) = 0; + ) { + return impl()->create_connection_( + scan_interval, + scan_window, + initiator_policy, + peer_address_type, + peer_address, + own_address_type, + connection_interval_min, + connection_interval_max, + connection_latency, + supervision_timeout, + minimum_connection_event_length, + maximum_connection_event_length + ); + } /** * Create a new le connection to a connectable advertiser. @@ -1272,7 +1554,7 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.66 LE extended create connection * command. */ - virtual ble_error_t extended_create_connection( + ble_error_t extended_create_connection( initiator_policy_t initiator_policy, own_address_type_t own_address_type, peer_address_type_t peer_address_type, @@ -1286,7 +1568,23 @@ struct Gap { const uint16_t *supervision_timeouts, const uint16_t *minimum_connection_event_lengths, const uint16_t *maximum_connection_event_lengths - ) = 0; + ) { + return impl()->extended_create_connection_( + initiator_policy, + own_address_type, + peer_address_type, + peer_address, + initiating_phys, + scan_intervals, + scan_windows, + connection_intervals_min, + connection_intervals_max, + connection_latencies, + supervision_timeouts, + minimum_connection_event_lengths, + maximum_connection_event_lengths + ); + } /** * Cancel the ongoing connection creation process. @@ -1297,7 +1595,9 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.13 LE create connection cancel * command. */ - virtual ble_error_t cancel_connection_creation() = 0; + ble_error_t cancel_connection_creation() { + return impl()->cancel_connection_creation_(); + } /** * Return the number of total whitelist entries that can be stored in the @@ -1311,7 +1611,9 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.14 LE read white list size * command. */ - virtual uint8_t read_white_list_capacity() = 0; + uint8_t read_white_list_capacity() { + return impl()->read_white_list_capacity_(); + } /** * Clear the whitelist stored in the LE subsystem. @@ -1324,7 +1626,9 @@ struct Gap { * * @note: See Bluetooth 5 Vol 2 PartE: 7.8.15 LE clear white list command. */ - virtual ble_error_t clear_whitelist() = 0; + ble_error_t clear_whitelist() { + return impl()->clear_whitelist_(); + } /** * Add a device to the LE subsystem Whitelist. @@ -1343,10 +1647,15 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.16 LE add device to white list * command. */ - virtual ble_error_t add_device_to_whitelist( + ble_error_t add_device_to_whitelist( whitelist_address_type_t address_type, address_t address - ) = 0; + ) { + return impl()->add_device_to_whitelist_( + address_type, + address + ); + } /** * Remove a device from the LE subsystem Whitelist. @@ -1365,10 +1674,15 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.17 LE remove device from white * list command. */ - virtual ble_error_t remove_device_from_whitelist( + ble_error_t remove_device_from_whitelist( whitelist_address_type_t address_type, address_t address - ) = 0; + ) { + return impl()->remove_device_from_whitelist_( + address_type, + address + ); + } /** * Start a connection update procedure. @@ -1427,7 +1741,7 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.18 LE Connection update command. * */ - virtual ble_error_t connection_parameters_update( + ble_error_t connection_parameters_update( connection_handle_t connection, uint16_t connection_interval_min, uint16_t connection_interval_max, @@ -1435,7 +1749,17 @@ struct Gap { uint16_t supervision_timeout, uint16_t minimum_connection_event_length, uint16_t maximum_connection_event_length - ) = 0; + ) { + return impl()->connection_parameters_update_( + connection, + connection_interval_min, + connection_interval_max, + connection_latency, + supervision_timeout, + minimum_connection_event_length, + maximum_connection_event_length + ); + } /** * Accept connection parameter request. @@ -1494,7 +1818,7 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.31 LE remote connection parameter * request reply command. */ - virtual ble_error_t accept_connection_parameter_request( + ble_error_t accept_connection_parameter_request( connection_handle_t connection_handle, uint16_t interval_min, uint16_t interval_max, @@ -1502,7 +1826,17 @@ struct Gap { uint16_t supervision_timeout, uint16_t minimum_connection_event_length, uint16_t maximum_connection_event_length - ) = 0; + ) { + return impl()->accept_connection_parameter_request_( + connection_handle, + interval_min, + interval_max, + latency, + supervision_timeout, + minimum_connection_event_length, + maximum_connection_event_length + ); + } /** * Reject a connection parameter update request. @@ -1519,10 +1853,15 @@ struct Gap { * @note: See Bluetooth 5 Vol 2 PartE: 7.8.32 LE Remote Connection Parameter * Request Negative Reply Command. */ - virtual ble_error_t reject_connection_parameter_request( + ble_error_t reject_connection_parameter_request( connection_handle_t connection_handle, hci_error_code_t rejection_reason - ) = 0; + ) { + return impl()->reject_connection_parameter_request_( + connection_handle, + rejection_reason + ); + } /** * Start a disconnection procedure. @@ -1540,10 +1879,12 @@ struct Gap { * * @note: See Bluetooth 5 Vol 2 PartE: 7.1.6 disconenct command. */ - virtual ble_error_t disconnect( + ble_error_t disconnect( connection_handle_t connection, disconnection_reason_t disconnection_reason - ) = 0; + ) { + return impl()->disconnect_(connection, disconnection_reason); + } /** Check if privacy feature is supported by implementation * @@ -1551,7 +1892,9 @@ struct Gap { * * @note: See Bluetooth 5 Vol 3 Part C: 10.7 Privacy feature. */ - virtual bool is_privacy_supported() = 0; + bool is_privacy_supported() { + return impl()->is_privacy_supported_(); + } /** Enable or disable private addresses resolution * @@ -1562,9 +1905,11 @@ struct Gap { * * @note: See Bluetooth 5 Vol 2 PartE: 7.8.44 LE Set Address Resolution Enable command. */ - virtual ble_error_t set_address_resolution( + ble_error_t set_address_resolution( bool enable - ) = 0; + ) { + return impl()->set_address_resolution_(enable); + } /** * Checked support for a feature in the link controller. @@ -1572,32 +1917,45 @@ struct Gap { * @param feature feature to be checked. * @return TRUE if feature is supported. */ - virtual bool is_feature_supported( + bool is_feature_supported( controller_supported_features_t feature - ) = 0; + ) { + return impl()->is_feature_supported_(feature); + } /** * @see Gap::readPhy */ - virtual ble_error_t read_phy(connection_handle_t connection) = 0; + ble_error_t read_phy(connection_handle_t connection) { + return impl()->read_phy_(connection); + } /** * @see Gap::setPreferredPhys */ - virtual ble_error_t set_preferred_phys( + ble_error_t set_preferred_phys( const phy_set_t &tx_phys, const phy_set_t &rx_phys - ) = 0; + ) { + return impl()->set_preferred_phys_(tx_phys, rx_phys); + } /** * @see Gap::setPhy */ - virtual ble_error_t set_phy( + ble_error_t set_phy( connection_handle_t connection, const phy_set_t &tx_phys, const phy_set_t &rx_phys, coded_symbol_per_bit_t coded_symbol - ) = 0; + ) { + return impl()->set_phy_( + connection, + tx_phys, + rx_phys, + coded_symbol + ); + } /** * Register a callback which will handle Gap events. @@ -1637,7 +1995,7 @@ protected: { } - virtual ~Gap() + ~Gap() { }