diff --git a/.gitignore b/.gitignore index 6396bf6..5ca6960 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .pio .vscode NerdMinerLog.txt -platformio-device-monitor*.log diff --git a/README.md b/README.md index 99695ea..ab10550 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ If you want you can compile the entire project using Arduino, PlatformIO or Expr After programming, you will only need to setup your Wifi and BTC address. 1. Connect to NerdMinerAP + - AP: NerdMinerAP + - PASS: MineYourCoins 1. Setup your Wifi Network 1. Add your BTCaddress diff --git a/platformio.ini b/platformio.ini index 910b64c..0b0cec5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,20 +18,22 @@ framework = arduino monitor_filters = esp32_exception_decoder time - log2file board_build.arduino.memory_type = qio_opi monitor_speed = 115200 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 build_flags = -D LV_LVGL_H_INCLUDE_SIMPLE -D BOARD_HAS_PSRAM -D ARDUINO_USB_MODE=1 -D ARDUINO_USB_CDC_ON_BOOT=1 - -D DEBUG_MINING=1 - ;-D DEBUG_MINING_SHARE + ;-D DEBUG_MINING=1 lib_deps = https://github.com/takkaO/OpenFontRender bblanchon/ArduinoJson@^6.21.2 diff --git a/src/NerdMinerV2.ino.cpp b/src/NerdMinerV2.ino.cpp index 8cb03aa..1b6281b 100644 --- a/src/NerdMinerV2.ino.cpp +++ b/src/NerdMinerV2.ino.cpp @@ -79,6 +79,7 @@ void setup() // Higher prio monitor task Serial.println(""); Serial.println("Initiating tasks..."); + xTaskCreate(runMonitor, "Monitor", 5000, NULL, 4, NULL); /******** CREATE MINER TASKS *****/ for (size_t i = 0; i < THREADS; i++) { @@ -87,10 +88,8 @@ void setup() // Start mining tasks BaseType_t res = xTaskCreate(runWorker, name, 30000, (void*)name, 1, NULL); - Serial.printf("Starting miner %s %s!\n", name, res == pdPASS? "successful":"failed"); + Serial.printf("Starting %s %s!\n", name, res == pdPASS? "successful":"failed"); } - - Serial.println("NerdMiner v2 started......"); } void app_error_fault_handler(void *arg) { @@ -124,5 +123,4 @@ void loop() { //Run miner on main core when there is time --Currently on test // runMiner(); - runMonitor(); } \ No newline at end of file diff --git a/src/mining.cpp b/src/mining.cpp index baaa10c..8bd092e 100644 --- a/src/mining.cpp +++ b/src/mining.cpp @@ -3,7 +3,6 @@ #include #include #include // Graphics and font library for ILI9341 driver chip -#include #include "media/Free_Fonts.h" #include "media/images.h" #include "mbedtls/md.h" @@ -33,6 +32,8 @@ extern char btcString[80]; extern OpenFontRender render; extern TFT_eSprite background; + + bool checkValid(unsigned char* hash, unsigned char* target) { bool valid = true; for(uint8_t i=31; i>=0; i--) { @@ -44,7 +45,7 @@ bool checkValid(unsigned char* hash, unsigned char* target) { break; } } - #ifdef DEBUG_MINING_SHARE + #ifdef DEBUG_MINING if (valid) { Serial.print("\tvalid : "); for (size_t i = 0; i < 32; i++) @@ -113,6 +114,13 @@ void getNextExtranonce2(int extranonce2_size, char *extranonce2) { extranonce2[2 * extranonce2_size] = 0; } +bool verifyPayload (String* line){ + if(line->length() == 0) return false; + line->trim(); + if(line->isEmpty()) return false; + return true; +} + bool checkError(const StaticJsonDocument doc) { if (doc["error"].size() == 0) { return false; @@ -123,7 +131,7 @@ bool checkError(const StaticJsonDocument doc) { void runWorker(void *name) { - // TEST: https://bitcoin.stackexchange.com/questions/22929/full-example-data-for-scrypt-stratum-client +// TEST: https://bitcoin.stackexchange.com/questions/22929/full-example-data-for-scrypt-stratum-client Serial.println(""); Serial.printf("\n[WORKER] Started. Running %s on core %d\n", (char *)name, xPortGetCoreID()); @@ -534,6 +542,7 @@ void runWorker(void *name) { //////////////////THREAD CALLS/////////////////// + //Testeamos hashrate final usando hilo principal //this is currently on test @@ -573,7 +582,7 @@ void runMiner(void){ } -void runMonitor() { +void runMonitor(void *name){ // Serial.println("[MONITOR] started"); diff --git a/src/mining.h b/src/mining.h index ffc5093..bfbb74b 100644 --- a/src/mining.h +++ b/src/mining.h @@ -4,6 +4,6 @@ #define MAX_NONCE 5000000U #define TARGET_NONCE 471136297U -void runMonitor(); +void runMonitor(void *name); void runWorker(void *name); void runMiner(void); \ No newline at end of file