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

Commit 3440ab69 authored by Zach Johnson's avatar Zach Johnson
Browse files

Simplify DirectHciTest send_hal_acl_data

first step towards more general code

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --host
Change-Id: I4957acd5868f4d079fdffb255df16200e919429b
parent f3816b5e
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -74,6 +74,8 @@ from bluetooth_packets_python3.hci_packets import PacketBoundaryFlag
from bluetooth_packets_python3.hci_packets import ResetBuilder
from bluetooth_packets_python3.hci_packets import Lap
from bluetooth_packets_python3.hci_packets import OpCode
from bluetooth_packets_python3.hci_packets import AclPacketBuilder
from bluetooth_packets_python3 import RawBuilder


class DirectHciTest(GdBaseTestClass):
@@ -98,14 +100,8 @@ class DirectHciTest(GdBaseTestClass):
        self.dut.hci.SendAcl(acl_msg)

    def send_hal_acl_data(self, handle, pb_flag, b_flag, acl):
        lower = handle & 0xff
        upper = (handle >> 8) & 0xf
        upper = upper | int(pb_flag) & 0x3
        upper = upper | ((int(b_flag) & 0x3) << 2)
        lower_length = len(acl) & 0xff
        upper_length = (len(acl) & 0xff00) >> 8
        concatenated = bytes([lower, upper, lower_length, upper_length] + list(acl))
        self.cert_hal.send_acl(concatenated)
        acl_msg = AclPacketBuilder(handle, pb_flag, b_flag, RawBuilder(acl))
        self.cert_hal.send_acl(acl_msg.Serialize())

    def test_local_hci_cmd_and_event(self):
        # Loopback mode responds with ACL and SCO connection complete
+3 −0
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@ PYBIND11_MODULE(bluetooth_packets_python3, m) {
  py::class_<BasePacketBuilder, std::shared_ptr<BasePacketBuilder>>(m, "BasePacketBuilder");
  py::class_<RawBuilder, BasePacketBuilder, std::shared_ptr<RawBuilder>>(m, "RawBuilder")
      .def(py::init([](std::vector<uint8_t> bytes) { return std::make_unique<RawBuilder>(bytes); }))
      .def(py::init([](std::string bytes) {
        return std::make_unique<RawBuilder>(std::vector<uint8_t>(bytes.begin(), bytes.end()));
      }))
      .def("Serialize", [](RawBuilder& builder) {
        std::vector<uint8_t> packet;
        BitInserter it(packet);