with PyHci(self.cert) as cert_hci, \
EventStream(self.dut.hci_acl_manager.FetchAclData(empty_proto.Empty())) as acl_data_stream:
- # CERT Enables scans and gets its address
- cert_hci.send_command_with_complete(
- hci_packets.WriteScanEnableBuilder(
- hci_packets.ScanEnable.INQUIRY_AND_PAGE_SCAN))
-
- cert_hci.send_command_with_complete(hci_packets.ReadBdAddrBuilder())
-
- read_bd_addr = ReadBdAddrCompleteCapture()
- assertThat(cert_hci.get_event_stream()).emits(read_bd_addr)
- cert_address = read_bd_addr.get().GetBdAddr()
+ cert_hci.enable_inquiry_and_page_scan()
+ cert_address = cert_hci.read_own_address()
with EventStream(
self.dut.hci_acl_manager.CreateConnection(
EventStream(self.dut.hci_acl_manager.FetchAclData(empty_proto.Empty())) as acl_data_stream:
# CERT Enables scans and gets its address
- cert_hci.send_command_with_complete(
- hci_packets.WriteScanEnableBuilder(
- hci_packets.ScanEnable.INQUIRY_AND_PAGE_SCAN))
-
- cert_hci.send_command_with_complete(hci_packets.ReadBdAddrBuilder())
-
- read_bd_addr = ReadBdAddrCompleteCapture()
- assertThat(cert_hci.get_event_stream()).emits(read_bd_addr)
- cert_address = read_bd_addr.get().GetBdAddr()
+ cert_hci.enable_inquiry_and_page_scan()
+ cert_address = cert_hci.read_own_address()
with EventStream(
self.dut.hci_acl_manager.CreateConnection(
from google.protobuf import empty_pb2 as empty_proto
from cert.event_stream import EventStream
+from captures import ReadBdAddrCompleteCapture
+from bluetooth_packets_python3 import hci_packets
+from cert.truth import assertThat
class PyHci(object):
def send_command_with_status(self, command):
self.device.hci.send_command_with_status(command)
+
+ def enable_inquiry_and_page_scan(self):
+ self.send_command_with_complete(
+ hci_packets.WriteScanEnableBuilder(
+ hci_packets.ScanEnable.INQUIRY_AND_PAGE_SCAN))
+
+ def read_own_address(self):
+ self.send_command_with_complete(hci_packets.ReadBdAddrBuilder())
+ read_bd_addr = ReadBdAddrCompleteCapture()
+ assertThat(self.event_stream).emits(read_bd_addr)
+ return read_bd_addr.get().GetBdAddr()