Add access to LQI and RSSI to Contiki motes

This commit is contained in:
Yvonne-Anne Pignolet 2012-12-11 12:09:33 +01:00 committed by Moritz 'Morty' Strübe
parent 7b59e1dbe7
commit 83ae37b48e
3 changed files with 35 additions and 0 deletions

View File

@ -62,6 +62,7 @@ int simSignalStrength = -100;
int simLastSignalStrength = -100;
char simPower = 100;
int simRadioChannel = 26;
int simLQI = 105;
static const void *pending_data;
@ -93,6 +94,12 @@ radio_signal_strength_current(void)
return simSignalStrength;
}
/*---------------------------------------------------------------------------*/
int
radio_LQI(void)
{
return simLQI;
}
/*---------------------------------------------------------------------------*/
static int
radio_on(void)
{
@ -145,6 +152,9 @@ radio_read(void *buf, unsigned short bufsize)
memcpy(buf, simInDataBuffer, simInSize);
simInSize = 0;
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, simSignalStrength);
packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, simLQI);
return tmp;
}
/*---------------------------------------------------------------------------*/

View File

@ -64,4 +64,11 @@ radio_signal_strength_last(void);
int
radio_signal_strength_current(void);
/**
* Link quality indicator of last received packet.
*/
int
radio_LQI(void);
#endif /* __COOJA_RADIO_H__ */

View File

@ -250,6 +250,24 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
myMoteMemory.setIntValueOf("simSignalStrength", (int) signalStrength);
}
/** Set LQI to a value between 0 and 255.
*
* @see se.sics.cooja.interfaces.Radio#setLQI(int)
*/
public void setLQI(int lqi){
if(lqi<0) {
lqi=0;
}
else if(lqi>0xff) {
lqi=0xff;
}
myMoteMemory.setIntValueOf("simLQI", lqi);
}
public int getLQI(){
return myMoteMemory.getIntValueOf("simLQI");
}
public Position getPosition() {
return mote.getInterfaces().getPosition();
}