added signal strength and output power (non-core) functions
+ bug fix
This commit is contained in:
parent
2892edc2fa
commit
f2dd0a96cd
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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"
|
#include "dev/radio-arch.h"
|
||||||
|
@ -56,8 +56,20 @@ char simOutDataBuffer[UIP_BUFSIZE];
|
||||||
int simOutSize;
|
int simOutSize;
|
||||||
|
|
||||||
char simRadioHWOn = 1;
|
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
|
static void
|
||||||
doInterfaceActionsBeforeTick(void)
|
doInterfaceActionsBeforeTick(void)
|
||||||
|
@ -85,6 +97,8 @@ doInterfaceActionsBeforeTick(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ** Good place to add explicit manchester/gcr-encoding
|
||||||
|
|
||||||
// Hand over new packet to uIP
|
// Hand over new packet to uIP
|
||||||
uip_len = simInSize;
|
uip_len = simInSize;
|
||||||
memcpy(&uip_buf[UIP_LLH_LEN], &simInDataBuffer[0], simInSize);
|
memcpy(&uip_buf[UIP_LLH_LEN], &simInDataBuffer[0], simInSize);
|
||||||
|
@ -120,8 +134,7 @@ simDoSend(void)
|
||||||
return UIP_FW_ZEROLEN;
|
return UIP_FW_ZEROLEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - Initiate transmission -
|
// ** Good place to add explicit manchester/gcr-decoding
|
||||||
simTransmitting = 1;
|
|
||||||
|
|
||||||
// Copy packet data to temporary storage
|
// Copy packet data to temporary storage
|
||||||
memcpy(&simOutDataBuffer[0], &uip_buf[UIP_LLH_LEN], uip_len);
|
memcpy(&simOutDataBuffer[0], &uip_buf[UIP_LLH_LEN], uip_len);
|
||||||
|
@ -144,6 +157,10 @@ simDoSend(void)
|
||||||
return UIP_FW_DROPPED;
|
return UIP_FW_DROPPED;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// - Initiate transmission -
|
||||||
|
simTransmitting = 1;
|
||||||
|
|
||||||
// Busy-wait while transmitting
|
// Busy-wait while transmitting
|
||||||
while (simTransmitting) {
|
while (simTransmitting) {
|
||||||
cooja_mt_yield();
|
cooja_mt_yield();
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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;
|
package se.sics.cooja.contikimote.interfaces;
|
||||||
|
@ -62,6 +62,7 @@ import se.sics.cooja.interfaces.Radio;
|
||||||
* <p>
|
* <p>
|
||||||
* <li>char simRadioHWOn (radio hardware status (on/off))
|
* <li>char simRadioHWOn (radio hardware status (on/off))
|
||||||
* <li>int simSignalStrength (heard radio signal strength)
|
* <li>int simSignalStrength (heard radio signal strength)
|
||||||
|
* <li>char simPower (number indicating power output)
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* Dependency core interfaces are:
|
* Dependency core interfaces are:
|
||||||
|
@ -104,6 +105,8 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface {
|
||||||
private RadioEvent lastEvent = RadioEvent.UNKNOWN;
|
private RadioEvent lastEvent = RadioEvent.UNKNOWN;
|
||||||
private int lastEventTime = 0;
|
private int lastEventTime = 0;
|
||||||
|
|
||||||
|
private int oldOutputPowerIndicator = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an interface to the radio at mote.
|
* Creates an interface to the radio at mote.
|
||||||
*
|
*
|
||||||
|
@ -261,6 +264,16 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface {
|
||||||
return interferenceEndTime >= myMote.getSimulation().getSimulationTime();
|
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() {
|
public double getCurrentSignalStrength() {
|
||||||
return myMoteMemory.getIntValueOf("simSignalStrength");
|
return myMoteMemory.getIntValueOf("simSignalStrength");
|
||||||
}
|
}
|
||||||
|
@ -303,6 +316,13 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface {
|
||||||
}
|
}
|
||||||
myEnergyConsumption = energyListeningRadioPerTick;
|
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?
|
// Are we transmitting but should stop?
|
||||||
if (transmitting && myMote.getSimulation().getSimulationTime() >= transmissionEndTime) {
|
if (transmitting && myMote.getSimulation().getSimulationTime() >= transmissionEndTime) {
|
||||||
myMoteMemory.setByteValueOf("simTransmitting", (byte) 0);
|
myMoteMemory.setByteValueOf("simTransmitting", (byte) 0);
|
||||||
|
|
Loading…
Reference in a new issue