1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

rework HTTPclient examples

This commit is contained in:
Markus Sattler
2015-12-09 12:56:49 +01:00
parent e15c745e6f
commit 1dabac60a9
3 changed files with 22 additions and 10 deletions

View File

@ -36,26 +36,31 @@ void setup() {
WiFiMulti.addAP("SSID", "PASSWORD");
// allow reuse (if server supports it)
http.setReuse(true);
}
void loop() {
// wait for WiFi connection
if((WiFiMulti.run() == WL_CONNECTED)) {
http.begin("192.168.1.12", 80, "/test.html");
http.begin("http://192.168.1.12/test.html");
//http.begin("192.168.1.12", 80, "/test.html");
int httpCode = http.GET();
if(httpCode) {
USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);
// file found at server
if(httpCode == 200) {
if(httpCode == HTTP_CODE_OK) {
http.writeToStream(&USE_SERIAL);
}
} else {
USE_SERIAL.print("[HTTP] GET... failed, no connection or no HTTP server\n");
}
http.end();
}
delay(1000);