Esempio n. 1
0
  public static SBBIRouter findRouter() throws Exception {
    InternetGatewayDevice[] routers;
    try {
      routers = InternetGatewayDevice.getDevices(DISCOVERY_TIMEOUT);
    } catch (IOException e) {
      throw new Exception("Could not find router", e);
    }

    if (routers == null || routers.length == 0) {
      throw new Exception("No routers found");
    }

    if (routers.length != 1) {
      throw new Exception("Found more than one router (" + routers.length + ")");
    }

    return new SBBIRouter(routers[0]);
  }