For getting RSSI value from xbee
Dependents: XBeeGetRSSISampleProgram Xbee_s2_RX_versao2
Diff: XBeeGetRssi.cpp
- Revision:
- 6:2e725705db90
- Parent:
- 5:790675fae748
- Child:
- 7:588a7745cc0e
- Child:
- 8:b1313aaddf17
diff -r 790675fae748 -r 2e725705db90 XBeeGetRssi.cpp --- a/XBeeGetRssi.cpp Sat Aug 24 07:07:50 2013 +0000 +++ b/XBeeGetRssi.cpp Sun Aug 25 13:50:36 2013 +0000 @@ -1,3 +1,10 @@ +/*---------------------------------------------------------- +20130824:Todos:improve the performance of this program. +get only the rssi value. + + +----------------------------------------------------------*/ + #include "XBeeGetRssi.h" #include "mbed.h" //#include <string.h> @@ -8,7 +15,7 @@ _rx=rx; } -char XBeeGetRssi::get(int n){ +char XBeeGetRssi::getRssi(int n){ //int judge_counter=0; int judge_counter=0; int rssi_counter=0; @@ -17,9 +24,10 @@ Serial pc(USBTX,USBRX); //for debugging. Serial _MyXbee(_tx,_rx); - _rssi[0]='P'; //initial value - _xbee_message[0]='P';//initial value; - + for(int i=0;i<20;i++){ + _rssi[i]='^'; //initial value + _xbee_message[i]='^';//initial value; + } // pc.printf("At the first of xbee class.\r\n"); _MyXbee.putc('T'); @@ -31,11 +39,11 @@ wait(1.0); //_MyXbee.printf("+++"); //entering AT command mode. _MyXbee.putc('+'); - wait_ms(100); + wait_ms(1); _MyXbee.putc('+'); - wait_ms(100); + wait_ms(1); _MyXbee.putc('+'); - wait_ms(100); + wait_ms(1); // pc.printf("sent +++\r\n"); while(_xbee_message[judge_counter++]!='\r'){ while(_MyXbee.readable()){ @@ -53,15 +61,15 @@ xbee_message_counter=0; _MyXbee.putc('A'); - wait_ms(100); + wait_ms(5); _MyXbee.putc('T'); - wait_ms(100); + wait_ms(10); _MyXbee.putc('D'); - wait_ms(100); + wait_ms(10); _MyXbee.putc('B'); - wait_ms(100); + wait_ms(10); _MyXbee.putc('\r'); - wait_ms(100); + wait_ms(10); // pc.printf("sent ATDB!\r\n"); while(_rssi[judge_counter++]!='\0'){ @@ -73,13 +81,13 @@ // pc.printf("Here is class end!\r\n"); _MyXbee.putc('A'); - wait_ms(100); + wait_ms(5); _MyXbee.putc('T'); - wait_ms(100); + wait_ms(5); _MyXbee.putc('C'); - wait_ms(100); + wait_ms(5); _MyXbee.putc('N'); - wait_ms(100); + wait_ms(5); _MyXbee.putc('\r'); return _rssi[n];