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
This commit is contained in:
BitMaker 2023-08-03 01:13:52 +02:00
parent cde810a515
commit d42fc0c9fa
2 changed files with 15 additions and 13 deletions

View File

@ -10,7 +10,7 @@
[platformio] [platformio]
globallib_dir = lib globallib_dir = lib
default_envs = NerminerV2 ;, ESP32-devKitv1 TTGO-T-Display default_envs = NerminerV2, ESP32-devKitv1; TTGO-T-Display
[env:NerminerV2] [env:NerminerV2]
platform = espressif32 platform = espressif32
@ -42,7 +42,7 @@ lib_deps =
https://github.com/tzapu/WiFiManager.git https://github.com/tzapu/WiFiManager.git
mathertel/OneButton @ ^2.0.3 mathertel/OneButton @ ^2.0.3
arduino-libraries/NTPClient 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] [env:ESP32-devKitv1]
@ -60,12 +60,10 @@ upload_speed = 115200
# 2 x 4.5MB app, 6.875MB SPIFFS # 2 x 4.5MB app, 6.875MB SPIFFS
;board_build.partitions = large_spiffs_16MB.csv ;board_build.partitions = large_spiffs_16MB.csv
;board_build.partitions = default_8MB.csv ;board_build.partitions = default_8MB.csv
;board_build.partitions = huge_app.csv board_build.partitions = huge_app.csv
board_build.partitions = default.csv ;board_build.partitions = default.csv
build_flags = build_flags =
-D ARDUINO_USB_MODE=1
-U FREERTOS
;-D DEBUG_MINING=1 ;-D DEBUG_MINING=1
lib_deps = lib_deps =
https://github.com/takkaO/OpenFontRender https://github.com/takkaO/OpenFontRender
@ -73,11 +71,11 @@ lib_deps =
https://github.com/tzapu/WiFiManager.git https://github.com/tzapu/WiFiManager.git
mathertel/OneButton @ ^2.0.3 mathertel/OneButton @ ^2.0.3
arduino-libraries/NTPClient 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] [env:TTGO-T-Display]
platform = espressif32 platform = espressif32
board = esp-wrover-kit board = esp32dev ;esp-wrover-kit
framework = arduino framework = arduino
monitor_filters = monitor_filters =
esp32_exception_decoder esp32_exception_decoder
@ -92,7 +90,6 @@ upload_speed = 115200
board_build.partitions = huge_app.csv board_build.partitions = huge_app.csv
;build_flags = ;build_flags =
; -D ARDUINO_USB_MODE=1
;-D DEBUG_MINING=1 ;-D DEBUG_MINING=1
lib_deps = lib_deps =
https://github.com/takkaO/OpenFontRender https://github.com/takkaO/OpenFontRender

View File

@ -3,7 +3,7 @@
#include <WiFi.h> #include <WiFi.h>
#include <esp_task_wdt.h> #include <esp_task_wdt.h>
#include <TFT_eSPI.h> // Graphics and font library for ILI9341 driver chip #include <TFT_eSPI.h> // Graphics and font library for ILI9341 driver chip
#include <wolfssl/wolfcrypt/sha256.h> //#include <wolfssl/wolfcrypt/sha256.h>
#include "ShaTests/nerdSHA256.h" #include "ShaTests/nerdSHA256.h"
#include "media/Free_Fonts.h" #include "media/Free_Fonts.h"
#include "media/images.h" #include "media/images.h"
@ -43,10 +43,10 @@ monitor_data mMonitor;
bool isMinerSuscribed = false; bool isMinerSuscribed = false;
unsigned long mLastTXtoPool = millis(); unsigned long mLastTXtoPool = millis();
void checkPoolConnection(void) { bool checkPoolConnection(void) {
if (client.connected()) { if (client.connected()) {
return; return true;
} }
isMinerSuscribed = false; isMinerSuscribed = false;
@ -65,7 +65,10 @@ void checkPoolConnection(void) {
WiFi.hostByName(poolString, serverIP); WiFi.hostByName(poolString, serverIP);
Serial.printf("Resolved DNS got: %s\n", serverIP.toString()); Serial.printf("Resolved DNS got: %s\n", serverIP.toString());
vTaskDelay(1000 / portTICK_PERIOD_MS); vTaskDelay(1000 / portTICK_PERIOD_MS);
return true;
} }
return false;
} }
//Implements a socketKeepAlive function and //Implements a socketKeepAlive function and
@ -140,7 +143,9 @@ void runStratumWorker(void *name) {
//portNumber = 3333; //portNumber = 3333;
//strcpy(btcString,"test"); //strcpy(btcString,"test");
checkPoolConnection(); if(!checkPoolConnection())
//If server not reachable add 5sec delay bettween connection petitions
vTaskDelay(5000 / portTICK_PERIOD_MS);
if(!isMinerSuscribed){ if(!isMinerSuscribed){