Compare commits
No commits in common. "main" and "feature/mining_pool_logo_download" have entirely different histories.
main
...
feature/mi
9 changed files with 209 additions and 191 deletions
12
README.md
12
README.md
|
@ -16,21 +16,21 @@ Biggest differences with v2 are:
|
||||||
|
|
||||||
New features:
|
New features:
|
||||||
- BitAxe integration
|
- BitAxe integration
|
||||||
- Nostr Zap notifier
|
- Zap notifier
|
||||||
- Multiple mining pool stats integrations
|
- Braiins Pool and Ocean mining stats integration
|
||||||
|
|
||||||
"Steal focus on new block" means that when a new block is mined, the display will switch to the block height screen if it's not on it already.
|
"Steal focus on new block" means that when a new block is mined, the display will switch to the block height screen if it's not on it already.
|
||||||
|
|
||||||
See the [docs](https://git.btclock.dev/btclock/docs) repo for more information and building instructions.
|
Most [information](https://github.com/btclock/btclock_v2/wiki) about BTClock v2 is still valid for this version.
|
||||||
|
|
||||||
**NOTE**: The software assumes that the hardware is run in a controlled private network. ~~The Web UI and the OTA update mechanism are not password protected and accessible to anyone in the network. Also, since the device only fetches numbers through WebSockets it will skip server certificate verification to save resources.~~ Since 3.2.0 the WebUI is password protectable and all certificates are verified. OTA update mechanism is not password-protected.
|
**NOTE**: The software assumes that the hardware is run in a controlled private network. ~~The Web UI and the OTA update mechanism are not password protected and accessible to anyone in the network. Also, since the device only fetches numbers through WebSockets it will skip server certificate verification to save resources.~~ Since 3.2.0 the WebUI is password protectable and all certificates are verified. OTA update mechanism is not password-protected.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
Use PlatformIO to build it yourself. Make sure you fetch the [WebUI](https://git.btclock.dev/btclock/webui) submodule.
|
Use PlatformIO to build it yourself. Make sure you fetch the [WebUI](https://github.com/btclock/webui) submodule.
|
||||||
|
|
||||||
|
|
||||||
## Mining pool stats
|
## Braiins Pool and Ocean integration
|
||||||
Enable mining pool stats by accessing your btclock's web UI (point a web browser at the device's IP address).
|
Enable mining pool stats by accessing your btclock's web UI (point a web browser at the device's IP address).
|
||||||
|
|
||||||
Under Settings -> Extra Features: toggle Enable Mining Pool Stats.
|
Under Settings -> Extra Features: toggle Enable Mining Pool Stats.
|
||||||
|
@ -41,8 +41,6 @@ The Mining Pool Earnings screen displays:
|
||||||
* Braiins: Today's mining reward thus far
|
* Braiins: Today's mining reward thus far
|
||||||
* Ocean: Your estimated earnings if the pool were to find a block right now
|
* Ocean: Your estimated earnings if the pool were to find a block right now
|
||||||
|
|
||||||
For solo mining pools, there are no earning estimations. Your username is the onchain withdrawal address, without the worker name.
|
|
||||||
|
|
||||||
|
|
||||||
### Braiins Pool integration
|
### Braiins Pool integration
|
||||||
Create an API key based on the steps [here](https://academy.braiins.com/en/braiins-pool/monitoring/#api-configuration).
|
Create an API key based on the steps [here](https://academy.braiins.com/en/braiins-pool/monitoring/#api-configuration).
|
||||||
|
|
|
@ -54,7 +54,7 @@ void taskBitaxeFetch(void *pvParameters)
|
||||||
|
|
||||||
void setupBitaxeFetchTask()
|
void setupBitaxeFetchTask()
|
||||||
{
|
{
|
||||||
xTaskCreate(taskBitaxeFetch, "bitaxeFetch", (3 * 1024), NULL, tskIDLE_PRIORITY,
|
xTaskCreate(taskBitaxeFetch, "bitaxeFetch", (6 * 1024), NULL, tskIDLE_PRIORITY,
|
||||||
&bitaxeFetchTaskHandle);
|
&bitaxeFetchTaskHandle);
|
||||||
|
|
||||||
xTaskNotifyGive(bitaxeFetchTaskHandle);
|
xTaskNotifyGive(bitaxeFetchTaskHandle);
|
||||||
|
|
|
@ -19,50 +19,39 @@ TickType_t lastDebounceTime = 0;
|
||||||
void buttonTask(void *parameter) {
|
void buttonTask(void *parameter) {
|
||||||
while (1) {
|
while (1) {
|
||||||
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
||||||
|
std::lock_guard<std::mutex> lock(mcpMutex);
|
||||||
|
|
||||||
TickType_t currentTime = xTaskGetTickCount();
|
TickType_t currentTime = xTaskGetTickCount();
|
||||||
|
|
||||||
if ((currentTime - lastDebounceTime) >= debounceDelay) {
|
if ((currentTime - lastDebounceTime) >= debounceDelay) {
|
||||||
lastDebounceTime = currentTime;
|
lastDebounceTime = currentTime;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(mcpMutex);
|
|
||||||
|
|
||||||
if (!digitalRead(MCP_INT_PIN)) {
|
if (!digitalRead(MCP_INT_PIN)) {
|
||||||
uint16_t intFlags = mcp1.getInterruptFlagRegister();
|
uint pin = mcp1.getInterruptFlagRegister();
|
||||||
uint16_t intCap = mcp1.getInterruptCaptureRegister();
|
|
||||||
|
|
||||||
// Check each button individually
|
switch (pin) {
|
||||||
if (intFlags & BTN_1) handleButton1();
|
case BTN_1:
|
||||||
if (intFlags & BTN_2) handleButton2();
|
|
||||||
if (intFlags & BTN_3) handleButton3();
|
|
||||||
if (intFlags & BTN_4) handleButton4();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear interrupt state
|
|
||||||
while (!digitalRead(MCP_INT_PIN)) {
|
|
||||||
std::lock_guard<std::mutex> lock(mcpMutex);
|
|
||||||
mcp1.getInterruptCaptureRegister();
|
|
||||||
delay(1); // Small delay to prevent tight loop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper functions to handle each button
|
|
||||||
void handleButton1() {
|
|
||||||
toggleTimerActive();
|
toggleTimerActive();
|
||||||
}
|
break;
|
||||||
|
case BTN_2:
|
||||||
void handleButton2() {
|
|
||||||
nextScreen();
|
nextScreen();
|
||||||
}
|
break;
|
||||||
|
case BTN_3:
|
||||||
void handleButton3() {
|
|
||||||
previousScreen();
|
previousScreen();
|
||||||
}
|
break;
|
||||||
|
case BTN_4:
|
||||||
void handleButton4() {
|
|
||||||
showSystemStatusScreen();
|
showSystemStatusScreen();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mcp1.getInterruptCaptureRegister();
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
// Very ugly, but for some reason this is necessary
|
||||||
|
while (!digitalRead(MCP_INT_PIN)) {
|
||||||
|
mcp1.getInterruptCaptureRegister();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR handleButtonInterrupt() {
|
void IRAM_ATTR handleButtonInterrupt() {
|
||||||
|
|
|
@ -8,13 +8,6 @@
|
||||||
|
|
||||||
extern TaskHandle_t buttonTaskHandle;
|
extern TaskHandle_t buttonTaskHandle;
|
||||||
|
|
||||||
// Task and setup functions
|
|
||||||
void buttonTask(void *pvParameters);
|
void buttonTask(void *pvParameters);
|
||||||
void IRAM_ATTR handleButtonInterrupt();
|
void IRAM_ATTR handleButtonInterrupt();
|
||||||
void setupButtonTask();
|
void setupButtonTask();
|
||||||
|
|
||||||
// Individual button handlers
|
|
||||||
void handleButton1();
|
|
||||||
void handleButton2();
|
|
||||||
void handleButton3();
|
|
||||||
void handleButton4();
|
|
||||||
|
|
|
@ -466,34 +466,32 @@ void setupHardware()
|
||||||
|
|
||||||
Wire.begin(I2C_SDA_PIN, I2C_SCK_PIN, 400000);
|
Wire.begin(I2C_SDA_PIN, I2C_SCK_PIN, 400000);
|
||||||
|
|
||||||
if (!mcp1.begin()) {
|
if (!mcp1.begin())
|
||||||
|
{
|
||||||
Serial.println(F("Error MCP23017 1"));
|
Serial.println(F("Error MCP23017 1"));
|
||||||
} else {
|
|
||||||
|
// while (1)
|
||||||
|
// ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pinMode(MCP_INT_PIN, INPUT_PULLUP);
|
pinMode(MCP_INT_PIN, INPUT_PULLUP);
|
||||||
|
// mcp1.setupInterrupts(false, false, LOW);
|
||||||
|
mcp1.enableControlRegister(MCP23x17_IOCR_ODR);
|
||||||
|
|
||||||
// Enable mirrored interrupts (both INTA and INTB pins signal any interrupt)
|
mcp1.mirrorInterrupts(true);
|
||||||
if (!mcp1.mirrorInterrupts(true)) {
|
|
||||||
Serial.println(F("Error setting up mirrored interrupts"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure all 4 button pins as inputs with pullups and interrupts
|
for (int i = 0; i < 4; i++)
|
||||||
for (int i = 0; i < 4; i++) {
|
{
|
||||||
if (!mcp1.pinMode1(i, INPUT_PULLUP)) {
|
mcp1.pinMode1(i, INPUT_PULLUP);
|
||||||
Serial.printf("Error setting pin %d to input pull up\n", i);
|
mcp1.enableInterrupt(i, LOW);
|
||||||
}
|
}
|
||||||
// Enable interrupt on CHANGE for each pin
|
#ifndef IS_BTCLOCK_V8
|
||||||
if (!mcp1.enableInterrupt(i, CHANGE)) {
|
for (int i = 8; i <= 14; i++)
|
||||||
Serial.printf("Error enabling interrupt for pin %d\n", i);
|
{
|
||||||
|
mcp1.pinMode1(i, OUTPUT);
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
// Set interrupt pins as open drain with active-low polarity
|
|
||||||
if (!mcp1.setInterruptPolarity(2)) { // 2 = Open drain
|
|
||||||
Serial.println(F("Error setting interrupt polarity"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear any pending interrupts
|
|
||||||
mcp1.getInterruptCaptureRegister();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IS_HW_REV_B
|
#ifdef IS_HW_REV_B
|
||||||
|
|
|
@ -149,6 +149,25 @@ void forceFullRefresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void refreshFromMemory()
|
||||||
|
{
|
||||||
|
for (uint i = 0; i < NUM_SCREENS; i++)
|
||||||
|
{
|
||||||
|
int *taskParam = new int;
|
||||||
|
*taskParam = i;
|
||||||
|
|
||||||
|
xTaskCreate(
|
||||||
|
[](void *pvParameters)
|
||||||
|
{
|
||||||
|
const int epdIndex = *(int *)pvParameters;
|
||||||
|
delete (int *)pvParameters;
|
||||||
|
displays[epdIndex].refresh(false);
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
},
|
||||||
|
"PrepareUpd", 4096, taskParam, tskIDLE_PRIORITY, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setupDisplays()
|
void setupDisplays()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lockMcp(mcpMutex);
|
std::lock_guard<std::mutex> lockMcp(mcpMutex);
|
||||||
|
|
|
@ -26,6 +26,7 @@ typedef struct {
|
||||||
} UpdateDisplayTaskItem;
|
} UpdateDisplayTaskItem;
|
||||||
|
|
||||||
void forceFullRefresh();
|
void forceFullRefresh();
|
||||||
|
void refreshFromMemory();
|
||||||
void setupDisplays();
|
void setupDisplays();
|
||||||
|
|
||||||
void splitText(const uint dispNum, const String &top, const String &bottom,
|
void splitText(const uint dispNum, const String &top, const String &bottom,
|
||||||
|
|
|
@ -93,7 +93,7 @@ void setupMiningPoolStatsFetchTask()
|
||||||
"logoDownload",
|
"logoDownload",
|
||||||
(6 * 1024),
|
(6 * 1024),
|
||||||
NULL,
|
NULL,
|
||||||
tskIDLE_PRIORITY,
|
12,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
xTaskCreate(taskMiningPoolStatsFetch,
|
xTaskCreate(taskMiningPoolStatsFetch,
|
||||||
|
|
192
src/main.cpp
192
src/main.cpp
|
@ -22,132 +22,152 @@
|
||||||
uint wifiLostConnection;
|
uint wifiLostConnection;
|
||||||
uint priceNotifyLostConnection = 0;
|
uint priceNotifyLostConnection = 0;
|
||||||
uint blockNotifyLostConnection = 0;
|
uint blockNotifyLostConnection = 0;
|
||||||
|
// char ptrTaskList[1500];
|
||||||
|
|
||||||
int64_t getUptime() {
|
extern "C" void app_main()
|
||||||
return esp_timer_get_time() / 1000000;
|
{
|
||||||
}
|
initArduino();
|
||||||
|
|
||||||
void handlePriceNotifyDisconnection() {
|
Serial.begin(115200);
|
||||||
if (priceNotifyLostConnection == 0) {
|
setup();
|
||||||
priceNotifyLostConnection = getUptime();
|
|
||||||
Serial.println(F("Lost price notification connection, trying to reconnect..."));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((getUptime() - priceNotifyLostConnection) > 300) { // 5 minutes timeout
|
while (true)
|
||||||
Serial.println(F("Price notification connection lost for 5 minutes, restarting handler..."));
|
{
|
||||||
restartPriceNotify();
|
// vTaskList(ptrTaskList);
|
||||||
priceNotifyLostConnection = 0;
|
// Serial.println(F("**********************************"));
|
||||||
}
|
// Serial.println(F("Task State Prio Stack Num"));
|
||||||
}
|
// Serial.println(F("**********************************"));
|
||||||
|
// Serial.print(ptrTaskList);
|
||||||
|
// Serial.println(F("**********************************"));
|
||||||
|
if (eventSourceTaskHandle != NULL)
|
||||||
|
xTaskNotifyGive(eventSourceTaskHandle);
|
||||||
|
|
||||||
void handleBlockNotifyDisconnection() {
|
int64_t currentUptime = esp_timer_get_time() / 1000000;
|
||||||
if (blockNotifyLostConnection == 0) {
|
;
|
||||||
blockNotifyLostConnection = getUptime();
|
|
||||||
Serial.println(F("Lost block notification connection, trying to reconnect..."));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((getUptime() - blockNotifyLostConnection) > 300) { // 5 minutes timeout
|
if (!getIsOTAUpdating())
|
||||||
Serial.println(F("Block notification connection lost for 5 minutes, restarting handler..."));
|
{
|
||||||
restartBlockNotify();
|
|
||||||
blockNotifyLostConnection = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleFrontlight() {
|
|
||||||
#ifdef HAS_FRONTLIGHT
|
#ifdef HAS_FRONTLIGHT
|
||||||
if (hasLightLevel() && preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE) != 0) {
|
if (hasLightLevel()) {
|
||||||
uint lightLevel = getLightLevel();
|
if (preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE) != 0)
|
||||||
uint luxThreshold = preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE);
|
{
|
||||||
|
if (hasLightLevel() && getLightLevel() <= 1 && preferences.getBool("flOffWhenDark", DEFAULT_FL_OFF_WHEN_DARK))
|
||||||
if (lightLevel <= 1 && preferences.getBool("flOffWhenDark", DEFAULT_FL_OFF_WHEN_DARK)) {
|
{
|
||||||
if (frontlightIsOn()) frontlightFadeOutAll();
|
if (frontlightIsOn()) {
|
||||||
} else if (lightLevel < luxThreshold && !frontlightIsOn()) {
|
|
||||||
frontlightFadeInAll();
|
|
||||||
} else if (frontlightIsOn() && lightLevel > luxThreshold) {
|
|
||||||
frontlightFadeOutAll();
|
frontlightFadeOutAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
else if (hasLightLevel() && getLightLevel() < preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE) && !frontlightIsOn())
|
||||||
|
{
|
||||||
|
frontlightFadeInAll();
|
||||||
}
|
}
|
||||||
|
else if (frontlightIsOn() && getLightLevel() > preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE))
|
||||||
|
{
|
||||||
|
frontlightFadeOutAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void checkWiFiConnection() {
|
if (!WiFi.isConnected())
|
||||||
if (!WiFi.isConnected()) {
|
{
|
||||||
if (!wifiLostConnection) {
|
if (!wifiLostConnection)
|
||||||
wifiLostConnection = getUptime();
|
{
|
||||||
|
wifiLostConnection = currentUptime;
|
||||||
Serial.println(F("Lost WiFi connection, trying to reconnect..."));
|
Serial.println(F("Lost WiFi connection, trying to reconnect..."));
|
||||||
}
|
}
|
||||||
if ((getUptime() - wifiLostConnection) > 600) {
|
|
||||||
|
if ((currentUptime - wifiLostConnection) > 600)
|
||||||
|
{
|
||||||
Serial.println(F("Still no connection after 10 minutes, restarting..."));
|
Serial.println(F("Still no connection after 10 minutes, restarting..."));
|
||||||
delay(2000);
|
delay(2000);
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
WiFi.begin();
|
WiFi.begin();
|
||||||
} else if (wifiLostConnection) {
|
}
|
||||||
|
else if (wifiLostConnection)
|
||||||
|
{
|
||||||
wifiLostConnection = 0;
|
wifiLostConnection = 0;
|
||||||
Serial.println(F("Connection restored, reset timer."));
|
Serial.println(F("Connection restored, reset timer."));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void checkMissedBlocks() {
|
if (getPriceNotifyInit() && !preferences.getBool("fetchEurPrice", DEFAULT_FETCH_EUR_PRICE) && !isPriceNotifyConnected())
|
||||||
Serial.println(F("Long time (45 min) since last block, checking if I missed anything..."));
|
{
|
||||||
int currentBlock = getBlockFetch();
|
priceNotifyLostConnection++;
|
||||||
if (currentBlock != -1) {
|
Serial.println(F("Lost price data connection..."));
|
||||||
if (currentBlock != getBlockHeight()) {
|
queueLedEffect(LED_DATA_PRICE_ERROR);
|
||||||
Serial.println(F("Detected stuck block height... restarting block handler."));
|
|
||||||
restartBlockNotify();
|
|
||||||
}
|
|
||||||
setLastBlockUpdate(getUptime());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// if price WS connection does not come back after 6*5 seconds, destroy and recreate
|
||||||
|
if (priceNotifyLostConnection > 6)
|
||||||
|
{
|
||||||
|
Serial.println(F("Restarting price handler..."));
|
||||||
|
|
||||||
void monitorDataConnections() {
|
restartPriceNotify();
|
||||||
// Price notification monitoring
|
// setupPriceNotify();
|
||||||
if (getPriceNotifyInit() && !preferences.getBool("fetchEurPrice", DEFAULT_FETCH_EUR_PRICE) && !isPriceNotifyConnected()) {
|
priceNotifyLostConnection = 0;
|
||||||
handlePriceNotifyDisconnection();
|
}
|
||||||
} else if (priceNotifyLostConnection > 0 && isPriceNotifyConnected()) {
|
}
|
||||||
|
else if (priceNotifyLostConnection > 0 && isPriceNotifyConnected())
|
||||||
|
{
|
||||||
priceNotifyLostConnection = 0;
|
priceNotifyLostConnection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block notification monitoring
|
if (getBlockNotifyInit() && !isBlockNotifyConnected())
|
||||||
if (getBlockNotifyInit() && !isBlockNotifyConnected()) {
|
{
|
||||||
handleBlockNotifyDisconnection();
|
blockNotifyLostConnection++;
|
||||||
} else if (blockNotifyLostConnection > 0 && isBlockNotifyConnected()) {
|
Serial.println(F("Lost block data connection..."));
|
||||||
|
queueLedEffect(LED_DATA_BLOCK_ERROR);
|
||||||
|
// if mempool WS connection does not come back after 6*5 seconds, destroy and recreate
|
||||||
|
if (blockNotifyLostConnection > 6)
|
||||||
|
{
|
||||||
|
Serial.println(F("Restarting block handler..."));
|
||||||
|
|
||||||
|
restartBlockNotify();
|
||||||
|
// setupBlockNotify();
|
||||||
|
blockNotifyLostConnection = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (blockNotifyLostConnection > 0 && isBlockNotifyConnected())
|
||||||
|
{
|
||||||
blockNotifyLostConnection = 0;
|
blockNotifyLostConnection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for missed price updates
|
// if more than 5 price updates are missed, there is probably something wrong, reconnect
|
||||||
if ((getLastPriceUpdate(CURRENCY_USD) - getUptime()) > (preferences.getUInt("minSecPriceUpd", DEFAULT_SECONDS_BETWEEN_PRICE_UPDATE) * 5)) {
|
if ((getLastPriceUpdate(CURRENCY_USD) - currentUptime) > (preferences.getUInt("minSecPriceUpd", DEFAULT_SECONDS_BETWEEN_PRICE_UPDATE) * 5))
|
||||||
|
{
|
||||||
Serial.println(F("Detected 5 missed price updates... restarting price handler."));
|
Serial.println(F("Detected 5 missed price updates... restarting price handler."));
|
||||||
|
|
||||||
restartPriceNotify();
|
restartPriceNotify();
|
||||||
|
// setupPriceNotify();
|
||||||
|
|
||||||
priceNotifyLostConnection = 0;
|
priceNotifyLostConnection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for missed blocks
|
// If after 45 minutes no mempool blocks, check the rest API
|
||||||
if ((getLastBlockUpdate() - getUptime()) > 45 * 60) {
|
if ((getLastBlockUpdate() - currentUptime) > 45 * 60)
|
||||||
checkMissedBlocks();
|
{
|
||||||
|
Serial.println(F("Long time (45 min) since last block, checking if I missed anything..."));
|
||||||
|
int currentBlock = getBlockFetch();
|
||||||
|
if (currentBlock != -1)
|
||||||
|
{
|
||||||
|
if (currentBlock != getBlockHeight())
|
||||||
|
{
|
||||||
|
Serial.println(F("Detected stuck block height... restarting block handler."));
|
||||||
|
// Mempool source stuck, restart
|
||||||
|
restartBlockNotify();
|
||||||
|
// setupBlockNotify();
|
||||||
|
}
|
||||||
|
// set last block update so it doesn't fetch for 45 minutes
|
||||||
|
setLastBlockUpdate(currentUptime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void app_main() {
|
if (currentUptime - getLastTimeSync() > 24 * 60 * 60)
|
||||||
initArduino();
|
{
|
||||||
Serial.begin(115200);
|
|
||||||
setup();
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
if (eventSourceTaskHandle != NULL) {
|
|
||||||
xTaskNotifyGive(eventSourceTaskHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!getIsOTAUpdating()) {
|
|
||||||
handleFrontlight();
|
|
||||||
checkWiFiConnection();
|
|
||||||
monitorDataConnections();
|
|
||||||
|
|
||||||
if (getUptime() - getLastTimeSync() > 24 * 60 * 60) {
|
|
||||||
Serial.println(F("Last time update is longer than 24 hours ago, sync again"));
|
Serial.println(F("Last time update is longer than 24 hours ago, sync again"));
|
||||||
syncTime();
|
syncTime();
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(5000));
|
vTaskDelay(pdMS_TO_TICKS(5000));
|
||||||
|
|
Loading…
Reference in a new issue