Skip to content

Commit

Permalink
Merge pull request contiki-os#54 from cmorty/contiki_mote_lqi_support
Browse files Browse the repository at this point in the history
Add access to LQI and RSSI to Contiki motes
  • Loading branch information
fros4943 committed Nov 19, 2013
2 parents dc05eea + 83ae37b commit e7789f9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions platform/cooja/dev/cooja-radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ int simSignalStrength = -100;
int simLastSignalStrength = -100;
char simPower = 100;
int simRadioChannel = 26;
int simLQI = 105;

static const void *pending_data;

Expand Down Expand Up @@ -93,6 +94,12 @@ radio_signal_strength_current(void)
return simSignalStrength;
}
/*---------------------------------------------------------------------------*/
int
radio_LQI(void)
{
return simLQI;
}
/*---------------------------------------------------------------------------*/
static int
radio_on(void)
{
Expand Down Expand Up @@ -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;
}
/*---------------------------------------------------------------------------*/
Expand Down
7 changes: 7 additions & 0 deletions platform/cooja/dev/cooja-radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,24 @@ public void setCurrentSignalStrength(double 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() {
return mote.getInterfaces().getPosition();
}
Expand Down

0 comments on commit e7789f9

Please sign in to comment.