For getting RSSI value from xbee
Dependents: XBeeGetRSSISampleProgram Xbee_s2_RX_versao2
Diff: XBeeGetRssi.cpp
- Revision:
- 7:588a7745cc0e
- Parent:
- 6:2e725705db90
- Child:
- 9:eb8838ce9d65
--- a/XBeeGetRssi.cpp Sun Aug 25 13:50:36 2013 +0000 +++ b/XBeeGetRssi.cpp Sun Aug 25 14:08:44 2013 +0000 @@ -19,46 +19,29 @@ //int judge_counter=0; int judge_counter=0; int rssi_counter=0; - int xbee_message_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 - _xbee_message[i]='^';//initial value; } -// pc.printf("At the first of xbee class.\r\n"); _MyXbee.putc('T'); - while(_MyXbee.readable()){ - _xbee_message[0]=_MyXbee.getc(); - } -// pc.printf("first message from xbee;%s\r\n",_xbee_message[0]); wait(1.0); - //_MyXbee.printf("+++"); //entering AT command mode. _MyXbee.putc('+'); wait_ms(1); _MyXbee.putc('+'); wait_ms(1); _MyXbee.putc('+'); wait_ms(1); -// pc.printf("sent +++\r\n"); - while(_xbee_message[judge_counter++]!='\r'){ - while(_MyXbee.readable()){ - _xbee_message[xbee_message_counter++]=_MyXbee.getc(); - } - }_xbee_message[judge_counter]='\0'; + judge_counter=0; //reset counter for later use - xbee_message_counter=0; //reset counter for later use - - // while(_xbee_message[judge_counter++]!='\0'){ -// pc.printf("got xbee message;%s\r\n",_xbee_message[xbee_message_counter++]); - //} + wait(1.0); judge_counter=0; - xbee_message_counter=0; _MyXbee.putc('A'); wait_ms(5); @@ -70,15 +53,12 @@ wait_ms(10); _MyXbee.putc('\r'); wait_ms(10); -// pc.printf("sent ATDB!\r\n"); while(_rssi[judge_counter++]!='\0'){ while(_MyXbee.readable()){ _rssi[rssi_counter++]=_MyXbee.getc(); - //rssi_counter++; } - }//_rssi[rssi_counter]='\0'; //contain rssi value to _rssi[] -// pc.printf("Here is class end!\r\n"); + } _MyXbee.putc('A'); wait_ms(5);