From fa6bf6fd6a2e264638938f099210ef5c0a1a7725 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Fri, 13 Feb 2026 20:29:18 -0800 Subject: [PATCH] snapshot --- doorbell-touch.ino | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doorbell-touch.ino b/doorbell-touch.ino index abfea3f..c3bbc40 100644 --- a/doorbell-touch.ino +++ b/doorbell-touch.ino @@ -374,7 +374,6 @@ void flushStatus() { statusHttp.end(); Serial.printf("[STATUS] Sent (%d): %s\n", code, pendingStatusState.c_str()); - pendingStatusState = ""; pendingStatusMsg = ""; } @@ -490,6 +489,8 @@ void checkNetwork() { Serial.flush(); } +#include + void pollTopic(const char *url, void (*handler)(const String&), const char *topicName, @@ -501,17 +502,20 @@ void pollTopic(const char *url, HTTPClient http; http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); http.setTimeout(10000); - http.begin(client, url); + + if (!http.begin(client, url)) { + Serial.printf("[%s] begin() failed\n", topicName); + return; + } 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 %d\n", topicName, code); } 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(); }