From 316f154c1f91e6ed815173062ef88881c8f00edd Mon Sep 17 00:00:00 2001 From: fros4943 Date: Mon, 4 May 2009 15:34:00 +0000 Subject: [PATCH] notify when radio HW is turned on/off --- .../cooja/mspmote/interfaces/SkyByteRadio.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java index 7a08962b3..c9c4f7a9f 100755 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: SkyByteRadio.java,v 1.10 2009/04/16 14:28:12 fros4943 Exp $ + * $Id: SkyByteRadio.java,v 1.11 2009/05/04 15:34:00 fros4943 Exp $ */ package se.sics.cooja.mspmote.interfaces; @@ -49,6 +49,8 @@ import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.chip.RFListener; import se.sics.mspsim.chip.CC2420.RadioState; import se.sics.mspsim.chip.CC2420.StateListener; +import se.sics.mspsim.core.Chip; +import se.sics.mspsim.core.OperatingModeListener; /** * CC2420 to COOJA wrapper. @@ -139,6 +141,19 @@ public class SkyByteRadio extends Radio implements CustomDataRadio { } } }); + + cc2420.addOperatingModeListener(new OperatingModeListener() { + public void modeChanged(Chip source, int mode) { + if (isReceiverOn()) { + lastEvent = RadioEvent.HW_ON; + } else { + lastEvent = RadioEvent.HW_OFF; + } + lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime(); + setChanged(); + notifyObservers(); + } + }); } /* Packet radio support */