forked from esp8266/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename ESP8266httpClient to ESP8266HTTPClient (part 1)
- Loading branch information
Showing
9 changed files
with
1,035 additions
and
1,035 deletions.
There are no files selected for viewing
136 changes: 68 additions & 68 deletions
136
...mples/BasicHttpClient/BasicHttpClient.ino → ...mples/BasicHttpClient/BasicHttpClient.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,68 @@ | ||
/** | ||
* BasicHttpClient.ino | ||
* | ||
* Created on: 24.05.2015 | ||
* | ||
*/ | ||
|
||
#include <Arduino.h> | ||
|
||
#include <ESP8266WiFi.h> | ||
#include <ESP8266WiFiMulti.h> | ||
|
||
#include <ESP8266httpClient.h> | ||
|
||
#define USE_SERIAL Serial | ||
|
||
ESP8266WiFiMulti WiFiMulti; | ||
|
||
void setup() { | ||
|
||
USE_SERIAL.begin(115200); | ||
// USE_SERIAL.setDebugOutput(true); | ||
|
||
USE_SERIAL.println(); | ||
USE_SERIAL.println(); | ||
USE_SERIAL.println(); | ||
|
||
for(uint8_t t = 4; t > 0; t--) { | ||
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t); | ||
USE_SERIAL.flush(); | ||
delay(1000); | ||
} | ||
|
||
WiFiMulti.addAP("SSID", "PASSWORD"); | ||
|
||
} | ||
|
||
void loop() { | ||
// wait for WiFi connection | ||
if((WiFiMulti.run() == WL_CONNECTED)) { | ||
|
||
httpClient http; | ||
|
||
USE_SERIAL.print("[HTTP] begin...\n"); | ||
// configure traged server and url | ||
//http.begin("192.168.1.12", 443, "/test.html", true, "7a 9c f4 db 40 d3 62 5a 6e 21 bc 5c cc 66 c8 3e a1 45 59 38"); //HTTPS | ||
http.begin("192.168.1.12", 80, "/test.html"); //HTTP | ||
|
||
USE_SERIAL.print("[HTTP] GET...\n"); | ||
// start connection and send HTTP header | ||
int httpCode = http.GET(); | ||
if(httpCode) { | ||
// HTTP header has been send and Server response header has been handled | ||
USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode); | ||
|
||
// file found at server | ||
if(httpCode == 200) { | ||
String payload = http.getString(); | ||
USE_SERIAL.println(payload); | ||
} | ||
} else { | ||
USE_SERIAL.print("[HTTP] GET... failed, no connection or no HTTP server\n"); | ||
} | ||
} | ||
|
||
delay(10000); | ||
} | ||
|
||
/** | ||
* BasicHTTPClient.ino | ||
* | ||
* Created on: 24.05.2015 | ||
* | ||
*/ | ||
|
||
#include <Arduino.h> | ||
|
||
#include <ESP8266WiFi.h> | ||
#include <ESP8266WiFiMulti.h> | ||
|
||
#include <ESP8266HTTPClient.h> | ||
|
||
#define USE_SERIAL Serial | ||
|
||
ESP8266WiFiMulti WiFiMulti; | ||
|
||
void setup() { | ||
|
||
USE_SERIAL.begin(115200); | ||
// USE_SERIAL.setDebugOutput(true); | ||
|
||
USE_SERIAL.println(); | ||
USE_SERIAL.println(); | ||
USE_SERIAL.println(); | ||
|
||
for(uint8_t t = 4; t > 0; t--) { | ||
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t); | ||
USE_SERIAL.flush(); | ||
delay(1000); | ||
} | ||
|
||
WiFiMulti.addAP("SSID", "PASSWORD"); | ||
|
||
} | ||
|
||
void loop() { | ||
// wait for WiFi connection | ||
if((WiFiMulti.run() == WL_CONNECTED)) { | ||
|
||
HTTPClient http; | ||
|
||
USE_SERIAL.print("[HTTP] begin...\n"); | ||
// configure traged server and url | ||
//http.begin("192.168.1.12", 443, "/test.html", true, "7a 9c f4 db 40 d3 62 5a 6e 21 bc 5c cc 66 c8 3e a1 45 59 38"); //HTTPS | ||
http.begin("192.168.1.12", 80, "/test.html"); //HTTP | ||
|
||
USE_SERIAL.print("[HTTP] GET...\n"); | ||
// start connection and send HTTP header | ||
int httpCode = http.GET(); | ||
if(httpCode) { | ||
// HTTP header has been send and Server response header has been handled | ||
USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode); | ||
|
||
// file found at server | ||
if(httpCode == 200) { | ||
String payload = http.getString(); | ||
USE_SERIAL.println(payload); | ||
} | ||
} else { | ||
USE_SERIAL.print("[HTTP] GET... failed, no connection or no HTTP server\n"); | ||
} | ||
} | ||
|
||
delay(10000); | ||
} | ||
|
130 changes: 65 additions & 65 deletions
130
...mples/reuseConnection/reuseConnection.ino → ...ples/ReuseConnection/ReuseConnection.ino1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,65 @@ | ||
/** | ||
* reuseConnection.ino | ||
* | ||
* Created on: 22.11.2015 | ||
* | ||
*/ | ||
|
||
|
||
#include <Arduino.h> | ||
|
||
#include <ESP8266WiFi.h> | ||
#include <ESP8266WiFiMulti.h> | ||
|
||
#include <ESP8266httpClient.h> | ||
|
||
#define USE_SERIAL Serial | ||
|
||
ESP8266WiFiMulti WiFiMulti; | ||
|
||
httpClient http; | ||
|
||
void setup() { | ||
|
||
USE_SERIAL.begin(115200); | ||
// USE_SERIAL.setDebugOutput(true); | ||
|
||
USE_SERIAL.println(); | ||
USE_SERIAL.println(); | ||
USE_SERIAL.println(); | ||
|
||
for(uint8_t t = 4; t > 0; t--) { | ||
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t); | ||
USE_SERIAL.flush(); | ||
delay(1000); | ||
} | ||
|
||
WiFiMulti.addAP("SSID", "PASSWORD"); | ||
|
||
|
||
} | ||
|
||
void loop() { | ||
// wait for WiFi connection | ||
if((WiFiMulti.run() == WL_CONNECTED)) { | ||
|
||
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) { | ||
http.writeToStream(&USE_SERIAL); | ||
} | ||
} else { | ||
USE_SERIAL.print("[HTTP] GET... failed, no connection or no HTTP server\n"); | ||
} | ||
} | ||
|
||
delay(1000); | ||
} | ||
|
||
|
||
|
||
/** | ||
* reuseConnection.ino | ||
* | ||
* Created on: 22.11.2015 | ||
* | ||
*/ | ||
|
||
|
||
#include <Arduino.h> | ||
|
||
#include <ESP8266WiFi.h> | ||
#include <ESP8266WiFiMulti.h> | ||
|
||
#include <ESP8266HTTPClient.h> | ||
|
||
#define USE_SERIAL Serial | ||
|
||
ESP8266WiFiMulti WiFiMulti; | ||
|
||
HTTPClient http; | ||
|
||
void setup() { | ||
|
||
USE_SERIAL.begin(115200); | ||
// USE_SERIAL.setDebugOutput(true); | ||
|
||
USE_SERIAL.println(); | ||
USE_SERIAL.println(); | ||
USE_SERIAL.println(); | ||
|
||
for(uint8_t t = 4; t > 0; t--) { | ||
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t); | ||
USE_SERIAL.flush(); | ||
delay(1000); | ||
} | ||
|
||
WiFiMulti.addAP("SSID", "PASSWORD"); | ||
|
||
|
||
} | ||
|
||
void loop() { | ||
// wait for WiFi connection | ||
if((WiFiMulti.run() == WL_CONNECTED)) { | ||
|
||
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) { | ||
http.writeToStream(&USE_SERIAL); | ||
} | ||
} else { | ||
USE_SERIAL.print("[HTTP] GET... failed, no connection or no HTTP server\n"); | ||
} | ||
} | ||
|
||
delay(1000); | ||
} | ||
|
||
|
||
|
Oops, something went wrong.