From 32b5f206b16d87aae710f8cad321766c900d77cf Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 18 Mar 2008 15:48:00 +0000 Subject: [PATCH] implementing custom data objects --- .../cooja/mspmote/interfaces/SkyRadio.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyRadio.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyRadio.java index 75f7a4eb2..5cbc4b256 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyRadio.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyRadio.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: SkyRadio.java,v 1.2 2008/03/18 13:34:20 fros4943 Exp $ + * $Id: SkyRadio.java,v 1.3 2008/03/18 15:48:00 fros4943 Exp $ */ package se.sics.cooja.mspmote.interfaces; @@ -41,6 +41,7 @@ import org.apache.log4j.Logger; import org.jdom.Element; import se.sics.cooja.*; +import se.sics.cooja.interfaces.CustomDataRadio; import se.sics.cooja.interfaces.Position; import se.sics.cooja.interfaces.Radio; import se.sics.cooja.mspmote.SkyMote; @@ -53,7 +54,7 @@ import se.sics.mspsim.chip.PacketListener; * @author Fredrik Osterlind */ @ClassDescription("CC2420") -public class SkyRadio extends Radio { +public class SkyRadio extends Radio implements CustomDataRadio { private static Logger logger = Logger.getLogger(SkyRadio.class); private int lastEventTime = 0; @@ -90,6 +91,7 @@ public class SkyRadio extends Radio { public void transmissionStarted() { lastEventTime = myMote.getSimulation().getSimulationTime(); lastEvent = RadioEvent.TRANSMISSION_STARTED; + /*logger.debug("----- SKY TRANSMISSION STARTED -----");*/ setChanged(); notifyObservers(); } @@ -104,6 +106,7 @@ public class SkyRadio extends Radio { lastEventTime = myMote.getSimulation().getSimulationTime(); lastEvent = RadioEvent.CUSTOM_DATA_TRANSMITTED; + /*logger.debug("----- SKY CUSTOM DATA TRANSMITTED -----");*/ setChanged(); notifyObservers(); @@ -111,10 +114,12 @@ public class SkyRadio extends Radio { lastEventTime = myMote.getSimulation().getSimulationTime(); lastEvent = RadioEvent.PACKET_TRANSMITTED; + /*logger.debug("----- SKY PACKET TRANSMITTED -----");*/ setChanged(); notifyObservers(); lastEventTime = myMote.getSimulation().getSimulationTime(); + /*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/ lastEvent = RadioEvent.TRANSMISSION_FINISHED; setChanged(); notifyObservers(); @@ -136,6 +141,21 @@ public class SkyRadio extends Radio { lastIncomingCC2420Packet = CC2420RadioPacketConverter.fromCoojaToCC24240(packet); } + /* Custom data radio support */ + public Object getLastCustomDataTransmitted() { + return lastOutgoingCC2420Packet; + } + + public Object getLastCustomDataReceived() { + return lastIncomingCC2420Packet; + } + + public void receiveCustomData(Object data) { + if (data instanceof CC2420RadioPacket) { + lastIncomingCC2420Packet = (CC2420RadioPacket) data; + } + } + /* General radio support */ public boolean isTransmitting() { return isTransmitting; @@ -164,6 +184,7 @@ public class SkyRadio extends Radio { lastEventTime = myMote.getSimulation().getSimulationTime(); lastEvent = RadioEvent.RECEPTION_STARTED; + /*logger.debug("----- SKY RECEPTION STARTED -----");*/ setChanged(); notifyObservers(); } @@ -186,6 +207,7 @@ public class SkyRadio extends Radio { lastEventTime = myMote.getSimulation().getSimulationTime(); lastEvent = RadioEvent.RECEPTION_FINISHED; + /*logger.debug("----- SKY RECEPTION FINISHED -----");*/ setChanged(); notifyObservers(); } @@ -203,6 +225,7 @@ public class SkyRadio extends Radio { lastEventTime = myMote.getSimulation().getSimulationTime(); lastEvent = RadioEvent.RECEPTION_INTERFERED; + /*logger.debug("----- SKY RECEPTION INTERFERED -----");*/ setChanged(); notifyObservers(); }