diff --git a/platform/cooja/dev/radio-arch.c b/platform/cooja/dev/radio-arch.c index 6f6f03206..5bd45207f 100644 --- a/platform/cooja/dev/radio-arch.c +++ b/platform/cooja/dev/radio-arch.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: radio-arch.c,v 1.4 2006/10/05 12:09:40 fros4943 Exp $ + * $Id: radio-arch.c,v 1.5 2006/10/05 14:44:43 fros4943 Exp $ */ #include "dev/radio-arch.h" @@ -56,8 +56,20 @@ char simOutDataBuffer[UIP_BUFSIZE]; int simOutSize; char simRadioHWOn = 1; -int simSignalStrength; +int simSignalStrength = 0; +char simPower = 100; +/*-----------------------------------------------------------------------------------*/ +int +radio_sstrength(void) +{ + return simSignalStrength; +} +/*-----------------------------------------------------------------------------------*/ +void radio_set_txpower(unsigned char power) { + // 1 - 100: Number indicating output power + simPower = power; +} /*-----------------------------------------------------------------------------------*/ static void doInterfaceActionsBeforeTick(void) @@ -85,6 +97,8 @@ doInterfaceActionsBeforeTick(void) return; } + // ** Good place to add explicit manchester/gcr-encoding + // Hand over new packet to uIP uip_len = simInSize; memcpy(&uip_buf[UIP_LLH_LEN], &simInDataBuffer[0], simInSize); @@ -120,8 +134,7 @@ simDoSend(void) return UIP_FW_ZEROLEN; } - // - Initiate transmission - - simTransmitting = 1; + // ** Good place to add explicit manchester/gcr-decoding // Copy packet data to temporary storage memcpy(&simOutDataBuffer[0], &uip_buf[UIP_LLH_LEN], uip_len); @@ -131,7 +144,7 @@ simDoSend(void) while (simReceiving) { cooja_mt_yield(); } - + // Busy-wait until ether is ready, or die (MAC imitation) int retries=0; /* while (retries < 5 && simSignalStrength > -80) { @@ -144,6 +157,10 @@ simDoSend(void) return UIP_FW_DROPPED; } */ + + // - Initiate transmission - + simTransmitting = 1; + // Busy-wait while transmitting while (simTransmitting) { cooja_mt_yield(); diff --git a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java index 8456ff9a5..6d7c3fb8c 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ContikiRadio.java,v 1.6 2006/10/05 12:27:30 fros4943 Exp $ + * $Id: ContikiRadio.java,v 1.7 2006/10/05 14:46:16 fros4943 Exp $ */ package se.sics.cooja.contikimote.interfaces; @@ -62,6 +62,7 @@ import se.sics.cooja.interfaces.Radio; *

*

  • char simRadioHWOn (radio hardware status (on/off)) *
  • int simSignalStrength (heard radio signal strength) + *
  • char simPower (number indicating power output) * *

    * Dependency core interfaces are: @@ -103,6 +104,8 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface { private RadioEvent lastEvent = RadioEvent.UNKNOWN; private int lastEventTime = 0; + + private int oldOutputPowerIndicator = -1; /** * Creates an interface to the radio at mote. @@ -261,6 +264,16 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface { return interferenceEndTime >= myMote.getSimulation().getSimulationTime(); } + public double getCurrentOutputPower() { + // TODO Implement method + logger.warn("Not implemeted, always returning 1.5 dBm"); + return 1.5; + } + + public int getCurrentOutputPowerIndicator() { + return (int) myMoteMemory.getByteValueOf("simPower"); + } + public double getCurrentSignalStrength() { return myMoteMemory.getIntValueOf("simSignalStrength"); } @@ -303,6 +316,13 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface { } myEnergyConsumption = energyListeningRadioPerTick; + // Check if radio output power changed + if (myMoteMemory.getByteValueOf("simPower") != oldOutputPowerIndicator) { + oldOutputPowerIndicator = myMoteMemory.getByteValueOf("simPower"); + this.setChanged(); + this.notifyObservers(); + } + // Are we transmitting but should stop? if (transmitting && myMote.getSimulation().getSimulationTime() >= transmissionEndTime) { myMoteMemory.setByteValueOf("simTransmitting", (byte) 0);