Bonjour,
Mon projet avance...
J'ai cependant une interrogation sur une fonction que j'ai récupérée dans un exemple d'utilisation du shield GSM900.
Cette fonction envoie une commande AT et regarde si dans la réponse, il y a bien la chaîne de caractères recherchée. Elle retourne answer =1 , si c'est le cas.
Je souhaiterais pouvoir également récupérer toute la chaîne de caractères capturée. Il s'agit d'un tableau. Je n'arrive pas à mon résultat.
int8_t answer;
char aux_str[30];
int8_t sendATcommand(char* ATcommand, char* expected_answer1,
unsigned int timeout)
{
uint8_t x=0, answer=0;
char response[100]; // FICHIER 100 car, à diminuer ?
unsigned long previous;
memset(response, '\0', 100); // Initialize the string
delay(100);
while( GPRS.available() > 0) GPRS.read(); // Clean the input buffer
GPRS.println(ATcommand); // Send the AT command
x = 0;
previous = millis();
// this loop waits for the answer
do{
if(GPRS.available() != 0){
response[x] = GPRS.read();
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer1) != NULL)
{
answer = 1;
}
}
// Waits for the asnwer with time out
}while((answer == 0) && ((millis() - previous) < timeout));
return answer;
} // FIN SeentAtcommand
Quelqu'un a t-il une solution ?
Cordialement,