added method for checking if radio can receive data

This commit is contained in:
fros4943 2009-04-16 14:28:12 +00:00
parent 5af34f6800
commit ebcd6a08a5
3 changed files with 387 additions and 375 deletions

View file

@ -1,370 +1,375 @@
/* /*
* Copyright (c) 2009, Swedish Institute of Computer Science. * Copyright (c) 2009, Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: MicaZRadio.java,v 1.2 2009/03/19 14:47:37 joxe Exp $ * $Id: MicaZRadio.java,v 1.3 2009/04/16 14:28:12 fros4943 Exp $
*/ */
package se.sics.cooja.avrmote.interfaces; package se.sics.cooja.avrmote.interfaces;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.*; import java.util.*;
import javax.swing.*; import javax.swing.*;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jdom.Element; import org.jdom.Element;
import avrora.sim.platform.MicaZ; import avrora.sim.platform.MicaZ;
import avrora.sim.radio.CC2420Radio; import avrora.sim.radio.CC2420Radio;
import avrora.sim.radio.Medium; import avrora.sim.radio.Medium;
import se.sics.cooja.*; import se.sics.cooja.*;
import se.sics.cooja.avrmote.MicaZMote; import se.sics.cooja.avrmote.MicaZMote;
import se.sics.cooja.interfaces.CustomDataRadio; import se.sics.cooja.interfaces.CustomDataRadio;
import se.sics.cooja.interfaces.Position; import se.sics.cooja.interfaces.Position;
import se.sics.cooja.interfaces.Radio; import se.sics.cooja.interfaces.Radio;
import se.sics.cooja.mspmote.interfaces.CC2420RadioPacketConverter; import se.sics.cooja.mspmote.interfaces.CC2420RadioPacketConverter;
/** /**
* CC2420 to COOJA wrapper. * CC2420 to COOJA wrapper.
* *
* @author Joakim Eriksson * @author Joakim Eriksson
*/ */
@ClassDescription("CC2420") @ClassDescription("CC2420")
public class MicaZRadio extends Radio implements CustomDataRadio { public class MicaZRadio extends Radio implements CustomDataRadio {
private static Logger logger = Logger.getLogger(MicaZRadio.class); private static Logger logger = Logger.getLogger(MicaZRadio.class);
private long lastEventTime = 0; private long lastEventTime = 0;
private RadioEvent lastEvent = RadioEvent.UNKNOWN; private RadioEvent lastEvent = RadioEvent.UNKNOWN;
private MicaZMote mote; private MicaZMote mote;
private MicaZ micaz; private MicaZ micaz;
private CC2420Radio cc2420; private CC2420Radio cc2420;
private boolean isInterfered = false; private boolean isInterfered = false;
private boolean isTransmitting = false; private boolean isTransmitting = false;
private boolean isReceiving = false; private boolean isReceiving = false;
// private boolean hasFailedReception = false; // private boolean hasFailedReception = false;
private boolean radioOn = true; private boolean radioOn = true;
private RadioByte lastOutgoingByte = null; private RadioByte lastOutgoingByte = null;
private RadioByte lastIncomingByte = null; private RadioByte lastIncomingByte = null;
private RadioPacket lastOutgoingPacket = null; private RadioPacket lastOutgoingPacket = null;
private RadioPacket lastIncomingPacket = null; private RadioPacket lastIncomingPacket = null;
// private int mode; // private int mode;
Medium.Transmitter trans; Medium.Transmitter trans;
CC2420Radio.Receiver recv; CC2420Radio.Receiver recv;
public MicaZRadio(MicaZMote mote) { public MicaZRadio(MicaZMote mote) {
this.mote = mote; this.mote = mote;
micaz = mote.getMicaZ(); micaz = mote.getMicaZ();
cc2420 = (CC2420Radio) micaz.getDevice("radio"); cc2420 = (CC2420Radio) micaz.getDevice("radio");
trans = cc2420.getTransmitter(); trans = cc2420.getTransmitter();
recv = (CC2420Radio.Receiver) cc2420.getReceiver(); recv = (CC2420Radio.Receiver) cc2420.getReceiver();
trans.insertProbe(new Medium.Probe.Empty() { trans.insertProbe(new Medium.Probe.Empty() {
int len = 0; int len = 0;
int expLen = 0; int expLen = 0;
byte[] buffer = new byte[127 + 15]; byte[] buffer = new byte[127 + 15];
public void fireBeforeTransmit(Medium.Transmitter t, byte val) { public void fireBeforeTransmit(Medium.Transmitter t, byte val) {
if (len == 0) { if (len == 0) {
lastEventTime = MicaZRadio.this.mote.getSimulation().getSimulationTime(); lastEventTime = MicaZRadio.this.mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.TRANSMISSION_STARTED; lastEvent = RadioEvent.TRANSMISSION_STARTED;
/*logger.debug("----- MICAZ TRANSMISSION STARTED -----");*/ /*logger.debug("----- MICAZ TRANSMISSION STARTED -----");*/
setChanged(); setChanged();
notifyObservers(); notifyObservers();
} }
/* send this byte to all nodes */ /* send this byte to all nodes */
lastOutgoingByte = new RadioByte(val); lastOutgoingByte = new RadioByte(val);
lastEventTime = MicaZRadio.this.mote.getSimulation().getSimulationTime(); lastEventTime = MicaZRadio.this.mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.CUSTOM_DATA_TRANSMITTED; lastEvent = RadioEvent.CUSTOM_DATA_TRANSMITTED;
setChanged(); setChanged();
notifyObservers(); notifyObservers();
buffer[len++] = val; buffer[len++] = val;
if (len == 6) { if (len == 6) {
// System.out.println("## CC2420 Packet of length: " + data + " expected..."); // System.out.println("## CC2420 Packet of length: " + data + " expected...");
expLen = val + 6; expLen = val + 6;
} }
if (len == expLen) { if (len == expLen) {
/*logger.debug("----- MICAZ CUSTOM DATA TRANSMITTED -----");*/ /*logger.debug("----- MICAZ CUSTOM DATA TRANSMITTED -----");*/
lastOutgoingPacket = CC2420RadioPacketConverter.fromCC2420ToCooja(buffer); lastOutgoingPacket = CC2420RadioPacketConverter.fromCC2420ToCooja(buffer);
lastEventTime = MicaZRadio.this.mote.getSimulation().getSimulationTime(); lastEventTime = MicaZRadio.this.mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.PACKET_TRANSMITTED; lastEvent = RadioEvent.PACKET_TRANSMITTED;
/*logger.debug("----- MICAZ PACKET TRANSMITTED -----");*/ /*logger.debug("----- MICAZ PACKET TRANSMITTED -----");*/
setChanged(); setChanged();
notifyObservers(); notifyObservers();
// System.out.println("## CC2420 Transmission finished..."); // System.out.println("## CC2420 Transmission finished...");
lastEventTime = MicaZRadio.this.mote.getSimulation().getSimulationTime(); lastEventTime = MicaZRadio.this.mote.getSimulation().getSimulationTime();
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/ /*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
lastEvent = RadioEvent.TRANSMISSION_FINISHED; lastEvent = RadioEvent.TRANSMISSION_FINISHED;
setChanged(); setChanged();
notifyObservers(); notifyObservers();
len = 0; len = 0;
} }
} }
}); });
} }
/* Packet radio support */ /* Packet radio support */
public RadioPacket getLastPacketTransmitted() { public RadioPacket getLastPacketTransmitted() {
return lastOutgoingPacket; return lastOutgoingPacket;
} }
public RadioPacket getLastPacketReceived() { public RadioPacket getLastPacketReceived() {
return lastIncomingPacket; return lastIncomingPacket;
} }
public void setReceivedPacket(RadioPacket packet) { public void setReceivedPacket(RadioPacket packet) {
} }
/* Custom data radio support */ /* Custom data radio support */
public Object getLastCustomDataTransmitted() { public Object getLastCustomDataTransmitted() {
return lastOutgoingByte; return lastOutgoingByte;
} }
public Object getLastCustomDataReceived() { public Object getLastCustomDataReceived() {
return lastIncomingByte; return lastIncomingByte;
} }
public void receiveCustomData(Object data) { public void receiveCustomData(Object data) {
if (data instanceof RadioByte) { if (data instanceof RadioByte) {
lastIncomingByte = (RadioByte) data; lastIncomingByte = (RadioByte) data;
recv.nextByte(true, (byte)lastIncomingByte.getPacketData()[0]); recv.nextByte(true, lastIncomingByte.getPacketData()[0]);
} }
} }
/* General radio support */ /* General radio support */
public boolean isTransmitting() { public boolean isTransmitting() {
return isTransmitting; return isTransmitting;
} }
public boolean isReceiving() { public boolean isReceiving() {
return isReceiving; return isReceiving;
} }
public boolean isInterfered() { public boolean isInterfered() {
return isInterfered; return isInterfered;
} }
public int getChannel() { public int getChannel() {
// cc2420.updateActiveFrequency(); // cc2420.updateActiveFrequency();
// return cc2420.getActiveChannel(); // return cc2420.getActiveChannel();
return 0; return 0;
} }
public int getFrequency() { public int getFrequency() {
// cc2420.updateActiveFrequency(); // cc2420.updateActiveFrequency();
// return cc2420.getActiveFrequency(); // return cc2420.getActiveFrequency();
return 0; return 0;
} }
public void signalReceptionStart() { public boolean isReceiverOn() {
// cc2420.setCCA(true); /* TODO Implement me */
// hasFailedReception = mode == CC2420.MODE_TXRX_OFF; return true;
isReceiving = true; }
/* TODO cc2420.setSFD(true); */
public void signalReceptionStart() {
lastEventTime = mote.getSimulation().getSimulationTime(); // cc2420.setCCA(true);
lastEvent = RadioEvent.RECEPTION_STARTED; // hasFailedReception = mode == CC2420.MODE_TXRX_OFF;
/*logger.debug("----- SKY RECEPTION STARTED -----");*/ isReceiving = true;
setChanged(); /* TODO cc2420.setSFD(true); */
notifyObservers();
} lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_STARTED;
public void signalReceptionEnd() { /*logger.debug("----- SKY RECEPTION STARTED -----");*/
/* Deliver packet data */ setChanged();
isReceiving = false; notifyObservers();
// hasFailedReception = false; }
isInterfered = false;
// cc2420.setCCA(false); public void signalReceptionEnd() {
/* Deliver packet data */
/* tell the receiver that the packet is ended */ isReceiving = false;
recv.nextByte(false, (byte)0); // hasFailedReception = false;
isInterfered = false;
lastEventTime = mote.getSimulation().getSimulationTime(); // cc2420.setCCA(false);
lastEvent = RadioEvent.RECEPTION_FINISHED;
/*logger.debug("----- SKY RECEPTION FINISHED -----");*/ /* tell the receiver that the packet is ended */
setChanged(); recv.nextByte(false, (byte)0);
notifyObservers();
} lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_FINISHED;
public RadioEvent getLastEvent() { /*logger.debug("----- SKY RECEPTION FINISHED -----");*/
return lastEvent; setChanged();
} notifyObservers();
}
public void interfereAnyReception() {
isInterfered = true; public RadioEvent getLastEvent() {
isReceiving = false; return lastEvent;
// hasFailedReception = false; }
lastIncomingPacket = null;
public void interfereAnyReception() {
//cc2420.setCCA(true); isInterfered = true;
isReceiving = false;
/* is this ok ?? */ // hasFailedReception = false;
recv.nextByte(false, (byte)0); lastIncomingPacket = null;
//cc2420.setCCA(true);
lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_INTERFERED; /* is this ok ?? */
/*logger.debug("----- SKY RECEPTION INTERFERED -----");*/ recv.nextByte(false, (byte)0);
setChanged();
notifyObservers();
} lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_INTERFERED;
public double getCurrentOutputPower() { /*logger.debug("----- SKY RECEPTION INTERFERED -----");*/
return 1.1;//cc2420.getOutputPower(); setChanged();
} notifyObservers();
}
public int getCurrentOutputPowerIndicator() {
return 7; //cc2420.getOutputPowerIndicator(); public double getCurrentOutputPower() {
} return 1.1;//cc2420.getOutputPower();
}
public int getOutputPowerIndicatorMax() {
return 31; public int getCurrentOutputPowerIndicator() {
} return 7; //cc2420.getOutputPowerIndicator();
}
public double getCurrentSignalStrength() {
return 1;//cc2420.getRSSI(); public int getOutputPowerIndicatorMax() {
} return 31;
}
public void setCurrentSignalStrength(double signalStrength) {
//cc2420.setRSSI((int) signalStrength); public double getCurrentSignalStrength() {
} return 1;//cc2420.getRSSI();
}
public double energyConsumption() {
return 1.0; public void setCurrentSignalStrength(double signalStrength) {
} //cc2420.setRSSI((int) signalStrength);
}
public JPanel getInterfaceVisualizer() {
// Location public double energyConsumption() {
JPanel wrapperPanel = new JPanel(new BorderLayout()); return 1.0;
JPanel panel = new JPanel(new GridLayout(5, 2)); }
final JLabel statusLabel = new JLabel(""); public JPanel getInterfaceVisualizer() {
final JLabel lastEventLabel = new JLabel(""); // Location
final JLabel channelLabel = new JLabel(""); JPanel wrapperPanel = new JPanel(new BorderLayout());
final JLabel powerLabel = new JLabel(""); JPanel panel = new JPanel(new GridLayout(5, 2));
final JLabel ssLabel = new JLabel("");
final JButton updateButton = new JButton("Update"); final JLabel statusLabel = new JLabel("");
final JLabel lastEventLabel = new JLabel("");
panel.add(new JLabel("STATE:")); final JLabel channelLabel = new JLabel("");
panel.add(statusLabel); final JLabel powerLabel = new JLabel("");
final JLabel ssLabel = new JLabel("");
panel.add(new JLabel("LAST EVENT:")); final JButton updateButton = new JButton("Update");
panel.add(lastEventLabel);
panel.add(new JLabel("STATE:"));
panel.add(new JLabel("CHANNEL:")); panel.add(statusLabel);
panel.add(channelLabel);
panel.add(new JLabel("LAST EVENT:"));
panel.add(new JLabel("OUTPUT POWER:")); panel.add(lastEventLabel);
panel.add(powerLabel);
panel.add(new JLabel("CHANNEL:"));
panel.add(new JLabel("SIGNAL STRENGTH:")); panel.add(channelLabel);
JPanel smallPanel = new JPanel(new GridLayout(1, 2));
smallPanel.add(ssLabel); panel.add(new JLabel("OUTPUT POWER:"));
smallPanel.add(updateButton); panel.add(powerLabel);
panel.add(smallPanel);
panel.add(new JLabel("SIGNAL STRENGTH:"));
updateButton.addActionListener(new ActionListener() { JPanel smallPanel = new JPanel(new GridLayout(1, 2));
public void actionPerformed(ActionEvent e) { smallPanel.add(ssLabel);
channelLabel.setText(getChannel() + " (freq=" + getFrequency() + " MHz)"); smallPanel.add(updateButton);
powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")"); panel.add(smallPanel);
ssLabel.setText(getCurrentSignalStrength() + " dBm");
} updateButton.addActionListener(new ActionListener() {
}); public void actionPerformed(ActionEvent e) {
channelLabel.setText(getChannel() + " (freq=" + getFrequency() + " MHz)");
Observer observer; powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")");
this.addObserver(observer = new Observer() { ssLabel.setText(getCurrentSignalStrength() + " dBm");
public void update(Observable obs, Object obj) { }
if (isTransmitting()) { });
statusLabel.setText("transmitting");
} else if (isReceiving()) { Observer observer;
statusLabel.setText("receiving"); this.addObserver(observer = new Observer() {
} else if (radioOn /* mode != CC2420.MODE_TXRX_OFF */) { public void update(Observable obs, Object obj) {
statusLabel.setText("listening for traffic"); if (isTransmitting()) {
} else { statusLabel.setText("transmitting");
statusLabel.setText("HW off"); } else if (isReceiving()) {
} statusLabel.setText("receiving");
} else if (radioOn /* mode != CC2420.MODE_TXRX_OFF */) {
lastEventLabel.setText(lastEvent + " @ time=" + lastEventTime); statusLabel.setText("listening for traffic");
} else {
channelLabel.setText(getChannel() + " (freq=" + getFrequency() + " MHz)"); statusLabel.setText("HW off");
powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")"); }
ssLabel.setText(getCurrentSignalStrength() + " dBm");
} lastEventLabel.setText(lastEvent + " @ time=" + lastEventTime);
});
channelLabel.setText(getChannel() + " (freq=" + getFrequency() + " MHz)");
observer.update(null, null); powerLabel.setText(getCurrentOutputPower() + " dBm (indicator=" + getCurrentOutputPowerIndicator() + "/" + getOutputPowerIndicatorMax() + ")");
ssLabel.setText(getCurrentSignalStrength() + " dBm");
wrapperPanel.add(BorderLayout.NORTH, panel); }
});
// Saving observer reference for releaseInterfaceVisualizer
wrapperPanel.putClientProperty("intf_obs", observer); observer.update(null, null);
return wrapperPanel;
} wrapperPanel.add(BorderLayout.NORTH, panel);
public void releaseInterfaceVisualizer(JPanel panel) { // Saving observer reference for releaseInterfaceVisualizer
Observer observer = (Observer) panel.getClientProperty("intf_obs"); wrapperPanel.putClientProperty("intf_obs", observer);
if (observer == null) { return wrapperPanel;
logger.fatal("Error when releasing panel, observer is null"); }
return;
} public void releaseInterfaceVisualizer(JPanel panel) {
Observer observer = (Observer) panel.getClientProperty("intf_obs");
this.deleteObserver(observer); if (observer == null) {
} logger.fatal("Error when releasing panel, observer is null");
return;
public Mote getMote() { }
return mote;
} this.deleteObserver(observer);
}
public Position getPosition() {
return mote.getInterfaces().getPosition(); public Mote getMote() {
} return mote;
}
public Collection<Element> getConfigXML() {
return null; public Position getPosition() {
} return mote.getInterfaces().getPosition();
}
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
} public Collection<Element> getConfigXML() {
} return null;
}
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
}
}

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: SkyByteRadio.java,v 1.9 2009/04/01 23:37:27 fros4943 Exp $ * $Id: SkyByteRadio.java,v 1.10 2009/04/16 14:28:12 fros4943 Exp $
*/ */
package se.sics.cooja.mspmote.interfaces; package se.sics.cooja.mspmote.interfaces;
@ -74,8 +74,6 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
private boolean isReceiving = false; private boolean isReceiving = false;
// private boolean hasFailedReception = false; // private boolean hasFailedReception = false;
private boolean radioOn = true;
private CC2420RadioByte lastOutgoingByte = null; private CC2420RadioByte lastOutgoingByte = null;
private CC2420RadioByte lastIncomingByte = null; private CC2420RadioByte lastIncomingByte = null;
@ -363,7 +361,7 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
statusLabel.setText("transmitting"); statusLabel.setText("transmitting");
} else if (isReceiving()) { } else if (isReceiving()) {
statusLabel.setText("receiving"); statusLabel.setText("receiving");
} else if (radioOn /* mode != CC2420.MODE_TXRX_OFF */) { } else if (isReceiverOn()) {
statusLabel.setText("listening for traffic"); statusLabel.setText("listening for traffic");
} else { } else {
statusLabel.setText("HW off"); statusLabel.setText("HW off");
@ -410,4 +408,8 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) { public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
} }
public boolean isReceiverOn() {
return mote.skyNode.radio.getMode() != CC2420.MODE_TXRX_OFF;
}
} }

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: TR1001Radio.java,v 1.11 2009/03/09 17:14:35 fros4943 Exp $ * $Id: TR1001Radio.java,v 1.12 2009/04/16 14:28:12 fros4943 Exp $
*/ */
package se.sics.cooja.mspmote.interfaces; package se.sics.cooja.mspmote.interfaces;
@ -498,4 +498,9 @@ public class TR1001Radio extends Radio implements USARTListener, CustomDataRadio
public Mote getMote() { public Mote getMote() {
return mote; return mote;
} }
public boolean isReceiverOn() {
/* TODO Implement me */
return true;
}
} }