snapshot
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <NTPClient.h>
|
||||
#include <WiFiUdp.h>
|
||||
#include <Arduino_GFX_Library.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
|
||||
// =====================================================================
|
||||
// DEBUG MODE — set to true to use _test topic suffix
|
||||
@@ -225,7 +226,7 @@ bool pendingStatus = false;
|
||||
String pendingStatusState = "";
|
||||
String pendingStatusMsg = "";
|
||||
|
||||
HTTPClient http;
|
||||
// HTTPClient http;
|
||||
|
||||
// =====================================================================
|
||||
// Drawing Helpers
|
||||
@@ -362,15 +363,17 @@ void flushStatus() {
|
||||
String payload;
|
||||
serializeJson(doc, payload);
|
||||
|
||||
WiFiClientSecure client;
|
||||
client.setInsecure();
|
||||
|
||||
HTTPClient statusHttp;
|
||||
statusHttp.begin(STATUS_URL);
|
||||
statusHttp.begin(client, STATUS_URL);
|
||||
statusHttp.addHeader("Content-Type", "application/json");
|
||||
int code = statusHttp.POST(payload);
|
||||
statusHttp.end();
|
||||
|
||||
Serial.printf("[STATUS] Sent (%d): %s\n", code, pendingStatusState.c_str());
|
||||
|
||||
// Free memory immediately
|
||||
pendingStatusState = "";
|
||||
pendingStatusMsg = "";
|
||||
}
|
||||
@@ -438,24 +441,31 @@ void parseMessages(String &response, const char *topicName,
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// ntfy Polling
|
||||
// ntfy Polling — with TLS support
|
||||
// =====================================================================
|
||||
#include <WiFiClientSecure.h>
|
||||
|
||||
void pollTopic(const char *url,
|
||||
void (*handler)(const String&),
|
||||
const char *topicName,
|
||||
String &lastId)
|
||||
{
|
||||
http.begin(url);
|
||||
WiFiClientSecure client;
|
||||
client.setInsecure(); // skip cert verification for ntfy.sh
|
||||
|
||||
HTTPClient http;
|
||||
http.begin(client, url);
|
||||
http.setTimeout(10000);
|
||||
int code = http.GET();
|
||||
if (code == HTTP_CODE_OK) {
|
||||
String response = http.getString();
|
||||
if (response.length() > 0)
|
||||
parseMessages(response, topicName, handler, lastId);
|
||||
} else if (code < 0) {
|
||||
Serial.printf("[%s] HTTP error: %s\n", topicName, http.errorToString(code).c_str());
|
||||
}
|
||||
http.end();
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// Message Handlers
|
||||
// =====================================================================
|
||||
@@ -680,8 +690,10 @@ void loop() {
|
||||
String cmd = Serial.readStringUntil('\n');
|
||||
cmd.trim();
|
||||
if (cmd == "CLEAR_DEDUP") {
|
||||
lastProcessedId = "";
|
||||
Serial.println("[CMD] Dedup cleared");
|
||||
lastAlertId = "";
|
||||
lastSilenceId = "";
|
||||
lastAdminId = "";
|
||||
Serial.println("[CMD] Dedup cleared (all topics)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user