Exemple #1
0
  Download(String[] args) {

    boolean done = false;
    boolean dumpSrec2 = false;
    String infile = "";
    vNum = -1;

    for (int i = 0; i < args.length; i++) {
      if (done) usage();

      if (args[i].equals("--srecfile")) {
        infile = args[++i];
      } else if (args[i].equals("--printmsgs")) {
        printAllMsgs = true;
      } else if (args[i].equals("--dumpsrec")) {
        dumpSrec2 = true;
      } else if (args[i].equals("--reboot")) {
        reboot = true;
      } else if (args[i].equals("-h") || args[i].equals("--help")) usage();
      else usage();
    }
    if (!reboot) {
      if (infile.equals("")) {
        usage();
      } else {
        readSrecCode(infile);
      }
    }

    if (dumpSrec2) {
      dumpSrec();
      System.exit(0);
    }

    try {
      intf = new MoteIF((Messenger) null);
      intf.registerListener(new DelugeAdvMsg(), this);
      intf.registerListener(new DelugeReqUpdMetadataMsg(), this);
      intf.registerListener(new DelugeReqMsg(), this);
    } catch (Exception e) {
      System.out.println("ERROR: Couldn't contact serial forwarder.");
      System.exit(1);
    }

    intf.start();
  }
Exemple #2
0
 public synchronized void send(Message m) {
   try {
     intf.send(MoteIF.TOS_BCAST_ADDR, m);
   } catch (IOException e) {
     e.printStackTrace();
     System.out.println("ERROR: Can't send message");
     System.exit(1);
   }
 }
Exemple #3
0
 private void send(Message m) {
   try {
     moteIF.send(MoteIF.TOS_BCAST_ADDR, m);
   } catch (IOException e) {
     e.printStackTrace();
     System.out.println("ERROR: Can't send message");
     System.exit(1);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Exemple #4
0
  public Drip(int id) {

    log.info("Started id=" + id);
    try {
      moteIF = new MoteIF();
      moteIF.registerListener(new DripMsg(), this);
    } catch (Exception e) {
      System.out.println("ERROR: Couldn't contact serial forwarder.");
      System.exit(1);
    }

    this.id = id;
  }
 public DrainConnector(int p_spAddr, MoteIF p_moteIF) {
   spAddr = p_spAddr;
   moteIF = p_moteIF;
   moteIF.registerListener(new DrainMsg(), this);
   log.info("Started myAddr = " + spAddr + ", listening for DrainMsg");
 }