From aa6c09e9aa0a15a0bc24c9a98a1d867932b23e02 Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Sat, 4 Nov 2023 21:24:15 +0100 Subject: [PATCH] Reconnect WiFi on error --- src/tasks/blocknotify.cpp | 3 +++ src/tasks/get_price.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/tasks/blocknotify.cpp b/src/tasks/blocknotify.cpp index 4614b85..dd5c042 100644 --- a/src/tasks/blocknotify.cpp +++ b/src/tasks/blocknotify.cpp @@ -82,6 +82,9 @@ void checkBitcoinBlock(void *pvParameters) Serial.print(F("Error in HTTP request to mempool API: ")); Serial.print(httpCode); Serial.println(http->errorToString(httpCode)); + if (httpCode == -1) { + WiFi.reconnect(); + } } http->end(); diff --git a/src/tasks/get_price.cpp b/src/tasks/get_price.cpp index 86eb4fa..10aae6c 100644 --- a/src/tasks/get_price.cpp +++ b/src/tasks/get_price.cpp @@ -56,6 +56,9 @@ void taskGetPrice(void *pvParameters) { Serial.print(F("Error retrieving BTC/USD price (CoinGecko). HTTP status code: ")); Serial.println(httpCode); + if (httpCode == -1) { + WiFi.reconnect(); + } } } else { @@ -86,6 +89,9 @@ void taskGetPrice(void *pvParameters) { Serial.print(F("Error retrieving BTC/USD price (CoinDesk). HTTP status code: ")); Serial.println(httpCode); + if (httpCode == -1) { + WiFi.reconnect(); + } } }