Hi.
Based on the function found here http://www.cooking-hacks.com/documentation/tutorials/arduino-gprs-gsm-quadband-sim900
int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout){
uint8_t x=0, answer=0;
char response[100];
unsigned long previous;
memset(response, '\0', 100); // Initialice the string
delay(100);
while( Serial.available() > 0) Serial.read(); // Clean the input buffer
Serial.println(ATcommand); // Send the AT command
x = 0;
previous = millis();
// this loop waits for the answer
do{
// if there are data in the UART input buffer, reads it and checks for the asnwer
if(Serial.available() != 0){
response[x] = Serial.read();
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer) != NULL)
{
answer = 1;
}
}
// Waits for the asnwer with time out
}while((answer == 0) && ((millis() - previous) < timeout));
return answer;
}
which
1 .Sends AT commands to SIM900 module
2. Reading the answer
3. Comparing them to the expected answer
4. Return 1 or 0 depending if the answer was correct or wrong.
I would like to modify this function in order to receive the actual responce also .
Something like
return ( 1 or 0 , responce)
or whatever is posible in order to use that responce later in my code.
Can be done ?
Could you please guide me on how to do it ?
Thank you in advance