snapshot
This commit is contained in:
@@ -374,7 +374,6 @@ void flushStatus() {
|
|||||||
statusHttp.end();
|
statusHttp.end();
|
||||||
|
|
||||||
Serial.printf("[STATUS] Sent (%d): %s\n", code, pendingStatusState.c_str());
|
Serial.printf("[STATUS] Sent (%d): %s\n", code, pendingStatusState.c_str());
|
||||||
|
|
||||||
pendingStatusState = "";
|
pendingStatusState = "";
|
||||||
pendingStatusMsg = "";
|
pendingStatusMsg = "";
|
||||||
}
|
}
|
||||||
@@ -490,6 +489,8 @@ void checkNetwork() {
|
|||||||
Serial.flush();
|
Serial.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <WiFiClientSecure.h>
|
||||||
|
|
||||||
void pollTopic(const char *url,
|
void pollTopic(const char *url,
|
||||||
void (*handler)(const String&),
|
void (*handler)(const String&),
|
||||||
const char *topicName,
|
const char *topicName,
|
||||||
@@ -501,17 +502,20 @@ void pollTopic(const char *url,
|
|||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||||
http.setTimeout(10000);
|
http.setTimeout(10000);
|
||||||
http.begin(client, url);
|
|
||||||
|
if (!http.begin(client, url)) {
|
||||||
|
Serial.printf("[%s] begin() failed\n", topicName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int code = http.GET();
|
int code = http.GET();
|
||||||
if (code == HTTP_CODE_OK) {
|
if (code == HTTP_CODE_OK) {
|
||||||
String response = http.getString();
|
String response = http.getString();
|
||||||
if (response.length() > 0)
|
if (response.length() > 0)
|
||||||
parseMessages(response, topicName, handler, lastId);
|
parseMessages(response, topicName, handler, lastId);
|
||||||
} else if (code > 0) {
|
|
||||||
Serial.printf("[%s] HTTP %d\n", topicName, code);
|
|
||||||
} else {
|
} else {
|
||||||
Serial.printf("[%s] Error: %s\n", topicName, http.errorToString(code).c_str());
|
Serial.printf("[%s] HTTP %d: %s\n", topicName, code,
|
||||||
|
code < 0 ? http.errorToString(code).c_str() : "");
|
||||||
}
|
}
|
||||||
http.end();
|
http.end();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user