public void setMoteID(int newID) {
   moteID = newID;
   moteMem.setIntValueOf("simMoteID", moteID);
   moteMem.setByteValueOf("simMoteIDChanged", (byte) 1);
   moteMem.setIntValueOf("simRandomSeed", (int) (mote.getSimulation().getRandomSeed() + newID));
   setChanged();
   notifyObservers();
 }
示例#2
0
  protected void handleTransmit(byte val) {
    if (len == 0) {
      lastEventTime = mote.getSimulation().getSimulationTime();
      lastEvent = RadioEvent.TRANSMISSION_STARTED;
      if (DEBUG) logger.debug("----- 802.15.4 TRANSMISSION STARTED -----");
      setChanged();
      notifyObservers();
    }
    /* send this byte to all nodes */
    lastOutgoingByte = new RadioByte(val);
    lastEventTime = mote.getSimulation().getSimulationTime();
    lastEvent = RadioEvent.CUSTOM_DATA_TRANSMITTED;
    setChanged();
    notifyObservers();

    buffer[len++] = val;

    // System.out.println("## 802.15.4: " + (val&0xff) + " transmitted...");

    if (len == 6) {
      // System.out.println("## CC2420 Packet of length: " + val + " expected...");
      expLen = val + 6;
    }

    if (len == expLen) {
      if (DEBUG) logger.debug("----- 802.15.4 CUSTOM DATA TRANSMITTED -----");

      lastOutgoingPacket = Radio802154PacketConverter.fromCC2420ToCooja(buffer);
      lastEventTime = mote.getSimulation().getSimulationTime();
      lastEvent = RadioEvent.PACKET_TRANSMITTED;
      if (DEBUG) logger.debug("----- 802.15.4 PACKET TRANSMITTED -----");
      setChanged();
      notifyObservers();

      //          System.out.println("## CC2420 Transmission finished...");

      lastEventTime = mote.getSimulation().getSimulationTime();
      /*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
      lastEvent = RadioEvent.TRANSMISSION_FINISHED;
      setChanged();
      notifyObservers();
      len = 0;
    }
  }
示例#3
0
  /* need to add a few more methods later??? */
  public void signalReceptionStart() {
    isReceiving = true;

    //      cc2420.setCCA(true);
    //      hasFailedReception = mode == CC2420.MODE_TXRX_OFF;
    /* TODO cc2420.setSFD(true); */

    lastEventTime = mote.getSimulation().getSimulationTime();
    lastEvent = RadioEvent.RECEPTION_STARTED;
    if (DEBUG) logger.debug("----- 802.15.4 RECEPTION STARTED -----");
    setChanged();
    notifyObservers();
  }
示例#4
0
  public void interfereAnyReception() {
    isInterfered = true;
    isReceiving = false;
    //      hasFailedReception = false;
    lastIncomingPacket = null;

    // cc2420.setCCA(true);

    /* is this ok ?? */
    handleEndOfReception();
    // recv.nextByte(false, (byte)0);

    lastEventTime = mote.getSimulation().getSimulationTime();
    lastEvent = RadioEvent.RECEPTION_INTERFERED;
    /*logger.debug("----- SKY RECEPTION INTERFERED -----");*/
    setChanged();
    notifyObservers();
  }
示例#5
0
  public void signalReceptionEnd() {
    /* Deliver packet data */
    isReceiving = false;
    //      hasFailedReception = false;
    isInterfered = false;
    //      cc2420.setCCA(false);

    /* tell the receiver that the packet is ended */
    handleEndOfReception();

    lastEventTime = mote.getSimulation().getSimulationTime();
    lastEvent = RadioEvent.RECEPTION_FINISHED;
    if (DEBUG) logger.debug("----- 802.15.4 RECEPTION FINISHED -----");
    // Exception e = new IllegalStateException("Why finished?");
    // e.printStackTrace();
    setChanged();
    notifyObservers();
  }
 /**
  * Creates an interface to the mote ID at mote.
  *
  * @param mote Mote
  * @see Mote
  * @see se.sics.cooja.MoteInterfaceHandler
  */
 public ContikiMoteID(Mote mote) {
   this.mote = mote;
   this.moteMem = (SectionMoteMemory) mote.getMemory();
 }
示例#7
0
 /**
  * Calculates distance from associated mote to another mote.
  *
  * @param m Another mote
  * @return Distance
  */
 public double getDistanceTo(Mote m) {
   return getDistanceTo(m.getInterfaces().getPosition());
 }
示例#8
0
 public Position getPosition() {
   return mote.getInterfaces().getPosition();
 }