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
-D IS_S3
-D IS_BW
-D CONFIG_FREERTOS_USE_TRACE_FACILITY
# -D CONFIG_FREERTOS_USE_TRACE_FACILITY
-D WITH_RGB_LED
-D NEOPIXEL_COUNT=4
-DASYNCWEBSERVER_REGEX

View file

@ -41,13 +41,13 @@ extern Adafruit_NeoPixel pixels;
#endif
extern std::map<int, std::string> screenNameMap;
const int SCREEN_BLOCK_HEIGHT = 0;
const int SCREEN_MSCW_TIME = 1;
const int SCREEN_BTC_TICKER = 2;
const int SCREEN_TIME = 3;
const int SCREEN_HALVING_COUNTDOWN = 4;
const int SCREEN_COUNTDOWN = 98;
const 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 SCREEN_BLOCK_HEIGHT = 0;
const PROGMEM int SCREEN_MSCW_TIME = 1;
const PROGMEM int SCREEN_BTC_TICKER = 2;
const PROGMEM int SCREEN_TIME = 3;
const PROGMEM int SCREEN_HALVING_COUNTDOWN = 4;
const PROGMEM int SCREEN_COUNTDOWN = 98;
const PROGMEM int SCREEN_CUSTOM = 99;
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);

View file

@ -37,8 +37,7 @@ void checkBitcoinBlock(void *pvParameters)
http.addHeader("User-Agent", "BTClock/1.0");
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(auth);
String authEncoded = base64::encode(preferences.getString("rpcUser", BITCOIND_RPC_USER) + ":" + preferences.getString("rpcPass", BITCOIND_RPC_PASS));
http.addHeader("Authorization", "Basic " + authEncoded);
int httpCode = http.POST(payload);
@ -68,7 +67,8 @@ void checkBitcoinBlock(void *pvParameters)
}
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();

View file

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

View file

@ -1,6 +1,6 @@
#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
TaskHandle_t getPriceTaskHandle;
@ -41,7 +41,7 @@ void taskGetPrice(void *pvParameters)
}
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);
}

View file

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