Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ef0d178 authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Naming conformant to BT spec 5.3 Connect=>Filter Accept am: d7fe6938

parents 5c1b3aef d7fe6938
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -234,11 +234,12 @@ class PyHal(Closable):
                hci_packets.AddressType.RANDOM_DEVICE_ADDRESS, remote_addr, 1, [phy_scan_params]))
        self.wait_for_status(OpCode.LE_EXTENDED_CREATE_CONNECTION)

    def add_to_connect_list(self, remote_addr):
    def add_to_filter_accept_list(self, remote_addr):
        self.send_hci_command(
            hci_packets.LeAddDeviceToConnectListBuilder(hci_packets.ConnectListAddressType.RANDOM, remote_addr))
            hci_packets.LeAddDeviceToFilterAcceptListBuilder(hci_packets.FilterAcceptListAddressType.RANDOM,
                                                             remote_addr))

    def initiate_le_connection_by_connect_list(self, remote_addr):
    def initiate_le_connection_by_filter_accept_list(self, remote_addr):
        phy_scan_params = hci_packets.LeCreateConnPhyScanParameters()
        phy_scan_params.scan_interval = 0x60
        phy_scan_params.scan_window = 0x30
@@ -249,9 +250,10 @@ class PyHal(Closable):
        phy_scan_params.min_ce_length = 0
        phy_scan_params.max_ce_length = 0
        self.send_hci_command(
            hci_packets.LeExtendedCreateConnectionBuilder(
                hci_packets.InitiatorFilterPolicy.USE_CONNECT_LIST, hci_packets.OwnAddressType.RANDOM_DEVICE_ADDRESS,
                hci_packets.AddressType.RANDOM_DEVICE_ADDRESS, remote_addr, 1, [phy_scan_params]))
            hci_packets.LeExtendedCreateConnectionBuilder(hci_packets.InitiatorFilterPolicy.USE_FILTER_ACCEPT_LIST,
                                                          hci_packets.OwnAddressType.RANDOM_DEVICE_ADDRESS,
                                                          hci_packets.AddressType.RANDOM_DEVICE_ADDRESS, remote_addr, 1,
                                                          [phy_scan_params]))

    def complete_le_connection(self):
        connection_complete = HciCaptures.LeConnectionCompleteCapture()
+9 −8
Original line number Diff line number Diff line
@@ -44,15 +44,16 @@ class SimpleHalTest(gd_base_test.GdBaseTestClass):

    def test_stream_events(self):
        self.dut_hal.send_hci_command(
            hci_packets.LeAddDeviceToConnectListBuilder(hci_packets.ConnectListAddressType.RANDOM, '0C:05:04:03:02:01'))

            hci_packets.LeAddDeviceToFilterAcceptListBuilder(hci_packets.FilterAcceptListAddressType.RANDOM,
                                                             '0C:05:04:03:02:01'))
        assertThat(self.dut_hal.get_hci_event_stream()).emits(
            HciMatchers.Exactly(hci_packets.LeAddDeviceToConnectListCompleteBuilder(1, hci_packets.ErrorCode.SUCCESS)))
            HciMatchers.Exactly(
                hci_packets.LeAddDeviceToFilterAcceptListCompleteBuilder(1, hci_packets.ErrorCode.SUCCESS)))

    def test_loopback_hci_command(self):
        self.dut_hal.send_hci_command(hci_packets.WriteLoopbackModeBuilder(hci_packets.LoopbackMode.ENABLE_LOCAL))

        command = hci_packets.LeAddDeviceToConnectListBuilder(hci_packets.ConnectListAddressType.RANDOM,
        command = hci_packets.LeAddDeviceToFilterAcceptListBuilder(hci_packets.FilterAcceptListAddressType.RANDOM,
                                                                   '0C:05:04:03:02:01')
        self.dut_hal.send_hci_command(command)

@@ -114,11 +115,11 @@ class SimpleHalTest(gd_base_test.GdBaseTestClass):
        assertThat(self.cert_hal.get_acl_stream()).emits(lambda packet: b'SomeAclData' in packet.payload)
        assertThat(self.dut_hal.get_acl_stream()).emits(lambda packet: b'SomeMoreAclData' in packet.payload)

    def test_le_connect_list_connection_cert_advertises(self):
    def test_le_filter_accept_list_connection_cert_advertises(self):
        self.dut_hal.unmask_event(hci_packets.EventCode.LE_META_EVENT)
        self.dut_hal.set_random_le_address('0D:05:04:03:02:01')
        self.dut_hal.add_to_connect_list('0C:05:04:03:02:01')
        self.dut_hal.initiate_le_connection_by_connect_list('BA:D5:A4:A3:A2:A1')
        self.dut_hal.add_to_filter_accept_list('0C:05:04:03:02:01')
        self.dut_hal.initiate_le_connection_by_filter_accept_list('BA:D5:A4:A3:A2:A1')

        self.cert_hal.unmask_event(hci_packets.EventCode.LE_META_EVENT)
        advertisement = self.cert_hal.create_advertisement(
+6 −5
Original line number Diff line number Diff line
@@ -58,8 +58,8 @@ from bluetooth_packets_python3.hci_packets import LeExtendedCreateConnectionBuil
from bluetooth_packets_python3.hci_packets import InitiatorFilterPolicy
from bluetooth_packets_python3.hci_packets import AddressType
from bluetooth_packets_python3.hci_packets import BroadcastFlag
from bluetooth_packets_python3.hci_packets import ConnectListAddressType
from bluetooth_packets_python3.hci_packets import LeAddDeviceToConnectListBuilder
from bluetooth_packets_python3.hci_packets import FilterAcceptListAddressType
from bluetooth_packets_python3.hci_packets import LeAddDeviceToFilterAcceptListBuilder
from bluetooth_packets_python3.hci_packets import LeSetRandomAddressBuilder
from bluetooth_packets_python3.hci_packets import LeReadRemoteFeaturesBuilder
from bluetooth_packets_python3.hci_packets import WritePageTimeoutBuilder
@@ -238,14 +238,15 @@ class DirectHciTest(gd_base_test.GdBaseTestClass):
        assertThat(self.dut_hci.get_raw_acl_stream()).emits(
            lambda packet: logging.debug(packet.payload) or b'SomeMoreAclData' in packet.payload)

    def test_le_connect_list_connection_cert_advertises(self):
    def test_le_filter_accept_list_connection_cert_advertises(self):
        self.dut_hci.register_for_le_events(SubeventCode.CONNECTION_COMPLETE, SubeventCode.ENHANCED_CONNECTION_COMPLETE)
        # DUT Connects
        self.dut_hci.send_command(LeSetRandomAddressBuilder('0D:05:04:03:02:01'))
        self.dut_hci.send_command(LeAddDeviceToConnectListBuilder(ConnectListAddressType.RANDOM, '0C:05:04:03:02:01'))
        self.dut_hci.send_command(
            LeAddDeviceToFilterAcceptListBuilder(FilterAcceptListAddressType.RANDOM, '0C:05:04:03:02:01'))
        phy_scan_params = self._create_phy_scan_params()
        self.dut_hci.send_command(
            LeExtendedCreateConnectionBuilder(InitiatorFilterPolicy.USE_CONNECT_LIST,
            LeExtendedCreateConnectionBuilder(InitiatorFilterPolicy.USE_FILTER_ACCEPT_LIST,
                                              OwnAddressType.RANDOM_DEVICE_ADDRESS, AddressType.RANDOM_DEVICE_ADDRESS,
                                              'BA:D5:A4:A3:A2:A1', 1, [phy_scan_params]))

+4 −4
Original line number Diff line number Diff line
@@ -68,8 +68,8 @@ CmdEvtActivityClassification lookup_cmd(hci::OpCode opcode) {
    case hci::OpCode::WRITE_SIMPLE_PAIRING_MODE:
    case hci::OpCode::READ_SCAN_ENABLE:
    case hci::OpCode::LE_CREATE_CONNECTION_CANCEL:
    case hci::OpCode::LE_READ_CONNECT_LIST_SIZE:
    case hci::OpCode::LE_CLEAR_CONNECT_LIST:
    case hci::OpCode::LE_READ_FILTER_ACCEPT_LIST_SIZE:
    case hci::OpCode::LE_CLEAR_FILTER_ACCEPT_LIST:
    case hci::OpCode::SEND_KEYPRESS_NOTIFICATION:
    case hci::OpCode::LE_CLEAR_RESOLVING_LIST:
    case hci::OpCode::LE_READ_RESOLVING_LIST_SIZE:
@@ -287,12 +287,12 @@ CmdEvtActivityClassification lookup_cmd(hci::OpCode opcode) {
    case hci::OpCode::LE_CREATE_CONNECTION:
      classification = {.activity = Activity::CONNECT, .connection_handle_pos = 0, .address_pos = 9};
      break;
    case hci::OpCode::LE_ADD_DEVICE_TO_CONNECT_LIST:
    case hci::OpCode::LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST:
    case hci::OpCode::LE_READ_CHANNEL_MAP:
      classification = {.activity = Activity::CONNECT, .connection_handle_pos = 4, .address_pos = 0};
      break;

    case hci::OpCode::LE_REMOVE_DEVICE_FROM_CONNECT_LIST:
    case hci::OpCode::LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST:
    case hci::OpCode::LE_ADD_DEVICE_TO_RESOLVING_LIST:
    case hci::OpCode::LE_REMOVE_DEVICE_FROM_RESOLVING_LIST:
    case hci::OpCode::LE_READ_PEER_RESOLVABLE_ADDRESS:
+3 −3
Original line number Diff line number Diff line
@@ -210,15 +210,15 @@ void AclManager::CancelLeConnect(AddressWithType address_with_type) {
  CallOn(pimpl_->le_impl_, &le_impl::cancel_connect, address_with_type);
}

void AclManager::AddDeviceToConnectList(AddressWithType address_with_type) {
void AclManager::AddDeviceToFilterAcceptList(AddressWithType address_with_type) {
  CallOn(pimpl_->le_impl_, &le_impl::add_device_to_connect_list, address_with_type);
}

void AclManager::RemoveDeviceFromConnectList(AddressWithType address_with_type) {
void AclManager::RemoveDeviceFromFilterAcceptList(AddressWithType address_with_type) {
  CallOn(pimpl_->le_impl_, &le_impl::remove_device_from_connect_list, address_with_type);
}

void AclManager::ClearConnectList() {
void AclManager::ClearFilterAcceptList() {
  CallOn(pimpl_->le_impl_, &le_impl::clear_connect_list);
}

Loading