From 6e891f1a5f509c7817567633545b627c4dbc837e Mon Sep 17 00:00:00 2001 From: elmo128 <60213508+elmo128@users.noreply.github.com> Date: Sun, 17 Sep 2023 16:44:01 +0200 Subject: [PATCH] update files --- README.md | 7 +++---- platformio.ini | 2 +- src/drivers/storage/SDCard.cpp | 16 ++++++++++++++-- src/drivers/storage/SDCard.h | 8 ++------ src/drivers/storage/nvMemory.cpp | 5 ++++- src/drivers/storage/storage.h | 4 +++- src/wManager.cpp | 8 ++++---- 7 files changed, 31 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 49158f9..ca0102b 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,6 @@ Every time an stratum job notification is received miner update its current work - ESP32-2432S028R 2,8" ([Aliexpress link](https://s.click.aliexpress.com/e/_DdXkvLv)) - ESP32-cam [Board Info](https://lastminuteengineers.com/getting-started-with-esp32-cam/) -* affiliate link - ### Flash firmware #### microMiners Flashtool [Recommended] Easyiest way to flash firmware. Build your own miner using the folowing firwmare flash tool: @@ -89,14 +87,15 @@ After programming, you will only need to setup your Wifi and BTC address. #### SD card (if available) 1. Format a SD card using Fat32. -1. Create a file named "config.json" in your card's root containing the the following structure. Adjust the settings to your needs: +1. Create a file named "config.json" in your card's root, containing the the following structure. Adjust the settings to your needs: { "SSID": "myWifiSSID", "PW": "myWifiPassword", "PoolUrl": "public-pool.io", "PoolPort": 21496, "BtcWallet": "walletID", - "Timezone": 2 + "Timezone": 2, + "saveStats": false } 1. Insert the SD card. 1. Hold down the "reset configurations" button as described below to reset the configurations and/or boot without settings in your nvmemory. diff --git a/platformio.ini b/platformio.ini index 8ca1833..a66d3a5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,7 +10,7 @@ [platformio] globallib_dir = lib -default_envs = esp32cam, ESP32-2432S028R, NerminerV2, ESP32-devKitv1, NerminerV2-S3-DONGLE, NerminerV2-S3-AMOLED, NerminerV2-T-QT, NerdminerV2-T-Display_V1, ESP32-2432S028R +default_envs = esp32cam, ESP32-2432S028R, NerminerV2, ESP32-devKitv1, NerminerV2-S3-DONGLE, NerminerV2-S3-AMOLED, NerminerV2-T-QT, NerdminerV2-T-Display_V1, ESP32-2432S028R [env:NerminerV2] platform = espressif32 diff --git a/src/drivers/storage/SDCard.cpp b/src/drivers/storage/SDCard.cpp index ceee954..fe06bde 100644 --- a/src/drivers/storage/SDCard.cpp +++ b/src/drivers/storage/SDCard.cpp @@ -1,6 +1,16 @@ -#include"SDCard.h" -#if defined (BUILD_SDMMC_1) || defined(BUILD_SDMMC_4) || defined (BUILD_SDSPI) +#include +#include +#include + +#include "storage.h" +#include "nvMemory.h" +#include "..\devices\device.h" +#include "SDCard.h" + +#if defined (BUILD_SDMMC_1) || defined(BUILD_SDMMC_4) + +#include SDCard::SDCard() { @@ -58,6 +68,8 @@ bool SDCard::loadConfigFile(TSettings* Settings) Settings->PoolPort = json[JSON_KEY_POOLPORT].as(); if (json.containsKey(JSON_KEY_TIMEZONE)) Settings->Timezone = json[JSON_KEY_TIMEZONE].as(); + if (json.containsKey(JSON_KEY_STATS2NV)) + Settings->saveStats = json[JSON_KEY_STATS2NV].as(); return true; } else diff --git a/src/drivers/storage/SDCard.h b/src/drivers/storage/SDCard.h index baba932..b2e91f5 100644 --- a/src/drivers/storage/SDCard.h +++ b/src/drivers/storage/SDCard.h @@ -1,6 +1,8 @@ #ifndef _SDCARD_H_ #define _SDCARD_H_ +#include "storage.h" +#include "nvMemory.h" #include "..\devices\device.h" #if defined (SDMMC_D0) && defined (SDMMC_D1) && defined (SDMMC_D2) && defined (SDMMC_D3) @@ -13,12 +15,6 @@ #warning SD card support disabled! #endif -#include -#include - -#include "storage.h" -#include "nvMemory.h" - // Handles the transfer of settings from sd card to nv memory (wifi credentials are handled by wifimanager) class SDCard { diff --git a/src/drivers/storage/nvMemory.cpp b/src/drivers/storage/nvMemory.cpp index c8dac20..a686589 100644 --- a/src/drivers/storage/nvMemory.cpp +++ b/src/drivers/storage/nvMemory.cpp @@ -6,6 +6,9 @@ #include #include +#include "..\devices\device.h" +#include "storage.h" + nvMemory::nvMemory() { Initialized_ = false; @@ -30,7 +33,7 @@ bool nvMemory::saveConfig(TSettings* Settings) json[JSON_KEY_POOLPORT] = Settings->PoolPort; json[JSON_KEY_WALLETID] = Settings->BtcWallet; json[JSON_KEY_TIMEZONE] = Settings->Timezone; - json[JSON_KEY_TIMEZONE] = Settings->saveStats; + json[JSON_KEY_STATS2NV] = Settings->saveStats; // Open config file File configFile = SPIFFS.open(JSON_CONFIG_FILE, "w"); diff --git a/src/drivers/storage/storage.h b/src/drivers/storage/storage.h index 348b1b7..65a2b29 100644 --- a/src/drivers/storage/storage.h +++ b/src/drivers/storage/storage.h @@ -1,6 +1,8 @@ #ifndef _STORAGE_H_ #define _STORAGE_H_ +#include + #define DEFAULT_SSID "NMAP" #define DEFAULT_WIFIPW "1234567890" #define DEFAULT_POOLURL "public-pool.io" @@ -17,7 +19,7 @@ #define JSON_KEY_WALLETID "BtcWallet" #define JSON_KEY_POOLPORT "PoolPort" #define JSON_KEY_TIMEZONE "Timezone" -#define JSON_KEY_STATS2NV "saveStatsToNVS" +#define JSON_KEY_STATS2NV "saveStats" struct TSettings { diff --git a/src/wManager.cpp b/src/wManager.cpp index 4906ae9..93afff4 100644 --- a/src/wManager.cpp +++ b/src/wManager.cpp @@ -164,15 +164,15 @@ void init_WifiManager() wm.setConfigPortalBlocking(true); //Hacemos que el portal SI bloquee el firmware drawSetupScreen(); - if (!wm.startConfigPortal(DEFAULT_SSID, DEFAULT_WIFIPW)) + if (wm.startConfigPortal(DEFAULT_SSID, DEFAULT_WIFIPW)) { - Serial.println("failed to connect and hit timeout"); //Could be break forced after edditing, so save new config - + Serial.println("failed to connect and hit timeout"); strncpy(Settings.PoolAddress, pool_text_box.getValue(), sizeof(Settings.PoolAddress)); Settings.PoolPort = atoi(port_text_box_num.getValue()); strncpy(Settings.BtcWallet, addr_text_box.getValue(), sizeof(Settings.BtcWallet)); Settings.Timezone = atoi(time_text_box_num.getValue()); + Serial.println(save_stats_to_nvs.getValue()); Settings.saveStats = (strncmp(save_stats_to_nvs.getValue(), "T", 1) == 0); nvMem.saveConfig(&Settings); @@ -180,7 +180,7 @@ void init_WifiManager() //reset and try again, or maybe put it to deep sleep ESP.restart(); delay(5000); - } + }; } else {