From d42fc0c9faf63dccec58a1f7953e0a561d3f3b5c Mon Sep 17 00:00:00 2001 From: BitMaker Date: Thu, 3 Aug 2023 01:13:52 +0200 Subject: [PATCH] Fix add delay pool connection + building on any ESP32 - Added a 5sec delay after not being able to connect with pool. - Compile code to work on any ESP32 dev kit --- platformio.ini | 15 ++++++--------- src/mining.cpp | 13 +++++++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/platformio.ini b/platformio.ini index 1e11206..92b14af 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,7 +10,7 @@ [platformio] globallib_dir = lib -default_envs = NerminerV2 ;, ESP32-devKitv1 TTGO-T-Display +default_envs = NerminerV2, ESP32-devKitv1; TTGO-T-Display [env:NerminerV2] platform = espressif32 @@ -42,7 +42,7 @@ lib_deps = https://github.com/tzapu/WiFiManager.git mathertel/OneButton @ ^2.0.3 arduino-libraries/NTPClient - https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4 + ;https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4 [env:ESP32-devKitv1] @@ -60,12 +60,10 @@ upload_speed = 115200 # 2 x 4.5MB app, 6.875MB SPIFFS ;board_build.partitions = large_spiffs_16MB.csv ;board_build.partitions = default_8MB.csv -;board_build.partitions = huge_app.csv -board_build.partitions = default.csv +board_build.partitions = huge_app.csv +;board_build.partitions = default.csv build_flags = - -D ARDUINO_USB_MODE=1 - -U FREERTOS ;-D DEBUG_MINING=1 lib_deps = https://github.com/takkaO/OpenFontRender @@ -73,11 +71,11 @@ lib_deps = https://github.com/tzapu/WiFiManager.git mathertel/OneButton @ ^2.0.3 arduino-libraries/NTPClient - https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4 + ;https://github.com/golden-guy/Arduino_wolfssl.git#v5.5.4 [env:TTGO-T-Display] platform = espressif32 -board = esp-wrover-kit +board = esp32dev ;esp-wrover-kit framework = arduino monitor_filters = esp32_exception_decoder @@ -92,7 +90,6 @@ upload_speed = 115200 board_build.partitions = huge_app.csv ;build_flags = -; -D ARDUINO_USB_MODE=1 ;-D DEBUG_MINING=1 lib_deps = https://github.com/takkaO/OpenFontRender diff --git a/src/mining.cpp b/src/mining.cpp index 5a0adc5..ecfd283 100644 --- a/src/mining.cpp +++ b/src/mining.cpp @@ -3,7 +3,7 @@ #include #include #include // Graphics and font library for ILI9341 driver chip -#include +//#include #include "ShaTests/nerdSHA256.h" #include "media/Free_Fonts.h" #include "media/images.h" @@ -43,10 +43,10 @@ monitor_data mMonitor; bool isMinerSuscribed = false; unsigned long mLastTXtoPool = millis(); -void checkPoolConnection(void) { +bool checkPoolConnection(void) { if (client.connected()) { - return; + return true; } isMinerSuscribed = false; @@ -65,7 +65,10 @@ void checkPoolConnection(void) { WiFi.hostByName(poolString, serverIP); Serial.printf("Resolved DNS got: %s\n", serverIP.toString()); vTaskDelay(1000 / portTICK_PERIOD_MS); + return true; } + + return false; } //Implements a socketKeepAlive function and @@ -140,7 +143,9 @@ void runStratumWorker(void *name) { //portNumber = 3333; //strcpy(btcString,"test"); - checkPoolConnection(); + if(!checkPoolConnection()) + //If server not reachable add 5sec delay bettween connection petitions + vTaskDelay(5000 / portTICK_PERIOD_MS); if(!isMinerSuscribed){