Пример #1
0
  public static void main(String[] args) throws IOException {

    Logging.setLoggingDefaults();

    if (args.length > 1) {
      log.info("Searching for {} device with MAC address: {}", args[0], args[1]);
      MoteType type = MoteType.fromString(args[0]);
      if (type == null) {
        log.error("Unknown node type \"{}\" given.", args[0]);
        System.exit(1);
      }

      Map<String, String> telosBReferenceToMACMap = null;
      if (args.length == 3) {
        telosBReferenceToMACMap = readTelosBReferenceToMACMap(args[2]);
        log.info("Using Telos B USB chip ID to MAC mapping: {}", telosBReferenceToMACMap);
      }

      MoteList moteList = MoteListFactory.create(telosBReferenceToMACMap);
      log.info("Found: {}", moteList.getMotePort(type, StringUtils.parseHexOrDecLong(args[1])));

    } else if (args.length == 1) {

      Map<String, String> telosBReferenceToMACMap = null;
      if (args.length == 3) {
        telosBReferenceToMACMap = readTelosBReferenceToMACMap(args[2]);
        log.info("Using Telos B USB chip ID to MAC mapping: {}", telosBReferenceToMACMap);
      }

      log.info(
          "Displaying all connected devices: \n{}",
          MoteListFactory.create(telosBReferenceToMACMap).getMoteList());

    } else {
      log.info(
          "Displaying all connected devices: \n{}", MoteListFactory.create(null).getMoteList());
    }
  }