From 4fc082db3502f8801bcdb85f1814cf74f697ce80 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 18 Mar 2008 13:03:24 +0000 Subject: [PATCH] using new radio packet format --- .../cooja/interfaces/ApplicationRadio.java | 22 +++++++++---------- .../se/sics/cooja/plugins/RadioLogger.java | 9 ++------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/interfaces/ApplicationRadio.java b/tools/cooja/java/se/sics/cooja/interfaces/ApplicationRadio.java index 218d274a9..76bc850d7 100644 --- a/tools/cooja/java/se/sics/cooja/interfaces/ApplicationRadio.java +++ b/tools/cooja/java/se/sics/cooja/interfaces/ApplicationRadio.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ApplicationRadio.java,v 1.3 2008/03/17 09:50:27 fros4943 Exp $ + * $Id: ApplicationRadio.java,v 1.4 2008/03/18 13:03:24 fros4943 Exp $ */ package se.sics.cooja.interfaces; @@ -42,18 +42,18 @@ import se.sics.cooja.*; /** * Application radio. May for example be used by Java-based mote to implement - * radio functionality. Support radio channels and output power functionality. + * radio functionality. Supports radio channels and output power functionality. * The mote should observe the radio for incoming radio packet data. * * @author Fredrik Osterlind */ -public class ApplicationRadio extends Radio implements PacketRadio { +public class ApplicationRadio extends Radio { private Mote myMote; private static Logger logger = Logger.getLogger(ApplicationRadio.class); - private static byte[] packetFromMote = null; - private static byte[] packetToMote = null; + private RadioPacket packetFromMote = null; + private RadioPacket packetToMote = null; private boolean isTransmitting = false; private boolean isReceiving = false; @@ -65,7 +65,7 @@ public class ApplicationRadio extends Radio implements PacketRadio { private int lastEventTime = 0; private boolean outPacketExists = false; - private byte[] outPacket = null; + private RadioPacket outPacket = null; private int outPacketDuration = -1; private double signalStrength = -100; @@ -78,16 +78,16 @@ public class ApplicationRadio extends Radio implements PacketRadio { } /* Packet radio support */ - public byte[] getLastPacketTransmitted() { + public RadioPacket getLastPacketTransmitted() { return packetFromMote; } - public byte[] getLastPacketReceived() { + public RadioPacket getLastPacketReceived() { return packetToMote; } - public void setReceivedPacket(byte[] data) { - packetToMote = data; + public void setReceivedPacket(RadioPacket packet) { + packetToMote = packet; } /* General radio support */ @@ -189,7 +189,7 @@ public class ApplicationRadio extends Radio implements PacketRadio { * @param packet Packet data * @param duration Duration to transmit */ - public void startTransmittingPacket(byte[] packet, int duration) { + public void startTransmittingPacket(RadioPacket packet, int duration) { outPacketExists = true; outPacketDuration = duration; outPacket = packet; diff --git a/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java b/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java index 24e517a54..2b4e4b9ba 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java +++ b/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: RadioLogger.java,v 1.11 2007/11/20 04:17:11 fros4943 Exp $ + * $Id: RadioLogger.java,v 1.12 2008/03/18 13:06:19 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -45,7 +45,6 @@ import org.apache.log4j.Logger; import org.jdom.Element; import se.sics.cooja.*; -import se.sics.cooja.interfaces.PacketRadio; import se.sics.cooja.interfaces.Radio; /** @@ -252,11 +251,7 @@ public class RadioLogger extends VisPlugin { data[DATAPOS_TIME] = new Integer(simulation.getSimulationTime()); data[DATAPOS_CONNECTION] = newConnection; - if (newConnection.getSource() instanceof PacketRadio) { - data[DATAPOS_DATA] = ((PacketRadio) newConnection.getSource()).getLastPacketTransmitted(); - } else { - data[DATAPOS_DATA] = null; - } + data[DATAPOS_DATA] = newConnection.getSource().getLastPacketTransmitted().getPacketData(); rowData.add(data); }