Package se.sics.mspsim.chip

Examples of se.sics.mspsim.chip.PacketListener$Proxy


  }
 
  // Data incoming from the network!!! - forward to radio and if server, to
  // all other nodes
  private void dataReceived(byte[] data, ConnectionThread source) {
    PacketListener listener = this.packetListener;
    if (listener != null) {
      // Send this data to the transmitter in this node!
      listener.transmissionStarted();     
      listener.transmissionEnded(data);
    }

    // And if this is the server, propagate to the others
    if (serverSocket != null) {
      dataSent(data, source);
View Full Code Here


        }

        if (config.getPropertyAsBoolean("enableNetwork", false)) {
            final NetworkConnection network = new NetworkConnection();
            final RadioWrapper radioWrapper = new RadioWrapper(radio);
            radioWrapper.addPacketListener(new PacketListener() {
                public void transmissionStarted() {
                }
                public void transmissionEnded(byte[] receivedData) {
//                    System.out.println("**** Sending data len = " + receivedData.length);
//                    for (int i = 0; i < receivedData.length; i++) {
//                        System.out.println("Byte: " + Utils.hex8(receivedData[i]));
//                    }
                    network.dataSent(receivedData);
                }
            });

            network.addPacketListener(new PacketListener() {
                public void transmissionStarted() {
                }
                public void transmissionEnded(byte[] receivedData) {
//                    System.out.println("**** Receiving data = " + receivedData.length);
                    radioWrapper.packetReceived(receivedData);
View Full Code Here

    }
  }

  // NOTE: len is not in the packet for now...
  public void receivedByte(byte data) {
    PacketListener listener = this.packetListener;
//    System.out.println("*** RF Data :" + data + " = $" + Utils.hex8(data) + " => " +
//        (char) data);
    if (pos == 5) {
      len = data;
    }
    if (pos == 0) {
        if (listener != null) {
            listener.transmissionStarted();
        }
    }
    buffer[pos++] = data;
    // len + 1 = pos + 5 (preambles)
    if (len > 0 && len + 1 == pos - 5) {
//      System.out.println("***** SENDING DATA from CC2420 len = " + len);
      byte[] packet = new byte[len + 1];
      System.arraycopy(buffer, 5, packet, 0, len + 1);
      if (listener != null) {
          listener.transmissionEnded(packet);
      }
      pos = 0;
      len = 0;
    }
  }
View Full Code Here

TOP

Related Classes of se.sics.mspsim.chip.PacketListener$Proxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.