示例#1
0
  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);
    }
  }
示例#2
0
 public void messageReceived(int to, Message message) {
   BlinkToRadioMsg msg = (BlinkToRadioMsg) message;
   System.out.println("Received packet sequence number " + msg.get_counter());
 }