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:
Fredrik Osterlind 2012-06-04 12:39:46 +02:00
parent 6d2d05b146
commit 86f1c34692
13 changed files with 37 additions and 25 deletions

View file

@ -111,7 +111,7 @@ public class MicaZRadio extends Radio802154 {
return (int) cc2420.getFrequency();
}
public boolean isReceiverOn() {
public boolean isRadioOn() {
FiniteStateMachine fsm = cc2420.getFiniteStateMachine();
/* based on reading the source code it seems that the fsm state = 3 means on */
//System.out.println("COOJA: cc2420 FSM: " + fsm.getCurrentState());

View file

@ -192,7 +192,7 @@ public class MRM extends AbstractRadioMedium {
double recvSignalStrength = probData[1];
if (recvProb == 1.0 || random.nextDouble() < recvProb) {
/* Yes, the receiver *may* receive this packet (it's strong enough) */
if (!recv.isReceiverOn()) {
if (!recv.isRadioOn()) {
newConnection.addInterfered(recv);
recv.interfereAnyReception();
} else if (recv.isInterfered()) {

View file

@ -31,8 +31,10 @@
package se.sics.cooja.mspmote.interfaces;
import java.util.Collection;
import org.apache.log4j.Logger;
import org.jdom.Element;
import se.sics.cooja.ClassDescription;
import se.sics.cooja.Mote;
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.mspmote.MspMote;
import se.sics.cooja.mspmote.MspMoteTimeEvent;
import se.sics.mspsim.chip.CC2420;
import se.sics.mspsim.chip.ChannelListener;
import se.sics.mspsim.chip.RFListener;
import se.sics.mspsim.chip.Radio802154;
@ -207,8 +210,8 @@ public class Msp802154Radio extends Radio implements CustomDataRadio {
lastIncomingPacket = packet;
/* TODO Check isReceiverOn() instead? */
if (radio.isReadyToReceive()) {
logger.warn("Radio is turned off, dropping packet data");
if (!radio.isReadyToReceive()) {
logger.warn("Radio receiver not ready, dropping packet data");
return;
}
@ -394,7 +397,16 @@ public class Msp802154Radio extends Radio implements CustomDataRadio {
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
}
public boolean isReceiverOn() {
return radio.isReadyToReceive();
public boolean isRadioOn() {
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;
}
}

View file

@ -354,7 +354,7 @@ public class TR1001Radio extends Radio implements USARTListener, CustomDataRadio
return mote;
}
public boolean isReceiverOn() {
public boolean isRadioOn() {
/* TODO Implement me */
return true;
}

View file

@ -310,7 +310,7 @@ public class PowerTracker extends VisPlugin {
this.mote = mote;
this.radio = mote.getInterfaces().getRadio();
radioWasOn = radio.isReceiverOn();
radioWasOn = radio.isRadioOn();
if (radio.isTransmitting()) {
lastRadioState = RadioState.TRANSMITTING;
} else if (radio.isReceiving()) {
@ -350,7 +350,7 @@ public class PowerTracker extends VisPlugin {
/* Await next radio event */
if (radio.isTransmitting()) {
lastRadioState = RadioState.TRANSMITTING;
} else if (!radio.isReceiverOn()) {
} else if (!radio.isRadioOn()) {
lastRadioState = RadioState.IDLE;
} else if (radio.isInterfered()) {
lastRadioState = RadioState.INTERFERED;
@ -359,7 +359,7 @@ public class PowerTracker extends VisPlugin {
} else {
lastRadioState = RadioState.IDLE;
}
radioWasOn = radio.isReceiverOn();
radioWasOn = radio.isRadioOn();
lastUpdateTime = now;
}

View file

@ -164,7 +164,7 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
}
/* General radio support */
public boolean isReceiverOn() {
public boolean isRadioOn() {
return radioOn;
}

View file

@ -181,7 +181,7 @@ public abstract class Radio802154 extends Radio implements CustomDataRadio {
public abstract int getFrequency();
public abstract boolean isReceiverOn();
public abstract boolean isRadioOn();
public abstract double getCurrentOutputPower();

View file

@ -392,7 +392,7 @@ public class ApplicationRadio extends Radio implements NoiseSourceRadio, Directi
this.setChanged();
this.notifyObservers();
}
public boolean isReceiverOn() {
public boolean isRadioOn() {
return radioOn;
}

View file

@ -139,18 +139,18 @@ public abstract class Radio extends MoteInterface {
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
* will be dropped. This method can be used to simulate radio interference
* 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.
*
*
* @see #signalReceptionEnd()
*/
public abstract void interfereAnyReception();

View file

@ -1004,7 +1004,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
final Radio moteRadio = mote.getInterfaces().getRadio();
if (moteRadio != null) {
RadioHWEvent startupHW = new RadioHWEvent(
simulation.getSimulationTime(), moteRadio.isReceiverOn());
simulation.getSimulationTime(), moteRadio.isRadioOn());
if (radioChannels) {
startupHW.channel = moteRadio.getChannel();
}
@ -1024,7 +1024,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
lastChannel = nowChannel;
RadioHWEvent ev = new RadioHWEvent(
simulation.getSimulationTime(), moteRadio.isReceiverOn());
simulation.getSimulationTime(), moteRadio.isRadioOn());
if (radioChannels) {
ev.channel = moteRadio.getChannel();
}
@ -1044,7 +1044,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
if (moteRadio.getLastEvent() == RadioEvent.HW_ON ||
moteRadio.getLastEvent() == RadioEvent.HW_OFF) {
RadioHWEvent ev = new RadioHWEvent(
simulation.getSimulationTime(), moteRadio.isReceiverOn());
simulation.getSimulationTime(), moteRadio.isRadioOn());
if (radioChannels) {
ev.channel = moteRadio.getChannel();
}
@ -1074,7 +1074,7 @@ public class TimeLine extends VisPlugin implements HasQuickHelp {
if (moteRadio.isTransmitting()) {
ev = new RadioRXTXEvent(
simulation.getSimulationTime(), RXTXRadioEvent.TRANSMITTING);
} else if (!moteRadio.isReceiverOn()) {
} else if (!moteRadio.isRadioOn()) {
ev = new RadioRXTXEvent(
simulation.getSimulationTime(), RXTXRadioEvent.IDLE);
} else if (moteRadio.isInterfered()) {

View file

@ -192,7 +192,7 @@ public class TrafficVisualizerSkin implements VisualizerSkin {
return null;
}
if (!moteRadio.isReceiverOn()) {
if (!moteRadio.isRadioOn()) {
return new Color[] { Color.GRAY };
}

View file

@ -273,7 +273,7 @@ public class DirectedGraphMedium extends AbstractRadioMedium {
continue;
}
if (!dest.radio.isReceiverOn()) {
if (!dest.radio.isRadioOn()) {
/* Fail: radio is off */
/*logger.info(source + ": Fail, off");*/
newConn.addInterfered(dest.radio);

View file

@ -215,7 +215,7 @@ public class UDGM extends AbstractRadioMedium {
if (distance <= moteTransmissionRange) {
/* Within transmission range */
if (!recv.isReceiverOn()) {
if (!recv.isRadioOn()) {
newConnection.addInterfered(recv);
recv.interfereAnyReception();
} else if (recv.isInterfered()) {