This example shows how to get RSSI after receiving a packet
File:
"WaspXBeeZB_3_gettingRSSI.pde"
/*
* ------Waspmote XBee ZigBee Getting RSSI Example------
*
* Explanation: This example shows how to get RSSI after receiving a packet
*
* Note: XBee modules must be configured at 38400bps and with API enabled.
*
* Copyright (C) 2009 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 0.1
* Design: David Gascón
* Implementation: Alberto Bielsa
*/
long previous=0;
uint8_t state=0;
void setup()
{
// Inits the XBee ZigBee library
xbeeZB.init(ZIGBEE,FREQ2_4G,NORMAL);
// Powers XBee
xbeeZB.ON();
}
void loop()
{
// Waiting message
previous=millis();
while( (millis()-previous) < 20000 )
{
if( XBee.available() )
{
xbeeZB.treatData();
if( !xbeeZB.error_RX )
{
// Getting RSSI using the API function
xbeeZB.getRSSI();
if( !xbeeZB.error_AT ){
XBee.print("RSSI: ");
XBee.println(xbeeZB.valueRSSI[0],HEX);
}
free(xbeeZB.packet_finished[xbeeZB.pos-1]);
xbeeZB.packet_finished[xbeeZB.pos-1]=NULL;
xbeeZB.pos--;
}
}
}
}
You can download the code of this example.