Improving memory management to prevent SSL errors

This commit is contained in:
Djuri Baars 2023-10-08 00:17:06 +02:00
parent cc28df888b
commit 37cb13f5f4
6 changed files with 16 additions and 17 deletions

View file

@ -55,7 +55,7 @@ build_flags =
-DLAST_BUILD_TIME=$UNIX_TIME -DLAST_BUILD_TIME=$UNIX_TIME
-D IS_S3 -D IS_S3
-D IS_BW -D IS_BW
-D CONFIG_FREERTOS_USE_TRACE_FACILITY # -D CONFIG_FREERTOS_USE_TRACE_FACILITY
-D WITH_RGB_LED -D WITH_RGB_LED
-D NEOPIXEL_COUNT=4 -D NEOPIXEL_COUNT=4
-DASYNCWEBSERVER_REGEX -DASYNCWEBSERVER_REGEX

View file

@ -41,13 +41,13 @@ extern Adafruit_NeoPixel pixels;
#endif #endif
extern std::map<int, std::string> screenNameMap; extern std::map<int, std::string> screenNameMap;
const int SCREEN_BLOCK_HEIGHT = 0; const PROGMEM int SCREEN_BLOCK_HEIGHT = 0;
const int SCREEN_MSCW_TIME = 1; const PROGMEM int SCREEN_MSCW_TIME = 1;
const int SCREEN_BTC_TICKER = 2; const PROGMEM int SCREEN_BTC_TICKER = 2;
const int SCREEN_TIME = 3; const PROGMEM int SCREEN_TIME = 3;
const int SCREEN_HALVING_COUNTDOWN = 4; const PROGMEM int SCREEN_HALVING_COUNTDOWN = 4;
const int SCREEN_COUNTDOWN = 98; const PROGMEM int SCREEN_COUNTDOWN = 98;
const int SCREEN_CUSTOM = 99; const PROGMEM int SCREEN_CUSTOM = 99;
const int screens[5] = { SCREEN_BLOCK_HEIGHT, SCREEN_MSCW_TIME, SCREEN_BTC_TICKER, SCREEN_TIME, SCREEN_HALVING_COUNTDOWN }; const PROGMEM int screens[5] = { SCREEN_BLOCK_HEIGHT, SCREEN_MSCW_TIME, SCREEN_BTC_TICKER, SCREEN_TIME, SCREEN_HALVING_COUNTDOWN };
const uint screenCount = sizeof(screens) / sizeof(int); const uint screenCount = sizeof(screens) / sizeof(int);

View file

@ -37,8 +37,7 @@ void checkBitcoinBlock(void *pvParameters)
http.addHeader("User-Agent", "BTClock/1.0"); http.addHeader("User-Agent", "BTClock/1.0");
String payload = "{\"jsonrpc\":\"1.0\",\"id\":\"current_block_height\",\"method\":\"getblockcount\",\"params\":[]}"; String payload = "{\"jsonrpc\":\"1.0\",\"id\":\"current_block_height\",\"method\":\"getblockcount\",\"params\":[]}";
String auth = preferences.getString("rpcUser", BITCOIND_RPC_USER) + ":" + preferences.getString("rpcPass", BITCOIND_RPC_PASS); String authEncoded = base64::encode(preferences.getString("rpcUser", BITCOIND_RPC_USER) + ":" + preferences.getString("rpcPass", BITCOIND_RPC_PASS));
String authEncoded = base64::encode(auth);
http.addHeader("Authorization", "Basic " + authEncoded); http.addHeader("Authorization", "Basic " + authEncoded);
int httpCode = http.POST(payload); int httpCode = http.POST(payload);
@ -68,7 +67,8 @@ void checkBitcoinBlock(void *pvParameters)
} }
else else
{ {
Serial.println("Error in HTTP request to mempool API"); Serial.print(F("Error in HTTP request to mempool API: "));
Serial.println(http.errorToString(httpCode));
} }
http.end(); http.end();

View file

@ -217,7 +217,6 @@ void taskEpd(void *pvParameters)
if (updatedThisCycle && preferences.getBool("ledFlashOnUpd", false)) if (updatedThisCycle && preferences.getBool("ledFlashOnUpd", false))
{ {
xTaskNotifyGive(ledHandlerTaskHandle); xTaskNotifyGive(ledHandlerTaskHandle);
Serial.println("Flash leds");
} }
#endif #endif

View file

@ -1,6 +1,6 @@
#include "get_price.hpp" #include "get_price.hpp"
const char *apiUrl = "https://api.coindesk.com/v1/bpi/currentprice/USD.json"; const PROGMEM char *apiUrl = "https://api.coindesk.com/v1/bpi/currentprice/USD.json";
std::vector<EventCallbackWithNumber> priceEventCallbacks; // Define a vector to hold multiple event callbacks std::vector<EventCallbackWithNumber> priceEventCallbacks; // Define a vector to hold multiple event callbacks
TaskHandle_t getPriceTaskHandle; TaskHandle_t getPriceTaskHandle;
@ -41,7 +41,7 @@ void taskGetPrice(void *pvParameters)
} }
else else
{ {
Serial.print("Error retrieving BTC/USD price. HTTP status code: "); Serial.print(F("Error retrieving BTC/USD price. HTTP status code: "));
Serial.println(httpCode); Serial.println(httpCode);
} }

View file

@ -5,8 +5,8 @@ TaskHandle_t ledHandlerTaskHandle = NULL;
void ledHandlerTask(void *parameter) void ledHandlerTask(void *parameter)
{ {
int dir = 5; const int dir = 5;
int bright = 0; const int bright = 0;
while (1) while (1)
{ {
ulTaskNotifyTake(pdTRUE, portMAX_DELAY); ulTaskNotifyTake(pdTRUE, portMAX_DELAY);