コード例 #1
0
ファイル: Download.java プロジェクト: saurabhd14/tinyos-1.x
  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();
  }
コード例 #2
0
ファイル: Download.java プロジェクト: saurabhd14/tinyos-1.x
 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);
   }
 }
コード例 #3
0
ファイル: Drip.java プロジェクト: saurabhd14/tinyos-1.x
 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();
   }
 }
コード例 #4
0
 public AntiTheftGui() {
   try {
     guiInit();
     /* Setup communication with the mote and request a messageReceived
     callback when an AlertMsg is received */
     mote = new MoteIF(this);
     mote.registerListener(new AlertMsg(), this);
   } catch (Exception e) {
     e.printStackTrace();
     System.exit(2);
   }
 }
コード例 #5
0
ファイル: Drip.java プロジェクト: saurabhd14/tinyos-1.x
  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;
  }
コード例 #6
0
  public TestTtsp() {
    try {
      mote = new MoteIF(PrintStreamMessenger.err);
      mote.registerListener(new TestTtspMsg(), this);
      System.out.println("Connecting to basestation...OK");
    } catch (Exception e) {
      System.out.println("Connecting to basestation...FAILED");
      e.printStackTrace();
      System.exit(2);
    }

    System.out.println(
        "[Reception Time (ms)] [Node] [Beacon] [GlobalTime (ms)] [LocalTime (ms)] [Offset (ms)] [Root] [Period]");
  }
コード例 #7
0
  public RadioSignalMeter(String motePort, String outputFile) {
    this.motePort = motePort;
    this.outputFile = outputFile;

    PhoenixSource phoenixLocal = null;

    if (motePort == null) {
      phoenixLocal = BuildSource.makePhoenix(PrintStreamMessenger.err);
    } else {
      phoenixLocal = BuildSource.makePhoenix(motePort, PrintStreamMessenger.err);
    }

    moteIF = new MoteIF(phoenixLocal);
    moteIF.registerListener(new RadioSignalResultsMsg(), this);
  }
コード例 #8
0
  /* User pressed the "Update" button. Read the GUI fields and
  send a SettingsMsg with the requested values. When the
  requested settings are bad, we silently update them to sane
  values. */
  public void updateSettings() {
    SettingsMsg smsg = new SettingsMsg();
    short alert = 0;
    short detect = 0;
    int checkInterval = Constants.DEFAULT_CHECK_INTERVAL;

    /* Extract current interval value, fixing bad values */
    String intervalS = fieldInterval.getText().trim();
    try {
      int newInterval = Integer.parseInt(intervalS);
      if (newInterval < 10) throw new NumberFormatException();
      checkInterval = newInterval;
    } catch (NumberFormatException e) {
      /* Reset field when value is bad */
      fieldInterval.setText("" + checkInterval);
    }

    /* Extract alert settings */
    if (repLedCb.isSelected()) alert |= Constants.ALERT_LEDS;
    if (repSirenCb.isSelected()) alert |= Constants.ALERT_SOUND;
    if (repNeighboursCb.isSelected()) alert |= Constants.ALERT_RADIO;
    if (repServerCb.isSelected()) alert |= Constants.ALERT_ROOT;
    if (alert == 0) {
      /* If nothing select, force-select LEDs */
      alert = Constants.ALERT_LEDS;
      repLedCb.setSelected(true);
    }

    /* Extract detection settings */
    if (detDarkCb.isSelected()) detect |= Constants.DETECT_DARK;
    if (detAccelCb.isSelected()) detect |= Constants.DETECT_ACCEL;
    if (detect == 0) {
      /* If no detection selected, force-select dark */
      detect = Constants.DETECT_DARK;
      detDarkCb.setSelected(true);
    }

    /* Build and send settings message */
    smsg.set_alert(alert);
    smsg.set_detect(detect);
    smsg.set_checkInterval(checkInterval);
    try {
      mote.send(MoteIF.TOS_BCAST_ADDR, smsg);
    } catch (IOException e) {
      error("Cannot send message to mote");
    }
  }
コード例 #9
0
ファイル: TestSerial.java プロジェクト: Jarob22/tinyos_dev
  public void sendPackets() {
    int counter = 0;
    BlinkToRadioMsg payload = new BlinkToRadioMsg();

    try {
      while (true) {
        System.out.println("Sending packet " + counter);
        payload.set_counter(counter);
        moteIF.send(0, payload);
        counter++;
        try {
          Thread.sleep(1000);
        } catch (InterruptedException exception) {
        }
      }
    } catch (IOException exception) {
      System.err.println("Exception thrown when sending packets. Exiting.");
      System.err.println(exception);
    }
  }
コード例 #10
0
 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");
 }
コード例 #11
0
ファイル: MsgReader.java プロジェクト: edgemaster/pervasive
 private void addMsgType(Message msg) {
   moteIF.registerListener(msg, this);
 }