Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request POST #1

Closed
ghost opened this issue Apr 25, 2018 · 3 comments
Closed

request POST #1

ghost opened this issue Apr 25, 2018 · 3 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@ghost
Copy link

ghost commented Apr 25, 2018

c'est de la bonne ou pas ? le coup de mettre la requête dans un string est beau jeu

Serial.begin(115200);
while(!Serial){}
WiFiClient client;
const char* host="http://jsonplaceholder.typicode.com/";
String PostData = "title=foo&body=bar&userId=1";

if (client.connect(host, 80)) {

client.println("POST /posts HTTP/1.1");
client.println("Host: jsonplaceholder.typicode.com");
client.println("Cache-Control: no-cache");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(PostData.length());
client.println();
client.println(PostData);

long interval = 2000;
unsigned long currentMillis = millis(), previousMillis = millis();

while(!client.available()){

  if( (currentMillis - previousMillis) > interval ){

    Serial.println("Timeout");
    blinkLed.detach();
    digitalWrite(2, LOW);
    client.stop();     
    return;
  }
  currentMillis = millis();
}

while (client.connected())
{
  if ( client.available() )
  {
    char str=client.read();
   Serial.println(str);
  }      
}

}

Volé sans honte ni remords d'ici

@ghost ghost added enhancement New feature or request question Further information is requested labels Apr 25, 2018
@ghost ghost assigned flavienhaas Apr 25, 2018
@ghost
Copy link
Author

ghost commented Apr 25, 2018

Donc voilà

struct paquet_nRFL01_PA_LNA
{
uint8_t IDp = 0;//0x00
uint8_t IDs = 0;//0x00
uint16_t TS = 0;//0x0000
uint16_t DT = 0;//0x0000
uint16_t D1= 0;//0x0000
uint16_t D2= 0;//0x0000
uint16_t D3= 0;//0x0000
};
typedef struct paquet_nRFL01_PA_LNA Trame;
Trame data;

Penses-tu qu'avec la structure au dessus on peut faire ça ? 🤔 🤔 🤔

string PostData ="ID="+data.IDs+"&IDp="+data.IDp+"&TS="+data.TS+"&DT="+data.DT+"&D1="+data.D1+"&D2="+data.D2+"&D3="+data.D3+"&valider=Valider"
	  
	  client.println("POST /formulaireCollecte.html HTTP/1.1");
		client.println("Host: btslimayrac.ovh");
		client.println("Cache-Control: no-cache");
		client.println("Content-Type: application/x-www-form-urlencoded");
		client.print("Content-Length: ");
		client.println(PostData.length());
		client.println();
		client.println(PostData);

@flavienhaas
Copy link
Owner

flavienhaas commented Apr 25, 2018

c'est la syntaxe de la librairie ethernet normalement ca passe

@ghost
Copy link
Author

ghost commented Apr 25, 2018

nice

@ghost ghost closed this as completed Apr 25, 2018
@flavienhaas flavienhaas changed the title Les requêtes POST mon frrr Les requêtes POST Apr 25, 2018
@flavienhaas flavienhaas changed the title Les requêtes POST request POST Apr 25, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant