me-no-dev / ESPAsyncUDP

Async UDP library for ESP8266
173 stars 56 forks source link

Wifi client while AsyncUDP ? #11

Closed Stephan35 closed 5 years ago

Stephan35 commented 7 years ago

Hello, I would like to know if it is possible to send TCP request while Udp event ? Best regards

me-no-dev commented 7 years ago

you want to start new client and send something inside the UDP callback? Or will that client be started elsewhere and just send some data in the UDP callback? The second option is possible, the first is not.

Stephan35 commented 7 years ago

What is UDP callback ? is it .onPacket ?

me-no-dev commented 7 years ago

yes

Stephan35 commented 7 years ago

Because i tried to send tcp within onPacket event , and failed . Impossible to send this kind of data :

WiFiClient dweet_client;
      const int httpPort = 80;
      if (!dweet_client.connect(dweet_host, httpPort)) {
        Serial.println("connection failed");
        return false;
      }else{
        Serial.print("connection établie");
            // This will send the request to the server
        dweet_client.print(String("GET /dweet/for/"+DweetID+"?Luminosite=") + DweetAnalRead + "&Cpt_WL_CONNECTED=" + DweetAlive + " HTTP/1.1\r\n" +
                     "Host: " + dweet_host + "\r\n" + 
                     "Connection: close\r\n\r\n");
        Serial.println("|closing connection");
        dweet_client.flush();
      }
      dweet_client.stop();
      return true;
    }

Should i store what i wish to do and launch in loop ?

me-no-dev commented 7 years ago

Yes, since it requires you to connect, you can not do it in the callback.

Stephan35 commented 7 years ago

Ok, very helpfull again ;-) Best regards.

stale[bot] commented 5 years ago

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.