Difference between revisions of "Rssi Demo"

From TinyOS Wiki
Jump to: navigation, search
m (Corrected some typos)
(Continuing the tutorial)
Line 44: Line 44:
  
 
== Rssi Base ==
 
== Rssi Base ==
 +
RssiBase is the application the will be put in a node connected to the serial port and will effectively read the RSSI. It uses the InterceptBase component to  forward the messages over the radio but intercept the RssiMsg before it is forwarded and include the RSSI value in it. It contains some cryptic macros so it can work correctly with chips that use either the CC2420 or CC1000 radio. First, let us analyse the forward event:
 +
 +
  event bool RssiMsgIntercept.forward(message_t *msg, void *payload, uint8_t len) {
 +
    RssiMsg *rssiMsg = (RssiMsg*) payload;
 +
    rssiMsg->rssi = getRssi(msg);
 +
   
 +
    return TRUE;
 +
  }
 +
 +
It always forwards the messages (always returns true) but modifies the payload by including the rssi. Let us now analyse the <code>getRssi(message_t *)</code> method:
 +
 +
 +
#ifdef __CC2420_H__ 
 +
  uint16_t getRssi(message_t *msg){
 +
    return (uint16_t) call CC2420Packet.getRssi(msg);
 +
  }
 +
#elif defined(CC1K_RADIO_MSG_H)
 +
    uint16_t getRssi(message_t *msg){
 +
    cc1000_metadata_t *md =(cc1000_metadata_t*) msg->metadata;
 +
    return md->strength_or_preamble;
 +
  }
 +
#else
 +
  #error Radio chip not supported! This demo currently works only \
 +
        for motes with CC1000 or CC2420 radios. 
 +
#endif //__CC2420_H__
 +
 +
That code, for platforms with the CC2420 radio, gets the RSSI from the <code>getRssi(message_t *)</code> method of the <code>CC2420Packet</code> interface, provided by the <code>CC2420ActiveMessageC</code> HAL component. For platforms with the CC1000 radio the RSSI is extracted from the packet metadata.
 +
 +
== Java Application ==
 
'''TODO'''
 
'''TODO'''
  

Revision as of 06:39, 11 April 2008

This lesson is to give an example on how to get Rssi readings from incoming packets. It consists of two applications:

  • a simple application that periodically sends messages over the radio, and
  • a modified version of BaseStation that includes the Rssi data on the payload of messages received over the radio before forwarding them over to the serial link.

It will also be shown how to get RSSI noise floor readings, to estimate the channel background noise when no node is transmitting.

Currently, this demo works only for motes that use CC1000 or CC2420 radio transceivers, but it should contain enough information for porting it to other chips that provide RSSI in a similar manner.


Introduction

RSSI is an acronym for Received Signal Strength Indication. It is a measure of the signal power on the radio link, usually in the units of dBm, while a message is being received. It can be used for estimating node connectivity and node distance (although the relation between distance and RSSI is noisy and not straightforward), among other things. Another usage of RSSI is to sample the channel power when no node is transmitting to estimate the background noise, also known as noise floor.

According to TinyOS' HAA <ref name="tep2">

 TEP 2: Hardware Abstraction Architecture

</ref> the RSSI data is not provided by the standard platform independent Hardware Interface Layer (represented interfaces Packet and AMPacket, as explained in TEP 116 <ref name="tep116">

 TEP 116: Packet Protocols

</ref> ). RSSI must be accessed by a platform-specific HAL interface, as in the case of the CC2420 or by a specific field of the message_t struct as defined in the platform_message.h <ref name="tep111">

 TEP 111: message_t

</ref> like in the case of the CC1000.

The RSSI values given by TinyOS are usually not in dBm units, and should be converted by the platform-specific relation to get meaningful data out of it.

Demo Application

Since RSSI is very platform-specific it will now be shown a hands-on demo to explain how to get RSSI readings from incoming packets. This demo is located in $TOSROOT/apps/tutorials/RssiDemo .

Intercept Base

InterceptBase is a modified version of the BaseStation component that provides the Intercept interface to allow the user application to inspect and modify radio and serial messages before they are forwarded to the other link, and to decide whether they shall be forwarded or not.

Sending Mote

SendingMote is the application to be put in the mote that sends the message whose RSSI will be read by the base. It contains a simple logic to periodically send a RssiMsg, as defined bellow:

 typedef nx_struct RssiMsg{
   nx_uint16_t rssi;
 } RssiMsg;

The RssiMsg is sent empty, it is the base that will include the RSSI value in the message.

Rssi Base

RssiBase is the application the will be put in a node connected to the serial port and will effectively read the RSSI. It uses the InterceptBase component to forward the messages over the radio but intercept the RssiMsg before it is forwarded and include the RSSI value in it. It contains some cryptic macros so it can work correctly with chips that use either the CC2420 or CC1000 radio. First, let us analyse the forward event:

 event bool RssiMsgIntercept.forward(message_t *msg, void *payload, uint8_t len) {
   RssiMsg *rssiMsg = (RssiMsg*) payload;
   rssiMsg->rssi = getRssi(msg);
   
   return TRUE;
 }

It always forwards the messages (always returns true) but modifies the payload by including the rssi. Let us now analyse the getRssi(message_t *) method:


#ifdef __CC2420_H__  
 uint16_t getRssi(message_t *msg){
   return (uint16_t) call CC2420Packet.getRssi(msg);
 }
#elif defined(CC1K_RADIO_MSG_H)
   uint16_t getRssi(message_t *msg){
   cc1000_metadata_t *md =(cc1000_metadata_t*) msg->metadata;
   return md->strength_or_preamble;
 }
#else
 #error Radio chip not supported! This demo currently works only \
        for motes with CC1000 or CC2420 radios.  
#endif //__CC2420_H__

That code, for platforms with the CC2420 radio, gets the RSSI from the getRssi(message_t *) method of the CC2420Packet interface, provided by the CC2420ActiveMessageC HAL component. For platforms with the CC1000 radio the RSSI is extracted from the packet metadata.

Java Application

TODO

Noise Floor Reading

TODO

References

<references/>