Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[platformio]
globallib_dir = lib

default_envs = NerdminerV2, NerdminerV2-T-HMI, wt32-sc01, wt32-sc01-plus, han_m5stack, M5Stick-C, M5Stick-C-Plus2, M5Stick-CPlus, esp32cam, ESP32-2432S028R, ESP32_2432S028_2USB, Lilygo-T-Embed, ESP32-devKitv1, NerdminerV2-S3-DONGLE, NerdminerV2-S3-GEEK, NerdminerV2-S3-AMOLED, NerdminerV2-S3-AMOLED-TOUCH, NerdminerV2-T-QT, NerdminerV2-T-Display_V1, TTGO-T-Display, M5-StampS3, ESP32-S3-devKitv1, ESP32-S3-mini-wemos, ESP32-S2-mini-wemos, ESP32-S3-mini-weact, ESP32-D0WD-V3-weact, ESP32-C3-super-mini, ESP32-C3-devKitmv1, ESP32-C3-042-OLED, ESP32-S3-042-OLED, ESP32-C3-spotpear, esp32-s3-devkitc1-n32r8
default_envs = NerdminerV2, NerdminerV2-T-HMI, wt32-sc01, wt32-sc01-plus, han_m5stack, M5Stick-C, M5Stick-C-Plus2, M5Stick-CPlus, esp32cam, ESP32-2432S028R, ESP32_2432S028_2USB, ESP32-2432S024, Lilygo-T-Embed, ESP32-devKitv1, NerdminerV2-S3-DONGLE, NerdminerV2-S3-GEEK, NerdminerV2-S3-AMOLED, NerdminerV2-S3-AMOLED-TOUCH, NerdminerV2-T-QT, NerdminerV2-T-Display_V1, TTGO-T-Display, M5-StampS3, ESP32-S3-devKitv1, ESP32-S3-mini-wemos, ESP32-S2-mini-wemos, ESP32-S3-mini-weact, ESP32-D0WD-V3-weact, ESP32-C3-super-mini, ESP32-C3-devKitmv1, ESP32-C3-042-OLED, ESP32-S3-042-OLED, ESP32-C3-spotpear, esp32-s3-devkitc1-n32r8

; Global configuration for all environments
[env]
Expand Down Expand Up @@ -1014,6 +1014,62 @@ lib_ignore =

;--------------------------------------------------------------------

[env:ESP32-2432S024]
platform = espressif32@6.6.0
board = esp32dev
framework = arduino
extra_scripts =
pre:auto_firmware_version.py
post:post_build_merge.py
monitor_speed = 115200
monitor_filters =
esp32_exception_decoder
time
colorize
;debug
upload_speed = 921600
;build_type = debug
board_build.partitions = huge_app.csv
build_flags =
;-DDEBUG_MEMORY=1
-D ESP32_2432S028R=1
-DUSER_SETUP_LOADED=1
-DILI9341_2_DRIVER=1
-DTFT_WIDTH=240
-DTFT_HEIGHT=320
-DTFT_BACKLIGHT_ON=HIGH
-DTFT_MOSI=13
-DTFT_SCLK=14
-DTFT_CS=15
-DTFT_DC=2
-DTFT_RST=12
-DTFT_BL=27
-DETOUCH_CS=33
-DTOUCH_CLK=25
-DTOUCH_MISO=39
-DTOUCH_MOSI=32
-DTOUCH_IRQ=36
-DLOAD_GLCD=1
-DLOAD_FONT2=1
-DLOAD_GFXFF=1
-DSMOOTH_FONT=1
-DSPI_FREQUENCY=55000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000

lib_deps =
https://github.com/takkaO/OpenFontRender#v1.2
bblanchon/ArduinoJson@^6.21.5
https://github.com/tzapu/WiFiManager.git#v2.0.17
mathertel/oneButton@^2.6.1
arduino-libraries/NTPClient@^3.2.1
bodmer/TFT_eSPI@^2.5.43
https://github.com/achillhasler/TFT_eTouch
lib_ignore =
HANSOLOminerv2

;--------------------------------------------------------------------

[env:NerdminerV2-T-HMI]
platform = espressif32@6.6.0
board = lilygo-t-hmi
Expand Down
4 changes: 2 additions & 2 deletions src/NerdMinerV2.ino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ void setup()
Serial.println("Initiating tasks...");
static const char monitor_name[] = "(Monitor)";
#if defined(CONFIG_IDF_TARGET_ESP32)
// Reduced stack for ESP32 classic to save memory
BaseType_t res1 = xTaskCreatePinnedToCore(runMonitor, "Monitor", 8000, (void*)monitor_name, 5, NULL,1);
// Increased stack for ESP32 classic due to NVS operations
BaseType_t res1 = xTaskCreatePinnedToCore(runMonitor, "Monitor", 9500, (void*)monitor_name, 5, NULL,1);
#else
BaseType_t res1 = xTaskCreatePinnedToCore(runMonitor, "Monitor", 10000, (void*)monitor_name, 5, NULL,1);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef VERSION_H
#define VERSION_H

#define CURRENT_VERSION "V1.8.2"
#define CURRENT_VERSION "V1.8.3"

#endif // VERSION_H
68 changes: 66 additions & 2 deletions src/wManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include "mining.h"
#include "timeconst.h"

#include <ArduinoJson.h>
#include <esp_flash.h>


// Flag for saving data
bool shouldSaveConfig = false;
Expand All @@ -31,6 +34,63 @@ nvMemory nvMem;

extern SDCard SDCrd;

String readCustomAPName() {
Serial.println("DEBUG: Attempting to read custom AP name from flash at 0x3F0000...");

// Leer directamente desde flash
const size_t DATA_SIZE = 128;
uint8_t buffer[DATA_SIZE];
memset(buffer, 0, DATA_SIZE); // Clear buffer

// Leer desde 0x3F0000
esp_err_t result = esp_flash_read(NULL, buffer, 0x3F0000, DATA_SIZE);
if (result != ESP_OK) {
Serial.printf("DEBUG: Flash read error: %s\n", esp_err_to_name(result));
return "";
}

Serial.println("DEBUG: Successfully read from flash");
String data = String((char*)buffer);

// Debug: show raw data read
Serial.printf("DEBUG: Raw flash data: '%s'\n", data.c_str());

if (data.startsWith("WEBFLASHER_CONFIG:")) {
Serial.println("DEBUG: Found WEBFLASHER_CONFIG marker");
String jsonPart = data.substring(18); // Después del marcador "WEBFLASHER_CONFIG:"

Serial.printf("DEBUG: JSON part: '%s'\n", jsonPart.c_str());

DynamicJsonDocument doc(256);
DeserializationError error = deserializeJson(doc, jsonPart);

if (error == DeserializationError::Ok) {
Serial.println("DEBUG: JSON parsed successfully");

if (doc.containsKey("apname")) {
String customAP = doc["apname"].as<String>();
customAP.trim();

if (customAP.length() > 0 && customAP.length() < 32) {
Serial.printf("✅ Custom AP name from webflasher: %s\n", customAP.c_str());
return customAP;
} else {
Serial.printf("DEBUG: AP name invalid length: %d\n", customAP.length());
}
} else {
Serial.println("DEBUG: 'apname' key not found in JSON");
}
} else {
Serial.printf("DEBUG: JSON parse error: %s\n", error.c_str());
}
} else {
Serial.println("DEBUG: WEBFLASHER_CONFIG marker not found - no custom config");
}

Serial.println("DEBUG: Using default AP name");
return "";
}

void saveConfigCallback()
// Callback notifying us of the need to save configuration
{
Expand Down Expand Up @@ -76,6 +136,10 @@ void init_WifiManager()
Serial.begin(115200);
#endif //MONITOR_SPEED
//Serial.setTxTimeoutMs(10);

// Check for custom AP name from flasher config, otherwise use default
String customAPName = readCustomAPName();
const char* apName = customAPName.length() > 0 ? customAPName.c_str() : DEFAULT_SSID;

//Init pin 15 to eneble 5V external power (LilyGo bug)
#ifdef PIN_ENABLE5V
Expand Down Expand Up @@ -204,7 +268,7 @@ void init_WifiManager()
wm.setConfigPortalBlocking(true); //Hacemos que el portal SI bloquee el firmware
drawSetupScreen();
mMonitor.NerdStatus = NM_Connecting;
wm.startConfigPortal(DEFAULT_SSID, DEFAULT_WIFIPW);
wm.startConfigPortal(apName, DEFAULT_WIFIPW);

if (shouldSaveConfig)
{
Expand Down Expand Up @@ -238,7 +302,7 @@ void init_WifiManager()
wm.setConfigPortalBlocking(true);
wm.setEnableConfigPortal(true);
// if (!wm.autoConnect(Settings.WifiSSID.c_str(), Settings.WifiPW.c_str()))
if (!wm.autoConnect(DEFAULT_SSID, DEFAULT_WIFIPW))
if (!wm.autoConnect(apName, DEFAULT_WIFIPW))
{
Serial.println("Failed to connect to configured WIFI, and hit timeout");
if (shouldSaveConfig) {
Expand Down