diff --git a/src/tools/interop/idt/discovery/dnssd.py b/src/tools/interop/idt/discovery/dnssd.py index dbb4bd7908a1bb..fe436948d331d0 100644 --- a/src/tools/interop/idt/discovery/dnssd.py +++ b/src/tools/interop/idt/discovery/dnssd.py @@ -16,9 +16,12 @@ # import asyncio +import os import log from zeroconf import ServiceBrowser, ServiceInfo, ServiceListener, Zeroconf +from capture.utils.artifact import create_standard_log_name + logger = log.get_logger(__file__) @@ -31,16 +34,20 @@ # TODO: display discriminator (to hex), device type (decode), Pairing hint (decode) -# TODO: Write log! class MatterDnssdListener(ServiceListener): def __init__(self, artifact_dir: str) -> None: super().__init__() self.artifact_dir = artifact_dir + self.log_name = os.path.join(self.artifact_dir, create_standard_log_name("dnssd", "txt")) self.logger = logger self.discovered_matter_devices: [str, ServiceInfo] = {} + def write_log(self, line: str) -> None: + with open(self.log_name, "a+") as log_file: + log_file.write(line) + @staticmethod def log_addr(info: ServiceInfo) -> str: ret = "\n" @@ -76,6 +83,7 @@ def handle_service_info( to_log += self.log_vid_pid(info) to_log += self.log_addr(info) self.logger.info(to_log) + self.write_log(to_log) def add_service(self, zc: Zeroconf, type_: str, name: str) -> None: self.handle_service_info(zc, type_, name, "ADDED") @@ -89,6 +97,7 @@ def remove_service(self, zc: Zeroconf, type_: str, name: str) -> None: if name in self.discovered_matter_devices: del self.discovered_matter_devices[name] self.logger.warning(to_log) + self.write_log(to_log) def browse_interactive(self) -> None: zc = Zeroconf() diff --git a/src/tools/interop/idt/probe/linux.py b/src/tools/interop/idt/probe/linux.py index e2e7fed9926a06..ac228210753416 100644 --- a/src/tools/interop/idt/probe/linux.py +++ b/src/tools/interop/idt/probe/linux.py @@ -26,6 +26,7 @@ class ProberLinuxHost(p.GenericMatterProber): def __init__(self, artifact_dir: str, dnssd_artifact_dir: str) -> None: + # TODO: Parity with macOS super(ProberLinuxHost, self).__init__(artifact_dir, dnssd_artifact_dir) self.logger = logger diff --git a/src/tools/interop/idt/probe/mac.py b/src/tools/interop/idt/probe/mac.py index 4c592e62ece3cb..839c97ea4474d4 100644 --- a/src/tools/interop/idt/probe/mac.py +++ b/src/tools/interop/idt/probe/mac.py @@ -29,19 +29,31 @@ def __init__(self, artifact_dir: str, dnssd_artifact_dir: str) -> None: super(ProberMacHost, self).__init__(artifact_dir, dnssd_artifact_dir) self.logger = logger + def discover_targets_by_neighbor(self) -> None: + self.logger.info("Arp") + self.run_command("arp -a") + self.logger.info("Neigh") + self.run_command("ndp -an") + + def check_routes(self) -> None: + self.logger.info("v6") + self.run_command("netstat -r -f inet6 -n") + def probe_v4(self, target: ProbeTarget) -> None: + self.logger.info("Ping") self.run_command(f"ping -c {config.ping_count} {target.ip}") + self.logger.info("Route") + # TODO def probe_v6(self, target: ProbeTarget) -> None: + self.logger.info("Ping") self.run_command(f"ping6 -c {config.ping_count} {target.ip}") + self.logger.info("Route") + # TODO def probe_v6_ll(self, target: ProbeTarget) -> None: interface = get_ll_interface() + self.logger.info("Ping") self.run_command(f"ping6 -c {config.ping_count} -I {interface} {target.ip}") - - def discover_targets_by_neighbor(self) -> None: - self.run_command("arp -a") - self.run_command("ndp -an") - - def check_routes(self) -> None: - self.run_command("netstat -r -f inet6 -n") + self.logger.info("Route") + # TODO