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

View file

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

View file

@ -250,6 +250,24 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
myMoteMemory.setIntValueOf("simSignalStrength", (int) signalStrength); 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() { public Position getPosition() {
return mote.getInterfaces().getPosition(); return mote.getInterfaces().getPosition();
} }