Loading system/gd/hci/cert/le_advertising_manager_test.py +11 −6 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,8 @@ class LeAdvertisingManagerTest(GdFacadeOnlyBaseTestClass): def test_le_ad_scan_dut_advertises(self): def test_le_ad_scan_dut_advertises(self): self.register_for_le_event(hci_packets.SubeventCode.ADVERTISING_REPORT) self.register_for_le_event(hci_packets.SubeventCode.ADVERTISING_REPORT) self.register_for_le_event( hci_packets.SubeventCode.EXTENDED_ADVERTISING_REPORT) with EventCallbackStream( with EventCallbackStream( self.cert_device.hci.FetchLeSubevents( self.cert_device.hci.FetchLeSubevents( empty_proto.Empty())) as hci_le_event_stream: empty_proto.Empty())) as hci_le_event_stream: Loading @@ -82,16 +84,19 @@ class LeAdvertisingManagerTest(GdFacadeOnlyBaseTestClass): self.enqueue_hci_command( self.enqueue_hci_command( hci_packets.LeSetRandomAddressBuilder('0C:05:04:03:02:01'), hci_packets.LeSetRandomAddressBuilder('0C:05:04:03:02:01'), True) True) scan_parameters = hci_packets.PhyScanParameters() scan_parameters.le_scan_type = hci_packets.LeScanType.ACTIVE scan_parameters.le_scan_interval = 40 scan_parameters.le_scan_window = 20 self.enqueue_hci_command( self.enqueue_hci_command( hci_packets.LeSetScanParametersBuilder( hci_packets.LeSetExtendedScanParametersBuilder( hci_packets.LeScanType.ACTIVE, 40, 20, hci_packets.AddressType.RANDOM_DEVICE_ADDRESS, hci_packets.AddressType.RANDOM_DEVICE_ADDRESS, hci_packets.LeSetScanningFilterPolicy.ACCEPT_ALL), True) hci_packets.LeSetScanningFilterPolicy.ACCEPT_ALL, 1, [scan_parameters]), True) self.enqueue_hci_command( self.enqueue_hci_command( hci_packets.LeSetScanEnableBuilder( hci_packets.LeSetExtendedScanEnableBuilder( hci_packets.Enable.ENABLED, hci_packets.Enable.ENABLED, hci_packets.Enable.DISABLED), # duplicate filtering hci_packets.FilterDuplicates.DISABLED, 0, 0), True) True) # DUT Advertises # DUT Advertises gap_name = hci_packets.GapData() gap_name = hci_packets.GapData() Loading system/gd/hci/le_advertising_manager.cc +34 −3 Original line number Original line Diff line number Diff line Loading @@ -42,6 +42,39 @@ struct Advertiser { common::Callback<void(ErrorCode, uint8_t, uint8_t)> set_terminated_callback; common::Callback<void(ErrorCode, uint8_t, uint8_t)> set_terminated_callback; }; }; ExtendedAdvertisingConfig::ExtendedAdvertisingConfig(const AdvertisingConfig& config) : AdvertisingConfig(config) { switch (config.event_type) { case AdvertisingEventType::ADV_IND: connectable = true; scannable = true; break; case AdvertisingEventType::ADV_DIRECT_IND: connectable = true; directed = true; high_duty_directed_connectable = true; break; case AdvertisingEventType::ADV_SCAN_IND: scannable = true; break; case AdvertisingEventType::ADV_NONCONN_IND: break; case AdvertisingEventType::ADV_DIRECT_IND_LOW: connectable = true; directed = true; break; default: LOG_WARN("Unknown event type"); break; } if (config.address_type == AddressType::PUBLIC_DEVICE_ADDRESS) { own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS; } else if (config.address_type == AddressType::RANDOM_DEVICE_ADDRESS) { own_address_type = OwnAddressType::RANDOM_DEVICE_ADDRESS; } // TODO(b/149221472): Support fragmentation operation = Operation::COMPLETE_ADVERTISMENT; } struct LeAdvertisingManager::impl { struct LeAdvertisingManager::impl { impl(Module* module) : module_(module), le_advertising_interface_(nullptr), num_instances_(0) {} impl(Module* module) : module_(module), le_advertising_interface_(nullptr), num_instances_(0) {} Loading Loading @@ -172,9 +205,7 @@ struct LeAdvertisingManager::impl { module_handler_); module_handler_); break; break; case (AdvertisingApiType::LE_5_0): { case (AdvertisingApiType::LE_5_0): { ExtendedAdvertisingConfig new_config; ExtendedAdvertisingConfig new_config = config; AdvertisingConfig* base_config_ptr = &new_config; *(base_config_ptr) = config; new_config.legacy_pdus = true; new_config.legacy_pdus = true; create_extended_advertiser(id, new_config, scan_callback, set_terminated_callback, handler); create_extended_advertiser(id, new_config, scan_callback, set_terminated_callback, handler); } break; } break; Loading system/gd/hci/le_advertising_manager.h +13 −11 Original line number Original line Diff line number Diff line Loading @@ -41,21 +41,23 @@ class AdvertisingConfig { class ExtendedAdvertisingConfig : public AdvertisingConfig { class ExtendedAdvertisingConfig : public AdvertisingConfig { public: public: bool connectable; bool connectable = false; bool scannable; bool scannable = false; bool directed; bool directed = false; bool high_duty_directed_connectable; bool high_duty_directed_connectable = false; bool legacy_pdus; bool legacy_pdus = false; bool anonymous; bool anonymous = false; bool include_tx_power; bool include_tx_power = false; bool use_le_coded_phy; // Primary advertisement PHY is LE Coded bool use_le_coded_phy; // Primary advertisement PHY is LE Coded uint8_t secondary_max_skip; // maximum advertising events to be skipped, 0x0 send AUX_ADV_IND prior ot the next event uint8_t secondary_max_skip; // maximum advertising events to be skipped, 0x0 send AUX_ADV_IND prior ot the next event SecondaryPhyType secondary_advertising_phy; SecondaryPhyType secondary_advertising_phy; uint8_t sid; uint8_t sid = 0x00; Enable enable_scan_request_notifications; Enable enable_scan_request_notifications = Enable::DISABLED; OwnAddressType own_address_type; OwnAddressType own_address_type; Operation operation; Operation operation; // TODO(b/149221472): Support fragmentation FragmentPreference fragment_preference; FragmentPreference fragment_preference = FragmentPreference::CONTROLLER_SHOULD_NOT; ExtendedAdvertisingConfig() = default; ExtendedAdvertisingConfig(const AdvertisingConfig& config); }; }; using AdvertiserId = int32_t; using AdvertiserId = int32_t; Loading Loading
system/gd/hci/cert/le_advertising_manager_test.py +11 −6 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,8 @@ class LeAdvertisingManagerTest(GdFacadeOnlyBaseTestClass): def test_le_ad_scan_dut_advertises(self): def test_le_ad_scan_dut_advertises(self): self.register_for_le_event(hci_packets.SubeventCode.ADVERTISING_REPORT) self.register_for_le_event(hci_packets.SubeventCode.ADVERTISING_REPORT) self.register_for_le_event( hci_packets.SubeventCode.EXTENDED_ADVERTISING_REPORT) with EventCallbackStream( with EventCallbackStream( self.cert_device.hci.FetchLeSubevents( self.cert_device.hci.FetchLeSubevents( empty_proto.Empty())) as hci_le_event_stream: empty_proto.Empty())) as hci_le_event_stream: Loading @@ -82,16 +84,19 @@ class LeAdvertisingManagerTest(GdFacadeOnlyBaseTestClass): self.enqueue_hci_command( self.enqueue_hci_command( hci_packets.LeSetRandomAddressBuilder('0C:05:04:03:02:01'), hci_packets.LeSetRandomAddressBuilder('0C:05:04:03:02:01'), True) True) scan_parameters = hci_packets.PhyScanParameters() scan_parameters.le_scan_type = hci_packets.LeScanType.ACTIVE scan_parameters.le_scan_interval = 40 scan_parameters.le_scan_window = 20 self.enqueue_hci_command( self.enqueue_hci_command( hci_packets.LeSetScanParametersBuilder( hci_packets.LeSetExtendedScanParametersBuilder( hci_packets.LeScanType.ACTIVE, 40, 20, hci_packets.AddressType.RANDOM_DEVICE_ADDRESS, hci_packets.AddressType.RANDOM_DEVICE_ADDRESS, hci_packets.LeSetScanningFilterPolicy.ACCEPT_ALL), True) hci_packets.LeSetScanningFilterPolicy.ACCEPT_ALL, 1, [scan_parameters]), True) self.enqueue_hci_command( self.enqueue_hci_command( hci_packets.LeSetScanEnableBuilder( hci_packets.LeSetExtendedScanEnableBuilder( hci_packets.Enable.ENABLED, hci_packets.Enable.ENABLED, hci_packets.Enable.DISABLED), # duplicate filtering hci_packets.FilterDuplicates.DISABLED, 0, 0), True) True) # DUT Advertises # DUT Advertises gap_name = hci_packets.GapData() gap_name = hci_packets.GapData() Loading
system/gd/hci/le_advertising_manager.cc +34 −3 Original line number Original line Diff line number Diff line Loading @@ -42,6 +42,39 @@ struct Advertiser { common::Callback<void(ErrorCode, uint8_t, uint8_t)> set_terminated_callback; common::Callback<void(ErrorCode, uint8_t, uint8_t)> set_terminated_callback; }; }; ExtendedAdvertisingConfig::ExtendedAdvertisingConfig(const AdvertisingConfig& config) : AdvertisingConfig(config) { switch (config.event_type) { case AdvertisingEventType::ADV_IND: connectable = true; scannable = true; break; case AdvertisingEventType::ADV_DIRECT_IND: connectable = true; directed = true; high_duty_directed_connectable = true; break; case AdvertisingEventType::ADV_SCAN_IND: scannable = true; break; case AdvertisingEventType::ADV_NONCONN_IND: break; case AdvertisingEventType::ADV_DIRECT_IND_LOW: connectable = true; directed = true; break; default: LOG_WARN("Unknown event type"); break; } if (config.address_type == AddressType::PUBLIC_DEVICE_ADDRESS) { own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS; } else if (config.address_type == AddressType::RANDOM_DEVICE_ADDRESS) { own_address_type = OwnAddressType::RANDOM_DEVICE_ADDRESS; } // TODO(b/149221472): Support fragmentation operation = Operation::COMPLETE_ADVERTISMENT; } struct LeAdvertisingManager::impl { struct LeAdvertisingManager::impl { impl(Module* module) : module_(module), le_advertising_interface_(nullptr), num_instances_(0) {} impl(Module* module) : module_(module), le_advertising_interface_(nullptr), num_instances_(0) {} Loading Loading @@ -172,9 +205,7 @@ struct LeAdvertisingManager::impl { module_handler_); module_handler_); break; break; case (AdvertisingApiType::LE_5_0): { case (AdvertisingApiType::LE_5_0): { ExtendedAdvertisingConfig new_config; ExtendedAdvertisingConfig new_config = config; AdvertisingConfig* base_config_ptr = &new_config; *(base_config_ptr) = config; new_config.legacy_pdus = true; new_config.legacy_pdus = true; create_extended_advertiser(id, new_config, scan_callback, set_terminated_callback, handler); create_extended_advertiser(id, new_config, scan_callback, set_terminated_callback, handler); } break; } break; Loading
system/gd/hci/le_advertising_manager.h +13 −11 Original line number Original line Diff line number Diff line Loading @@ -41,21 +41,23 @@ class AdvertisingConfig { class ExtendedAdvertisingConfig : public AdvertisingConfig { class ExtendedAdvertisingConfig : public AdvertisingConfig { public: public: bool connectable; bool connectable = false; bool scannable; bool scannable = false; bool directed; bool directed = false; bool high_duty_directed_connectable; bool high_duty_directed_connectable = false; bool legacy_pdus; bool legacy_pdus = false; bool anonymous; bool anonymous = false; bool include_tx_power; bool include_tx_power = false; bool use_le_coded_phy; // Primary advertisement PHY is LE Coded bool use_le_coded_phy; // Primary advertisement PHY is LE Coded uint8_t secondary_max_skip; // maximum advertising events to be skipped, 0x0 send AUX_ADV_IND prior ot the next event uint8_t secondary_max_skip; // maximum advertising events to be skipped, 0x0 send AUX_ADV_IND prior ot the next event SecondaryPhyType secondary_advertising_phy; SecondaryPhyType secondary_advertising_phy; uint8_t sid; uint8_t sid = 0x00; Enable enable_scan_request_notifications; Enable enable_scan_request_notifications = Enable::DISABLED; OwnAddressType own_address_type; OwnAddressType own_address_type; Operation operation; Operation operation; // TODO(b/149221472): Support fragmentation FragmentPreference fragment_preference; FragmentPreference fragment_preference = FragmentPreference::CONTROLLER_SHOULD_NOT; ExtendedAdvertisingConfig() = default; ExtendedAdvertisingConfig(const AdvertisingConfig& config); }; }; using AdvertiserId = int32_t; using AdvertiserId = int32_t; Loading