Download Final Report - Electrical and Computer Engineering

Transcript
}
/*
* Read Reply
*
* Used only for Node Discovery
*
ND is performed in AT command mode and the reply
*
must be read in one char at a time
*
*/
int readReply(int max_returns) {
char c;
unsigned long time;
unsigned long start = millis();
int i=0;
int num_returns = 0;
memset (buffer,'\0',32);
while (true) {
if(Serial.available()) {
c = Serial.read();
if (c == '\r') {
num_returns += 1;
if (num_returns >= max_returns || i==0) {
return i;
}
47