Ejemplo n.º 1
0
  public void messageReceived(int to, Message message) {
    Date date = Calendar.getInstance().getTime();

    if (message instanceof RadioSignalResultsMsg) {
      RadioSignalResultsMsg resultMsg = (RadioSignalResultsMsg) message;
      log(
          date
              + "\t"
              + date.getTime()
              + "\t"
              + "RADIO15.4_RESULT_MSG"
              + "\t"
              + resultMsg.get_idReceiver()
              + "\t"
              + resultMsg.get_idSender()
              + "\t"
              + resultMsg.get_seqno()
              + "\t"
              + resultMsg.get_rssi()
              + "\t"
              + resultMsg.get_lqi()
              + "\t"
              + resultMsg.get_timestamp());
    } else {
      log(date + "\t" + date.getTime() + "\t UNKNOWN_MSG" + "\t" + message.toString());
    }
  }
Ejemplo n.º 2
0
  public static void main(String[] args) throws Exception {
    String source = null;
    Vector v = new Vector();
    if (args.length > 0) {
      for (int i = 0; i < args.length; i++) {
        if (args[i].equals("-comm")) {
          source = args[++i];
        } else {
          String className = args[i];
          try {
            Class c = Class.forName(className);
            Object packet = c.newInstance();
            Message msg = (Message) packet;
            if (msg.amType() < 0) {
              System.err.println(className + " does not have an AM type - ignored");
            } else {
              v.addElement(msg);
            }
          } catch (Exception e) {
            System.err.println(e);
          }
        }
      }
    } else if (args.length != 0) {
      usage();
      System.exit(1);
    }

    MsgReader mr = new MsgReader(source);
    Enumeration msgs = v.elements();
    while (msgs.hasMoreElements()) {
      Message m = (Message) msgs.nextElement();
      mr.addMsgType(m);
    }
    mr.start();
  }