Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

How to use the async client? #18

Closed
@x-labz

Description

@x-labz

My current code, which actually not works....

AsyncClient async_client;

.
.
.

String req ;
int8_t connected = async_client.connected();
Serial.print("connected: ");
Serial.println(connected) ;

  if (!connected  ) {
    Serial.println("connecting..") ;
    async_client.connect("192.168.0.17", 80);
  }
  else {
    String req = "POST /data HTTP/1.1 \nHost: " ;
    req += config_data.host_ip ;
    req += "/data" ;
    req += "\nCache-Control: no-cache \nContent-Type: application/json \nContent-Length: ";
    req += payload.length() ;
    req += "\nAccept: */*\n";
    req += payload.c_str() ;

    Serial.println(req);

    if ( async_client.canSend()) {
      async_client.add(req.c_str(), req.length() );
      bool sent = async_client.send();
      async_client.close();
      Serial.print("sent...") ;
      Serial.println(sent) ;
    }
  }

What is missing? How to make it work? HEEEELP PLEEASE!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions