Pouknouki

Sauvegarde GET

Mar 17th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1.   if (client.connect(notificationHost.c_str(), notificationPort))
  2.   {
  3.     client.print("GET /update?simple=true&color=");
  4.     client.print(color);
  5.     client.println(" HTTP/1.1");
  6.     client.print("Host: ");
  7.     client.println(notificationHost.c_str());
  8.     client.println("Connection: close");
  9.     client.println();
  10.   }
  11.   else
  12.   {
  13.     Serial.println("[E] Couldn't notify... Trying again.");
  14.     return notifyPartner();
  15.   }
  16.  
  17.   int initialTime = millis();
  18.   int finalTime = millis();
  19.  
  20.   while (!client.available() && (finalTime - initialTime) < _NOTIFICATION_READ_TIMEOUT)
  21.     finalTime = millis();
  22.  
  23.   if ((finalTime - initialTime) >= _NOTIFICATION_READ_TIMEOUT)
  24.   {
  25.     Serial.println("[E] No response from the partner.");
  26.     ledOff();
  27.     return;
  28.   }
  29.  
  30.   String line = client.readStringUntil('|');
  31.  
  32.   while (!client.available()) {}
  33.  
  34.   line = client.readStringUntil('|');
  35.   Serial.println(line);
  36.  
  37.   client.stop();
Advertisement
Add Comment
Please, Sign In to add comment