Run a lightweight ARP + ping discovery, typically after Wi-Fi connects.
(self, include_arp_scan=True, cidrs=None)
| 587 | return ping_discovered |
| 588 | |
| 589 | def run_initial_ping_sweep(self, include_arp_scan=True, cidrs=None): |
| 590 | """Run a lightweight ARP + ping discovery, typically after Wi-Fi connects.""" |
| 591 | try: |
| 592 | target_cidrs = list(cidrs) if cidrs else [] |
| 593 | if not target_cidrs: |
| 594 | network = None |
| 595 | try: |
| 596 | network = self.get_network() |
| 597 | except Exception as network_error: |
| 598 | self.logger.warning(f"Unable to determine current network for ping sweep: {network_error}") |
| 599 | if network: |
| 600 | target_cidrs.append(str(network)) |
| 601 | else: |
| 602 | self.logger.error( |
| 603 | "Initial ping sweep aborted: no target CIDR and " |
| 604 | "network detection failed") |
| 605 | return {} |
| 606 | |
| 607 | self.logger.info(f"🚀 Initial ping sweep requested across {', '.join(target_cidrs)}") |
| 608 | arp_hosts = self.run_arp_scan(network=network) if include_arp_scan else {} |
| 609 | ping_results = self._ping_sweep_missing_hosts( |
| 610 | arp_hosts, |
| 611 | target_cidrs=target_cidrs |
| 612 | ) |
| 613 | |
| 614 | summary = { |
| 615 | 'arp_hosts': len(arp_hosts), |
| 616 | 'ping_hosts': len(ping_results), |
| 617 | 'target_cidrs': target_cidrs |
| 618 | } |
| 619 | self.logger.info( |
| 620 | f"📡 Initial ping sweep complete: {summary['arp_hosts']} ARP hosts, " |
| 621 | f"{summary['ping_hosts']} ping-only hosts" |
| 622 | ) |
| 623 | return summary |
| 624 | except Exception as exc: |
| 625 | self.logger.error(f"Initial ping sweep failed: {exc}") |
| 626 | self.logger.debug(f"Full traceback: {traceback.format_exc()}") |
| 627 | return None |
| 628 | |
| 629 | def get_current_timestamp(self): |
| 630 | """ |
no test coverage detected