ping method

void ping(
  1. Device device
)

Opens a Command prompt on Windows to ping the device.

Implementation

void ping(Device device) {
  final socket = models.sockets.socketForDevice(device);
  if (socket == null || socket.destination == null) {
    models.home.setMessage(severity: Severity.error, text: "Could not determine IP address for ${device.humanName}");
  } else {
    Process.run("cmd", [
      // Keep a CMD window open
      "/k", "start", "cmd", "/k",
      // Ping the IP address. -t means indefinitely
      "ping", "-t", socket.destination!.address.address,
    ]);
  }
}