We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I use this code with esp32, it works normally, but when used with esp8266, it cannot retrieve data. how to fix issue? thank you.
`#include <AutoConnect.h>
#ifdef ARDUINO_ARCH_ESP8266 #include <ESP8266WiFi.h> #include <ESP8266HTTPClient.h> #include <WiFiClientSecureBearSSL.h> #include <ESP8266WebServer.h> ESP8266WebServer Server; AutoConnect Portal(Server); #else #include <WiFi.h> #include <HTTPClient.h> #include <WebServer.h> WebServer Server; AutoConnect Portal(Server); #endif
void rootPage() { char content[] = "Hello, world"; Server.send(200, "text/plain", content); }
void setup() { Serial.begin(115200); Serial.println(""); Server.on("/", rootPage); if (Portal.begin()) Serial.println("WiFi connected: " + WiFi.localIP().toString()); updateData(); }
void loop() { Portal.handleClient(); }
void updateData() {
String url = "https://www.myweb.com/api/xml/mydata=259874";
#ifdef ARDUINO_ARCH_ESP8266 std::unique_ptrBearSSL::WiFiClientSecureclient(new BearSSL::WiFiClientSecure); client -> setInsecure(); HTTPClient http; http.begin(*client, url); #else HTTPClient http; http.begin(url); #endif
int httpCode = http.GET(); Serial.println(httpCode);
if (httpCode > 0) { String payload = http.getString(); Serial.println(payload); } else { Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); } http.end();
} `
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I use this code with esp32, it works normally, but when used with esp8266, it cannot retrieve data. how to fix issue? thank you.
`#include <AutoConnect.h>
#ifdef ARDUINO_ARCH_ESP8266
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecureBearSSL.h>
#include <ESP8266WebServer.h>
ESP8266WebServer Server;
AutoConnect Portal(Server);
#else
#include <WiFi.h>
#include <HTTPClient.h>
#include <WebServer.h>
WebServer Server;
AutoConnect Portal(Server);
#endif
void rootPage() {
char content[] = "Hello, world";
Server.send(200, "text/plain", content);
}
void setup() {
Serial.begin(115200); Serial.println("");
Server.on("/", rootPage);
if (Portal.begin()) Serial.println("WiFi connected: " + WiFi.localIP().toString());
updateData();
}
void loop() {
Portal.handleClient();
}
void updateData() {
String url = "https://www.myweb.com/api/xml/mydata=259874";
#ifdef ARDUINO_ARCH_ESP8266
std::unique_ptrBearSSL::WiFiClientSecureclient(new BearSSL::WiFiClientSecure);
client -> setInsecure();
HTTPClient http;
http.begin(*client, url);
#else
HTTPClient http;
http.begin(url);
#endif
int httpCode = http.GET();
Serial.println(httpCode);
if (httpCode > 0) {
String payload = http.getString();
Serial.println(payload);
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}
`
The text was updated successfully, but these errors were encountered: