kopia lustrzana https://github.com/alanesq/esp32cam-demo
Add files via upload
rodzic
69427ebf77
commit
6d5e2989b7
|
@ -35,6 +35,7 @@
|
||||||
#include "esp_camera.h" // https://github.com/espressif/esp32-camera
|
#include "esp_camera.h" // https://github.com/espressif/esp32-camera
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <WebServer.h>
|
#include <WebServer.h>
|
||||||
|
#include <HTTPClient.h> // used by requestWebPage()
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
|
@ -892,6 +893,37 @@ void handleStream(){
|
||||||
} // handleStream
|
} // handleStream
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
// -request a web page (wifi client)
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
// usage example: String q = requestWebPage("http://192.168.1.176:80/index.htm");
|
||||||
|
// original code from: https://techtutorialsx.com/2017/05/19/esp32-http-get-requests/
|
||||||
|
|
||||||
|
String requestWebPage(String urlRequested) {
|
||||||
|
|
||||||
|
if ((WiFi.status() != WL_CONNECTED)) return "ERROR: Network not connected";
|
||||||
|
|
||||||
|
HTTPClient http;
|
||||||
|
String payload;
|
||||||
|
|
||||||
|
http.begin(urlRequested); //Specify the URL
|
||||||
|
int httpCode = http.GET(); //Make the request
|
||||||
|
|
||||||
|
if (httpCode > 0) { //Check for the returning code
|
||||||
|
payload = http.getString();
|
||||||
|
if (debugInfo) Serial.println(httpCode);
|
||||||
|
if (debugInfo) Serial.println(payload);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Serial.println("Error on HTTP request");
|
||||||
|
}
|
||||||
|
|
||||||
|
http.end(); //Free the resources
|
||||||
|
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ******************************************************************************************************************
|
// ******************************************************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
@ -913,8 +945,6 @@ void handleTest() {
|
||||||
client.write("<!DOCTYPE html> <html lang='en'> <head> <title>photo</title> </head> <body>\n"); // basic html header
|
client.write("<!DOCTYPE html> <html lang='en'> <head> <title>photo</title> </head> <body>\n"); // basic html header
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// html body
|
// html body
|
||||||
client.print("<h1>Test Page</h1>\n");
|
client.print("<h1>Test Page</h1>\n");
|
||||||
|
|
||||||
|
@ -925,6 +955,9 @@ void handleTest() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// end html
|
// end html
|
||||||
client.write("</body></html>\n");
|
client.write("</body></html>\n");
|
||||||
delay(3);
|
delay(3);
|
||||||
|
|
Ładowanie…
Reference in New Issue