For getting RSSI value from xbee
Dependents: XBeeGetRSSISampleProgram Xbee_s2_RX_versao2
XBeeGetRssi.cpp
- Committer:
- ATKINZ117
- Date:
- 2013-08-25
- Revision:
- 7:588a7745cc0e
- Parent:
- 6:2e725705db90
- Child:
- 9:eb8838ce9d65
File content as of revision 7:588a7745cc0e:
/*---------------------------------------------------------- 20130824:Todos:improve the performance of this program. get only the rssi value. ----------------------------------------------------------*/ #include "XBeeGetRssi.h" #include "mbed.h" //#include <string.h> XBeeGetRssi::XBeeGetRssi(PinName tx,PinName rx){ _tx=tx; _rx=rx; } char XBeeGetRssi::getRssi(int n){ //int judge_counter=0; int judge_counter=0; int rssi_counter=0; //int xbee_message_counter=0; Serial pc(USBTX,USBRX); //for debugging. Serial _MyXbee(_tx,_rx); for(int i=0;i<20;i++){ _rssi[i]='^'; //initial value } _MyXbee.putc('T'); wait(1.0); _MyXbee.putc('+'); wait_ms(1); _MyXbee.putc('+'); wait_ms(1); _MyXbee.putc('+'); wait_ms(1); judge_counter=0; //reset counter for later use wait(1.0); judge_counter=0; _MyXbee.putc('A'); wait_ms(5); _MyXbee.putc('T'); wait_ms(10); _MyXbee.putc('D'); wait_ms(10); _MyXbee.putc('B'); wait_ms(10); _MyXbee.putc('\r'); wait_ms(10); while(_rssi[judge_counter++]!='\0'){ while(_MyXbee.readable()){ _rssi[rssi_counter++]=_MyXbee.getc(); } } _MyXbee.putc('A'); wait_ms(5); _MyXbee.putc('T'); wait_ms(5); _MyXbee.putc('C'); wait_ms(5); _MyXbee.putc('N'); wait_ms(5); _MyXbee.putc('\r'); return _rssi[n]; }