Bonjour,
Je me casse la ete pour un truc qui doit etre super simple, mais peu etre qu'un caractere me bloque
J'ai cette ligne
sendATcommand("AT+SAPBR=3,1,\"Contype\",\"GPRS\"", "OK", 2000);
sendATcommand("AT+SAPBR=3,1,\"APN\",\"apn\"", "OK", 2000);
sendATcommand("AT+SAPBR=3,1,\"USER\",\"user_name\"", "OK", 2000);
sendATcommand("AT+SAPBR=3,1,\"PWD\",\"password\"", "OK", 2000);
et j'aimerais tout simplement remplacer apn, user_name et password par des varaible de maniere a ce que je puisse tout configurer au debut du script
Mais voila, c'est bete, mais je me casse la tete. Au bebur du script j'ai créé ceci (je prend que l'exemple du "apn" car pour le reste ca se repeterra
const char apn[] = "internet"; // access-point name for GPRS
sendATcommand("AT+SAPBR=3,1,\"APN\",\""+apn+"\"", "OK", 2000);
Ceci me retourne ce message d'erreur
sim908_v5:82: error: invalid operands of types 'const char [21]' and 'const char [9]' to binary 'operator+'
int8_t sendATcommand(char* ATcommand, char* expected_answer1, unsigned int timeout){
uint8_t x=0, answer=0;
char response[100];
unsigned long previous;
memset(response, '\0', 100); // Initialize 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(Serial.available() != 0){
response[x] = Serial.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;
}