Loading tools/rootcanal/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -308,6 +308,7 @@ python_test_host { ":llcp_packets_python3_gen", "py/bluetooth.py", "py/controller.py", "test/LL/*.py", "test/LL/CIS/CEN/*.py", "test/LL/CIS/PER/*.py", "test/LL/CON_/CEN/*.py", Loading tools/rootcanal/model/controller/link_layer_controller.cc +5 −0 Original line number Diff line number Diff line Loading @@ -1237,6 +1237,7 @@ ErrorCode LinkLayerController::LeSetScanEnable(bool enable, if (!enable) { scanner_.scan_enable = false; scanner_.pending_scan_request = {}; scanner_.history.clear(); return ErrorCode::SUCCESS; } Loading Loading @@ -1265,6 +1266,7 @@ ErrorCode LinkLayerController::LeSetScanEnable(bool enable, scanner_.history.clear(); scanner_.timeout = {}; scanner_.periodical_timeout = {}; scanner_.pending_scan_request = {}; scanner_.filter_duplicates = filter_duplicates ? bluetooth::hci::FilterDuplicates::ENABLED : bluetooth::hci::FilterDuplicates::DISABLED; Loading Loading @@ -1394,6 +1396,7 @@ ErrorCode LinkLayerController::LeSetExtendedScanEnable( if (!enable) { scanner_.scan_enable = false; scanner_.pending_scan_request = {}; scanner_.history.clear(); return ErrorCode::SUCCESS; } Loading Loading @@ -1450,6 +1453,7 @@ ErrorCode LinkLayerController::LeSetExtendedScanEnable( scanner_.history.clear(); scanner_.timeout = {}; scanner_.periodical_timeout = {}; scanner_.pending_scan_request = {}; scanner_.filter_duplicates = filter_duplicates; scanner_.duration = duration_ms; scanner_.period = period_ms; Loading Loading @@ -4971,6 +4975,7 @@ void LinkLayerController::LeScanning() { // an HCI_LE_Scan_Timeout event shall be generated. INFO(id_, "Extended Scan Timeout"); scanner_.scan_enable = false; scanner_.pending_scan_request = {}; scanner_.history.clear(); if (IsLeEventUnmasked(SubeventCode::SCAN_TIMEOUT)) { send_event_(bluetooth::hci::LeScanTimeoutBuilder::Create()); Loading tools/rootcanal/test/LL/scan_collision.py 0 → 100644 +124 −0 Original line number Diff line number Diff line # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import hci_packets as hci import link_layer_packets as ll import unittest from hci_packets import ErrorCode from py.bluetooth import Address from py.controller import ControllerTest, generate_rpa class Test(ControllerTest): # Verify that the scanner gracefully handles being disabled before # receiving the response to a scan request. async def test(self): # Test parameters. LL_scanner_scanInterval_MIN = 0x2000 LL_scanner_scanInterval_MAX = 0x2000 LL_scanner_scanWindow_MIN = 0x200 LL_scanner_scanWindow_MAX = 0x200 LL_scanner_Adv_Channel_Map = 0x7 controller = self.controller peer_address = Address('aa:bb:cc:dd:ee:ff') controller.send_cmd( hci.LeSetScanParameters(le_scan_type=hci.LeScanType.ACTIVE, le_scan_interval=LL_scanner_scanInterval_MAX, le_scan_window=LL_scanner_scanWindow_MAX, own_address_type=hci.OwnAddressType.RESOLVABLE_OR_PUBLIC_ADDRESS, scanning_filter_policy=hci.LeScanningFilterPolicy.ACCEPT_ALL)) await self.expect_evt(hci.LeSetScanParametersComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) controller.send_cmd( hci.LeSetScanEnable(le_scan_enable=hci.Enable.ENABLED, filter_duplicates=hci.Enable.DISABLED)) await self.expect_evt(hci.LeSetScanEnableComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) controller.send_ll(ll.LeLegacyAdvertisingPdu(source_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, advertising_type=ll.LegacyAdvertisingType.ADV_SCAN_IND, advertising_data=[]), rssi=-16) await self.expect_evt( hci.LeAdvertisingReport(responses=[ hci.LeAdvertisingResponse(event_type=hci.AdvertisingEventType.ADV_SCAN_IND, address_type=hci.AddressType.RANDOM_DEVICE_ADDRESS, address=peer_address, advertising_data=[], rssi=0xf0) ])) await self.expect_ll( ll.LeScan(source_address=controller.address, destination_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, scanning_address_type=ll.AddressType.PUBLIC)) # Disable the scanner before the scan response is received. controller.send_cmd(hci.LeSetScanEnable(le_scan_enable=hci.Enable.DISABLED)) await self.expect_evt(hci.LeSetScanEnableComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) # Send the scan response now; it should be ignored by the disabled scanner. controller.send_ll(ll.LeScanResponse(source_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, scan_response_data=[]), rssi=-16) # Re-enable the scanner and send the advertising PDU again. # This time expect the scan response to be properly reported. controller.send_cmd( hci.LeSetScanEnable(le_scan_enable=hci.Enable.ENABLED, filter_duplicates=hci.Enable.DISABLED)) await self.expect_evt(hci.LeSetScanEnableComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) controller.send_ll(ll.LeLegacyAdvertisingPdu(source_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, advertising_type=ll.LegacyAdvertisingType.ADV_SCAN_IND, advertising_data=[]), rssi=-16) await self.expect_evt( hci.LeAdvertisingReport(responses=[ hci.LeAdvertisingResponse(event_type=hci.AdvertisingEventType.ADV_SCAN_IND, address_type=hci.AddressType.RANDOM_DEVICE_ADDRESS, address=peer_address, advertising_data=[], rssi=0xf0) ])) await self.expect_ll( ll.LeScan(source_address=controller.address, destination_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, scanning_address_type=ll.AddressType.PUBLIC)) controller.send_ll(ll.LeScanResponse(source_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, scan_response_data=[]), rssi=-16) await self.expect_evt( hci.LeAdvertisingReport(responses=[ hci.LeAdvertisingResponse(event_type=hci.AdvertisingEventType.SCAN_RESPONSE, address_type=hci.AddressType.RANDOM_DEVICE_ADDRESS, address=peer_address, advertising_data=[], rssi=0xf0) ])) tools/rootcanal/test/main.py +1 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ tests = [ 'LMP.LIH.BV_143_C', 'LMP.LIH.BV_144_C', 'LMP.LIH.BV_149_C', 'LL.scan_collision', ] Loading Loading
tools/rootcanal/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -308,6 +308,7 @@ python_test_host { ":llcp_packets_python3_gen", "py/bluetooth.py", "py/controller.py", "test/LL/*.py", "test/LL/CIS/CEN/*.py", "test/LL/CIS/PER/*.py", "test/LL/CON_/CEN/*.py", Loading
tools/rootcanal/model/controller/link_layer_controller.cc +5 −0 Original line number Diff line number Diff line Loading @@ -1237,6 +1237,7 @@ ErrorCode LinkLayerController::LeSetScanEnable(bool enable, if (!enable) { scanner_.scan_enable = false; scanner_.pending_scan_request = {}; scanner_.history.clear(); return ErrorCode::SUCCESS; } Loading Loading @@ -1265,6 +1266,7 @@ ErrorCode LinkLayerController::LeSetScanEnable(bool enable, scanner_.history.clear(); scanner_.timeout = {}; scanner_.periodical_timeout = {}; scanner_.pending_scan_request = {}; scanner_.filter_duplicates = filter_duplicates ? bluetooth::hci::FilterDuplicates::ENABLED : bluetooth::hci::FilterDuplicates::DISABLED; Loading Loading @@ -1394,6 +1396,7 @@ ErrorCode LinkLayerController::LeSetExtendedScanEnable( if (!enable) { scanner_.scan_enable = false; scanner_.pending_scan_request = {}; scanner_.history.clear(); return ErrorCode::SUCCESS; } Loading Loading @@ -1450,6 +1453,7 @@ ErrorCode LinkLayerController::LeSetExtendedScanEnable( scanner_.history.clear(); scanner_.timeout = {}; scanner_.periodical_timeout = {}; scanner_.pending_scan_request = {}; scanner_.filter_duplicates = filter_duplicates; scanner_.duration = duration_ms; scanner_.period = period_ms; Loading Loading @@ -4971,6 +4975,7 @@ void LinkLayerController::LeScanning() { // an HCI_LE_Scan_Timeout event shall be generated. INFO(id_, "Extended Scan Timeout"); scanner_.scan_enable = false; scanner_.pending_scan_request = {}; scanner_.history.clear(); if (IsLeEventUnmasked(SubeventCode::SCAN_TIMEOUT)) { send_event_(bluetooth::hci::LeScanTimeoutBuilder::Create()); Loading
tools/rootcanal/test/LL/scan_collision.py 0 → 100644 +124 −0 Original line number Diff line number Diff line # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import hci_packets as hci import link_layer_packets as ll import unittest from hci_packets import ErrorCode from py.bluetooth import Address from py.controller import ControllerTest, generate_rpa class Test(ControllerTest): # Verify that the scanner gracefully handles being disabled before # receiving the response to a scan request. async def test(self): # Test parameters. LL_scanner_scanInterval_MIN = 0x2000 LL_scanner_scanInterval_MAX = 0x2000 LL_scanner_scanWindow_MIN = 0x200 LL_scanner_scanWindow_MAX = 0x200 LL_scanner_Adv_Channel_Map = 0x7 controller = self.controller peer_address = Address('aa:bb:cc:dd:ee:ff') controller.send_cmd( hci.LeSetScanParameters(le_scan_type=hci.LeScanType.ACTIVE, le_scan_interval=LL_scanner_scanInterval_MAX, le_scan_window=LL_scanner_scanWindow_MAX, own_address_type=hci.OwnAddressType.RESOLVABLE_OR_PUBLIC_ADDRESS, scanning_filter_policy=hci.LeScanningFilterPolicy.ACCEPT_ALL)) await self.expect_evt(hci.LeSetScanParametersComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) controller.send_cmd( hci.LeSetScanEnable(le_scan_enable=hci.Enable.ENABLED, filter_duplicates=hci.Enable.DISABLED)) await self.expect_evt(hci.LeSetScanEnableComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) controller.send_ll(ll.LeLegacyAdvertisingPdu(source_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, advertising_type=ll.LegacyAdvertisingType.ADV_SCAN_IND, advertising_data=[]), rssi=-16) await self.expect_evt( hci.LeAdvertisingReport(responses=[ hci.LeAdvertisingResponse(event_type=hci.AdvertisingEventType.ADV_SCAN_IND, address_type=hci.AddressType.RANDOM_DEVICE_ADDRESS, address=peer_address, advertising_data=[], rssi=0xf0) ])) await self.expect_ll( ll.LeScan(source_address=controller.address, destination_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, scanning_address_type=ll.AddressType.PUBLIC)) # Disable the scanner before the scan response is received. controller.send_cmd(hci.LeSetScanEnable(le_scan_enable=hci.Enable.DISABLED)) await self.expect_evt(hci.LeSetScanEnableComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) # Send the scan response now; it should be ignored by the disabled scanner. controller.send_ll(ll.LeScanResponse(source_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, scan_response_data=[]), rssi=-16) # Re-enable the scanner and send the advertising PDU again. # This time expect the scan response to be properly reported. controller.send_cmd( hci.LeSetScanEnable(le_scan_enable=hci.Enable.ENABLED, filter_duplicates=hci.Enable.DISABLED)) await self.expect_evt(hci.LeSetScanEnableComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) controller.send_ll(ll.LeLegacyAdvertisingPdu(source_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, advertising_type=ll.LegacyAdvertisingType.ADV_SCAN_IND, advertising_data=[]), rssi=-16) await self.expect_evt( hci.LeAdvertisingReport(responses=[ hci.LeAdvertisingResponse(event_type=hci.AdvertisingEventType.ADV_SCAN_IND, address_type=hci.AddressType.RANDOM_DEVICE_ADDRESS, address=peer_address, advertising_data=[], rssi=0xf0) ])) await self.expect_ll( ll.LeScan(source_address=controller.address, destination_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, scanning_address_type=ll.AddressType.PUBLIC)) controller.send_ll(ll.LeScanResponse(source_address=peer_address, advertising_address_type=ll.AddressType.RANDOM, scan_response_data=[]), rssi=-16) await self.expect_evt( hci.LeAdvertisingReport(responses=[ hci.LeAdvertisingResponse(event_type=hci.AdvertisingEventType.SCAN_RESPONSE, address_type=hci.AddressType.RANDOM_DEVICE_ADDRESS, address=peer_address, advertising_data=[], rssi=0xf0) ]))
tools/rootcanal/test/main.py +1 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ tests = [ 'LMP.LIH.BV_143_C', 'LMP.LIH.BV_144_C', 'LMP.LIH.BV_149_C', 'LL.scan_collision', ] Loading