renamed radio method isReceiverOn() to isRadioOn()
fixed bug in Msp802154Radio causing all packets from non-802154-radios to be dropped
This commit is contained in:
parent
6d2d05b146
commit
86f1c34692
|
@ -111,7 +111,7 @@ public class MicaZRadio extends Radio802154 {
|
||||||
return (int) cc2420.getFrequency();
|
return (int) cc2420.getFrequency();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReceiverOn() {
|
public boolean isRadioOn() {
|
||||||
FiniteStateMachine fsm = cc2420.getFiniteStateMachine();
|
FiniteStateMachine fsm = cc2420.getFiniteStateMachine();
|
||||||
/* based on reading the source code it seems that the fsm state = 3 means on */
|
/* based on reading the source code it seems that the fsm state = 3 means on */
|
||||||
//System.out.println("COOJA: cc2420 FSM: " + fsm.getCurrentState());
|
//System.out.println("COOJA: cc2420 FSM: " + fsm.getCurrentState());
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class MRM extends AbstractRadioMedium {
|
||||||
double recvSignalStrength = probData[1];
|
double recvSignalStrength = probData[1];
|
||||||
if (recvProb == 1.0 || random.nextDouble() < recvProb) {
|
if (recvProb == 1.0 || random.nextDouble() < recvProb) {
|
||||||
/* Yes, the receiver *may* receive this packet (it's strong enough) */
|
/* Yes, the receiver *may* receive this packet (it's strong enough) */
|
||||||
if (!recv.isReceiverOn()) {
|
if (!recv.isRadioOn()) {
|
||||||
newConnection.addInterfered(recv);
|
newConnection.addInterfered(recv);
|
||||||
recv.interfereAnyReception();
|
recv.interfereAnyReception();
|
||||||
} else if (recv.isInterfered()) {
|
} else if (recv.isInterfered()) {
|
||||||
|
|
|
@ -31,8 +31,10 @@
|
||||||
package se.sics.cooja.mspmote.interfaces;
|
package se.sics.cooja.mspmote.interfaces;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
import se.sics.cooja.ClassDescription;
|
import se.sics.cooja.ClassDescription;
|
||||||
import se.sics.cooja.Mote;
|
import se.sics.cooja.Mote;
|
||||||
import se.sics.cooja.RadioPacket;
|
import se.sics.cooja.RadioPacket;
|
||||||
|
@ -42,6 +44,7 @@ import se.sics.cooja.interfaces.Position;
|
||||||
import se.sics.cooja.interfaces.Radio;
|
import se.sics.cooja.interfaces.Radio;
|
||||||
import se.sics.cooja.mspmote.MspMote;
|
import se.sics.cooja.mspmote.MspMote;
|
||||||
import se.sics.cooja.mspmote.MspMoteTimeEvent;
|
import se.sics.cooja.mspmote.MspMoteTimeEvent;
|
||||||
|
import se.sics.mspsim.chip.CC2420;
|
||||||
import se.sics.mspsim.chip.ChannelListener;
|
import se.sics.mspsim.chip.ChannelListener;
|
||||||
import se.sics.mspsim.chip.RFListener;
|
import se.sics.mspsim.chip.RFListener;
|
||||||
import se.sics.mspsim.chip.Radio802154;
|
import se.sics.mspsim.chip.Radio802154;
|
||||||
|
@ -207,8 +210,8 @@ public class Msp802154Radio extends Radio implements CustomDataRadio {
|
||||||
|
|
||||||
lastIncomingPacket = packet;
|
lastIncomingPacket = packet;
|
||||||
/* TODO Check isReceiverOn() instead? */
|
/* TODO Check isReceiverOn() instead? */
|
||||||
if (radio.isReadyToReceive()) {
|
if (!radio.isReadyToReceive()) {
|
||||||
logger.warn("Radio is turned off, dropping packet data");
|
logger.warn("Radio receiver not ready, dropping packet data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +397,16 @@ public class Msp802154Radio extends Radio implements CustomDataRadio {
|
||||||
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReceiverOn() {
|
public boolean isRadioOn() {
|
||||||
return radio.isReadyToReceive();
|
if (radio.isReadyToReceive()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (radio.getMode() == CC2420.MODE_POWER_OFF) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (radio.getMode() == CC2420.MODE_TXRX_OFF) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,7 +354,7 @@ public class TR1001Radio extends Radio implements USARTListener, CustomDataRadio
|
||||||
return mote;
|
return mote;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReceiverOn() {
|
public boolean isRadioOn() {
|
||||||
/* TODO Implement me */
|
/* TODO Implement me */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,7 +310,7 @@ public class PowerTracker extends VisPlugin {
|
||||||
this.mote = mote;
|
this.mote = mote;
|
||||||
this.radio = mote.getInterfaces().getRadio();
|
this.radio = mote.getInterfaces().getRadio();
|
||||||
|
|
||||||
radioWasOn = radio.isReceiverOn();
|
radioWasOn = radio.isRadioOn();
|
||||||
if (radio.isTransmitting()) {
|
if (radio.isTransmitting()) {
|
||||||
lastRadioState = RadioState.TRANSMITTING;
|
lastRadioState = RadioState.TRANSMITTING;
|
||||||
} else if (radio.isReceiving()) {
|
} else if (radio.isReceiving()) {
|
||||||
|
@ -350,7 +350,7 @@ public class PowerTracker extends VisPlugin {
|
||||||
/* Await next radio event */
|
/* Await next radio event */
|
||||||
if (radio.isTransmitting()) {
|
if (radio.isTransmitting()) {
|
||||||
lastRadioState = RadioState.TRANSMITTING;
|
lastRadioState = RadioState.TRANSMITTING;
|
||||||
} else if (!radio.isReceiverOn()) {
|
} else if (!radio.isRadioOn()) {
|
||||||
lastRadioState = RadioState.IDLE;
|
lastRadioState = RadioState.IDLE;
|
||||||
} else if (radio.isInterfered()) {
|
} else if (radio.isInterfered()) {
|
||||||
lastRadioState = RadioState.INTERFERED;
|
lastRadioState = RadioState.INTERFERED;
|
||||||
|
@ -359,7 +359,7 @@ public class PowerTracker extends VisPlugin {
|
||||||
} else {
|
} else {
|
||||||
lastRadioState = RadioState.IDLE;
|
lastRadioState = RadioState.IDLE;
|
||||||
}
|
}
|
||||||
radioWasOn = radio.isReceiverOn();
|
radioWasOn = radio.isRadioOn();
|
||||||
lastUpdateTime = now;
|
lastUpdateTime = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
|
||||||
}
|
}
|
||||||
|
|
||||||
/* General radio support */
|
/* General radio support */
|
||||||
public boolean isReceiverOn() {
|
public boolean isRadioOn() {
|
||||||
return radioOn;
|
return radioOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ public abstract class Radio802154 extends Radio implements CustomDataRadio {
|
||||||
|
|
||||||
public abstract int getFrequency();
|
public abstract int getFrequency();
|
||||||
|
|
||||||
public abstract boolean isReceiverOn();
|
public abstract boolean isRadioOn();
|
||||||
|
|
||||||
public abstract double getCurrentOutputPower();
|
public abstract double getCurrentOutputPower();
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,7 @@ public class ApplicationRadio extends Radio implements NoiseSourceRadio, Directi
|
||||||
this.setChanged();
|
this.setChanged();
|
||||||
this.notifyObservers();
|
this.notifyObservers();
|
||||||
}
|
}
|
||||||
public boolean isReceiverOn() {
|
public boolean isRadioOn() {
|
||||||
return radioOn;
|
return radioOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,18 +139,18 @@ public abstract class Radio extends MoteInterface {
|
||||||
public abstract boolean isInterfered();
|
public abstract boolean isInterfered();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return True if the simulated radio receiver is turned on
|
* @return True if the simulated radio transceiver is on
|
||||||
*/
|
*/
|
||||||
public abstract boolean isReceiverOn();
|
public abstract boolean isRadioOn();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interferes with any current reception. If this method is called, the packet
|
* Interferes with any current reception. If this method is called, the packet
|
||||||
* will be dropped. This method can be used to simulate radio interference
|
* will be dropped. This method can be used to simulate radio interference
|
||||||
* such as high background noise or radio packet collisions.
|
* such as high background noise or radio packet collisions.
|
||||||
*
|
*
|
||||||
* When the radio is no longer interfered, the {@link #signalReceptionEnd()}
|
* When the radio is no longer interfered, the {@link #signalReceptionEnd()}
|
||||||
* method must be called.
|
* method must be called.
|
||||||
*
|
*
|
||||||
* @see #signalReceptionEnd()
|
* @see #signalReceptionEnd()
|
||||||
*/
|
*/
|
||||||
public abstract void interfereAnyReception();
|
public abstract void interfereAnyReception();
|
||||||
|
|
|
@ -1004,7 +1004,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
|
||||||
final Radio moteRadio = mote.getInterfaces().getRadio();
|
final Radio moteRadio = mote.getInterfaces().getRadio();
|
||||||
if (moteRadio != null) {
|
if (moteRadio != null) {
|
||||||
RadioHWEvent startupHW = new RadioHWEvent(
|
RadioHWEvent startupHW = new RadioHWEvent(
|
||||||
simulation.getSimulationTime(), moteRadio.isReceiverOn());
|
simulation.getSimulationTime(), moteRadio.isRadioOn());
|
||||||
if (radioChannels) {
|
if (radioChannels) {
|
||||||
startupHW.channel = moteRadio.getChannel();
|
startupHW.channel = moteRadio.getChannel();
|
||||||
}
|
}
|
||||||
|
@ -1024,7 +1024,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
|
||||||
lastChannel = nowChannel;
|
lastChannel = nowChannel;
|
||||||
|
|
||||||
RadioHWEvent ev = new RadioHWEvent(
|
RadioHWEvent ev = new RadioHWEvent(
|
||||||
simulation.getSimulationTime(), moteRadio.isReceiverOn());
|
simulation.getSimulationTime(), moteRadio.isRadioOn());
|
||||||
if (radioChannels) {
|
if (radioChannels) {
|
||||||
ev.channel = moteRadio.getChannel();
|
ev.channel = moteRadio.getChannel();
|
||||||
}
|
}
|
||||||
|
@ -1044,7 +1044,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
|
||||||
if (moteRadio.getLastEvent() == RadioEvent.HW_ON ||
|
if (moteRadio.getLastEvent() == RadioEvent.HW_ON ||
|
||||||
moteRadio.getLastEvent() == RadioEvent.HW_OFF) {
|
moteRadio.getLastEvent() == RadioEvent.HW_OFF) {
|
||||||
RadioHWEvent ev = new RadioHWEvent(
|
RadioHWEvent ev = new RadioHWEvent(
|
||||||
simulation.getSimulationTime(), moteRadio.isReceiverOn());
|
simulation.getSimulationTime(), moteRadio.isRadioOn());
|
||||||
if (radioChannels) {
|
if (radioChannels) {
|
||||||
ev.channel = moteRadio.getChannel();
|
ev.channel = moteRadio.getChannel();
|
||||||
}
|
}
|
||||||
|
@ -1074,7 +1074,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
|
||||||
if (moteRadio.isTransmitting()) {
|
if (moteRadio.isTransmitting()) {
|
||||||
ev = new RadioRXTXEvent(
|
ev = new RadioRXTXEvent(
|
||||||
simulation.getSimulationTime(), RXTXRadioEvent.TRANSMITTING);
|
simulation.getSimulationTime(), RXTXRadioEvent.TRANSMITTING);
|
||||||
} else if (!moteRadio.isReceiverOn()) {
|
} else if (!moteRadio.isRadioOn()) {
|
||||||
ev = new RadioRXTXEvent(
|
ev = new RadioRXTXEvent(
|
||||||
simulation.getSimulationTime(), RXTXRadioEvent.IDLE);
|
simulation.getSimulationTime(), RXTXRadioEvent.IDLE);
|
||||||
} else if (moteRadio.isInterfered()) {
|
} else if (moteRadio.isInterfered()) {
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class TrafficVisualizerSkin implements VisualizerSkin {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!moteRadio.isReceiverOn()) {
|
if (!moteRadio.isRadioOn()) {
|
||||||
return new Color[] { Color.GRAY };
|
return new Color[] { Color.GRAY };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dest.radio.isReceiverOn()) {
|
if (!dest.radio.isRadioOn()) {
|
||||||
/* Fail: radio is off */
|
/* Fail: radio is off */
|
||||||
/*logger.info(source + ": Fail, off");*/
|
/*logger.info(source + ": Fail, off");*/
|
||||||
newConn.addInterfered(dest.radio);
|
newConn.addInterfered(dest.radio);
|
||||||
|
|
|
@ -215,7 +215,7 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
if (distance <= moteTransmissionRange) {
|
if (distance <= moteTransmissionRange) {
|
||||||
/* Within transmission range */
|
/* Within transmission range */
|
||||||
|
|
||||||
if (!recv.isReceiverOn()) {
|
if (!recv.isRadioOn()) {
|
||||||
newConnection.addInterfered(recv);
|
newConnection.addInterfered(recv);
|
||||||
recv.interfereAnyReception();
|
recv.interfereAnyReception();
|
||||||
} else if (recv.isInterfered()) {
|
} else if (recv.isInterfered()) {
|
||||||
|
|
Loading…
Reference in a new issue