Salut,
Voici le problème que je n'arrive pas à résoudre:
J'ai deux Arduino.
L'un est un ESP8266 et génère un point d'accès.
L'autre est un ESP32 qui doit envoyer une donnée (string) à ce point d'accès.
(tout ça via WiFi
Le point d'accès fonctionne bien et est bien détecté par l'ESP32
La donnée est une chaine de caractères de max 256 caractères ascii.
Il faut donc un bout de code sur le point d'accès pour récupérer cette donnée.
Il faut par ailleurs un code (POST?) sur l'ESP32 pour envoyer cette donnée au point d'accès.
J'ai tenté des GET et POST, mais je tourne en rond.
Voici mon dernier bout de code dans le point d'accès:
*void loop()*
*{*
*server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {*
* request->send(200, "text/plain", Str_to_DELTA);*
* });*
* delay(2000);*
* Serial.println(Str_to_DELTA); // je n'ai pas de réponse :-(*
*delay(1000);*
*}*
Et mon dernier bout de code pour l'ESP32:
*...*
*String PostData = "someDataToPost";*
*...*
*cycle=0;*
*WiFi.begin(ssid, password);*
* while ((WiFi.status() != WL_CONNECTED) and (cycle<10)) {*
* delay(500);*
* Serial.print("#");*
* cycle = cycle +1;*
* Serial.println("cycle: "+String(cycle));*
* }*
* Serial.println();*
* Serial.print("Connected, IP address: ");*
* Serial.println(WiFi.localIP()); // ok*
* if ((WiFi.status() == WL_CONNECTED)) {*
* Serial.println("connected"); // ok*
*if (client.connect(server, 80)){*
* Serial.println("client connected"); // ok*
* client.println("POST /Str_to_DELTA HTTP/1.1"); // Str_to_Delta est la, variable sur le point d'accès*
* client.println("Host: PhL-Soft");*
* client.println("User-Agent: Arduino/1.0");*
* client.println("Connection: close");*
* client.print("Content-Length: ");*
* client.println(PostData.length());*
* client.println();*
* client.println(PostData);*
* Serial.println("correctly send"); // ok*
* } else Serial.println("For POST, client not connected");*
* if (client.connected()) {*
* client.stop();*
* WiFi.disconnect();*
* }*
* Serial.println(Str_to_DELTA);*
* }*
Je reçois bien "correctly send" donc passe bien dans la boucle.
Je n'arrive pas à voir comprendre si le problème est dans l'un ou l'autre code
Merci pour vos pistes