From 940a2903f23d53d70dc77b981a417eab3c81ccfd Mon Sep 17 00:00:00 2001 From: joxe Date: Sun, 24 Jan 2010 23:16:17 +0000 Subject: [PATCH] fixed interference in app radio --- .../sics/cooja/interfaces/ApplicationRadio.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/interfaces/ApplicationRadio.java b/tools/cooja/java/se/sics/cooja/interfaces/ApplicationRadio.java index e3a182b62..b32a97086 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.10 2009/10/28 14:38:02 fros4943 Exp $ + * $Id: ApplicationRadio.java,v 1.11 2010/01/24 23:16:17 joxe Exp $ */ package se.sics.cooja.interfaces; @@ -83,6 +83,8 @@ public class ApplicationRadio extends Radio { private double outputPower = 0; private int outputPowerIndicator = 100; +private int interfered; + public ApplicationRadio(Mote mote) { this.mote = mote; this.simulation = mote.getSimulation(); @@ -117,10 +119,17 @@ public class ApplicationRadio extends Radio { } public void signalReceptionEnd() { + //System.out.println("SignalReceptionEnded for node: " + mote.getID() + " intf:" + interfered); if (isInterfered() || packetToMote == null) { - isInterfered = false; + interfered--; + if (interfered == 0) isInterfered = false; + if (interfered < 0) { + isInterfered = false; + //logger.warn("Interfered got lower than 0!!!"); + interfered = 0; + } packetToMote = null; - return; + if (interfered > 0) return; } isReceiving = false; @@ -154,7 +163,9 @@ public class ApplicationRadio extends Radio { return lastEvent; } + /* Note: this must be called exactly as many times as the reception ended */ public void interfereAnyReception() { + interfered++; if (!isInterfered()) { isInterfered = true;