Merge remote-tracking branch 'upstream/master'

This commit is contained in:
sany3001 2023-12-29 07:52:02 +01:00
commit dc65c45525
45 changed files with 15805 additions and 2555 deletions

144
README.md
View File

@ -1,81 +1,94 @@
# NerdSoloMiner
**The NerdSoloMiner v2**
This is a **free and open source project** that let you try to reach a bitcoin block with a small piece of hardware.
This is a **free and open source project** that let you try to reach a bitcoin block with a small piece of hardware.
The main aim of this project is to let you **learn more about minery** and to have a beautiful piece of hardware in your desktop.
Original project https://github.com/valerio-vaccaro/HAN
![image](images/bgNerdMinerV2.png)
## Requirements
- TTGO T-Display S3 or any supported boards (check Build tutorial 👇)
- 3D BOX [here](3d_files/)
### Project description
**ESP32 implementing Stratum protocol** to mine on solo pool. Pool can be changed but originally works with Public-pool.io (where Nerdminers are supported).
**ESP32 implementing Stratum protocol** to mine on solo pool. Pool can be changed but originally works with [public-pool.io](https://web.public-pool.io) (where Nerdminers are supported).
This project was initialy developed using ESP32-S3, but currently support other boards. It uses WifiManager to modify miner settings and save them to SPIFF.
The microMiner comes with several screens to monitor it's working procedure and also to show you network mining stats.
Currently includes:
- NerdMiner Screen > Mining data of Nerdminer
- ClockMiner Screen > Fashion style clock miner
- GlobalStats Screen > Global minery stats and relevant data
This miner is multicore and multithreads, both cores are used to mine and several threads are used to implementing stratum work and wifi stuff.
Every time an stratum job notification is received miner update its current work to not create stale shares.
This miner is multicore and multithreads, both cores are used to mine and several threads are used to implementing stratum work and wifi stuff.
Every time an stratum job notification is received miner update its current work to not create stale shares.
**IMPORTANT** Miner is not seen by all standard pools due to its low share difficulty. You can check miner work remotely using specific pools specified down or seeing logs via UART.
***Current project is still in developement and more features will be added***
**_Current project is still in developement and more features will be added_**
## Build Tutorial
### Hardware requirements
- LILYGO T-Display S3 (original one) or any other supported boards
- 3D BOX [here](3d_files/)
#### Current Supported Boards
- LILYGO T-Display S3 ([Aliexpress link*](https://s.click.aliexpress.com/e/_Ddy7739))
- ESP32-WROOM-32, ESP32-Devkit1.. ([Aliexpress link*](https://s.click.aliexpress.com/e/_DCzlUiX))
- LILYGO T-QT pro ([Aliexpress link*](https://s.click.aliexpress.com/e/_DBQIr43))
- LILYGO T-Display 1.14 ([Aliexpress link*](https://s.click.aliexpress.com/e/_DEqGvSJ))
- LILYGO T-Display S3 AMOLED ([Aliexpress link*](https://s.click.aliexpress.com/e/_DmOIK6j))
- LILYGO T-Dongle S3 ([Aliexpress link*](https://s.click.aliexpress.com/e/_DmQCPyj))
- ESP32-2432S028R 2,8" ([Aliexpress link*](https://s.click.aliexpress.com/e/_DdXkvLv) / Dev support: @nitroxgas / ⚡jadeddonald78@walletofsatoshi.com)
- ESP32-cam ([Board Info](https://lastminuteengineers.com/getting-started-with-esp32-cam/) / Dev support: @elmo128)
*Affiliate links
- LILYGO T-Display S3 ([Aliexpress link\*](https://s.click.aliexpress.com/e/_Ddy7739))
- ESP32-WROOM-32, ESP32-Devkit1.. ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DCzlUiX))
- LILYGO T-QT pro ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DBQIr43))
- LILYGO T-Display 1.14 ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DEqGvSJ))
- LILYGO T-Display S3 AMOLED ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DmOIK6j))
- LILYGO T-Dongle S3 ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DmQCPyj))
- ESP32-2432S028R 2,8" ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DdXkvLv) / Dev support: @nitroxgas / ⚡jadeddonald78@walletofsatoshi.com)
- ESP32-cam ([Board Info](https://lastminuteengineers.com/getting-started-with-esp32-cam/) / Dev support: @elmo128)
- M5-StampS3 ([Aliexpress link\*](https://s.click.aliexpress.com/e/_DevABY3) / Dev support: @gyengus)
\*Affiliate links
### Flash firmware
#### microMiners Flashtool [Recommended]
Easyiest way to flash firmware. Build your own miner using the folowing firwmare flash tool:
1. Get a TTGO T-display S3 or any other supported board
1. Go to NM2 flasher online: https://bitmaker-hub.github.io/diyflasher/
1. Go to NM2 flasher online: https://flasher.bitronics.store/ (recommend via Google Chrome incognito mode)
#### Standard tool
Create your own miner using the online firwmare flash tool **ESPtool** and one of the **binary files** that you will find in the ``bin`` folder.
Create your own miner using the online firwmare flash tool **ESPtool** and one of the **binary files** that you will find in the `bin` folder.
If you want you can compile the entire project using Arduino, PlatformIO or Expressif IDF.
1. Get a TTGO T-display S3 or any supported board
1. Download this repository
1. Go to ESPtool online: https://espressif.github.io/esptool-js/
1. Load the firmware with the binary from one of the sub-folders of ``bin`` corresponding to your board.
1. Plug your board and select each file from the sub-folder (``.bin`` files).
1. Load the firmware with the binary from one of the sub-folders of `bin` corresponding to your board.
1. Plug your board and select each file from the sub-folder (`.bin` files).
### Update firmware
Update NerdMiner firmware following same flashing steps but only using the file 0x10000_firmware.bin.
#### Build troubleshooting
1. Online ESPtool works with chrome, chromium, brave
1. Online [ESP Tool](https://espressif.github.io/esptool-js/) works with chrome, chromium, brave
1. ESPtool recommendations: use 115200bps
1. Build errors > If during firmware download upload stops, it's recommended to enter the board in boot mode. Unplug cable, hold right bottom button and then plug cable. Try programming
1. In extreme case you can "Erase all flash" on ESPtool to clean all current configuration before uploading firmware. There has been cases that experimented Wifi failures until this was made.
1. In extreme case you can "Erase all flash" on ESPtool to clean all current configuration before uploading firmware. There has been cases that experimented Wifi failures until this was made.
1. In case of ESP32-WROOM Boards, could be necessary to put your board on boot mode. Hold boot button, press reset button and then program.
## NerdMiner configuration
After programming, you will only need to setup your Wifi and BTC address.
Note: when BTC address of your selected wallet is not provided, mining will not be started.
@ -83,10 +96,14 @@ Note: when BTC address of your selected wallet is not provided, mining will not
#### Wifi Accesspoint
1. Connect to NerdMinerAP
- AP: NerdMinerAP
- PASS: MineYourCoins
- AP: NerdMinerAP
- PASS: MineYourCoins
1. Setup your Wifi Network
1. Add your BTCaddress
1. Change the password if needed
- If you are using public-pool.io and you want to set a custom name to your worker you can append a string with format _.yourworkername_ to the address
#### SD card (if available)
@ -97,12 +114,14 @@ Note: when BTC address of your selected wallet is not provided, mining will not
"SSID": "myWifiSSID",
"WifiPW": "myWifiPassword",
"PoolUrl": "public-pool.io",
"PoolPort": 21496,
"PoolPort": 21496,
"PoolPassword": "x",
"BtcWallet": "walletID",
"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.
1. Power down to remove the SD card. It is not needed for mining.
@ -111,20 +130,21 @@ Note: when BTC address of your selected wallet is not provided, mining will not
Recommended low difficulty share pools:
| Pool URL | Port | Web URL | Status |
|--- |--- |--- |--- |
| public-pool.io | 21496 | https://web.public-pool.io | Open Source Solo Bitcoin Mining Pool supporting open source miners |
| nerdminers.org | | https://nerdminers.org | Team domain for future pool - Currently pointing to public-pool.io |
| pool.nerdminer.io | 3333 | https://nerdminer.io | Mantained by CHMEX |
| pool.vkbit.com | 3333 | https://vkbit.com/ | Mantained by djerfy |
| Pool URL | Port | Web URL | Status |
| ----------------- | ----- | -------------------------- | ------------------------------------------------------------------ |
| public-pool.io | 21496 | https://web.public-pool.io | Open Source Solo Bitcoin Mining Pool supporting open source miners |
| nerdminers.org | | https://nerdminers.org | Team domain for future pool - Currently pointing to public-pool.io |
| pool.nerdminer.io | 3333 | https://nerdminer.io | Mantained by CHMEX |
| pool.vkbit.com | 3333 | https://vkbit.com/ | Mantained by djerfy - public-pool fork |
| pool.pyblock.xyz | 3333 | https://pool.pyblock.xyz/ | Mantained by curly60e |
Other standard pools not compatible with low difficulty share:
| Pool URL | Port | Web URL |
|--- |--- |--- |
| solo.ckpool.org | 3333 | https://solo.ckpool.org/ |
| Pool URL | Port | Web URL |
| ------------------------ | ---- | ----------------------------------------- |
| solo.ckpool.org | 3333 | https://solo.ckpool.org/ |
| btc.zsolo.bid | 6057 | https://zsolo.bid/en/btc-solo-mining-pool |
| eu.stratum.slushpool.com | 3333 | https://braiins.com/pool |
| eu.stratum.slushpool.com | 3333 | https://braiins.com/pool |
### Buttons
@ -133,16 +153,17 @@ Other standard pools not compatible with low difficulty share:
- One click > change screen.
- Double click > change screen orientation.
- Tripple click > turn the screen off and on again.
- Hold 5 seconds > **reset the configurations and reboot** your NerdMiner.
- Hold 5 seconds > **reset the configurations and reboot** your NerdMiner.
#### Two button devices:
With the USB-C port to the right:
**TOP BUTTON**
- One click > change screen.
- Hold 5 seconds > top right button to **reset the configurations and reboot** your NerdMiner.
- Hold and power up > enter **configuration mode** and edit current config via Wifi. You could change your settings or verify them.
- One click > change screen.
- Hold 5 seconds > top right button to **reset the configurations and reboot** your NerdMiner.
- Hold and power up > enter **configuration mode** and edit current config via Wifi. You could change your settings or verify them.
**BOTTOM BUTTON**
@ -150,41 +171,48 @@ With the USB-C port to the right:
- Double click > change orientation (default is USB-C to the right)
#### Build video
[![Ver video aquí](https://img.youtube.com/vi/POUT2R_opDs/0.jpg)](https://youtu.be/POUT2R_opDs)
## Developers
### Project guidelines
- Current project was addapted to work with PlatformIO
- Current project works with ESP32-S3 and ESP32-wroom.
- Partition squeme should be build as huge app
- All libraries needed shown on platform.ini
### Job done
- [x] Move project to platformIO
- [x] Bug rectangle on screen when 1milion shares
- [x] Bug memory leaks
- [x] Bug Reboots when received JSON contains some null values
- [x] Implement midstate sha256
- [x] Bug Wificlient DNS unresolved on Wifi.h
- [x] Code refactoring
- [x] Add blockHeight to screen
- [x] Add clock to show current time
- [x] Add new screen with global mining stats
- [x] Add pool support for low difficulty miners
- [x] Add best difficulty on miner screen
- [x] Add suport to standard ESP32 dev-kit / ESP32-WROOM
- [x] Code changes to support adding multiple boards
- [x] Add support to TTGO T-display 1.14
- [x] Add support to Amoled
- [x] Move project to platformIO
- [x] Bug rectangle on screen when 1milion shares
- [x] Bug memory leaks
- [x] Bug Reboots when received JSON contains some null values
- [x] Implement midstate sha256
- [x] Bug Wificlient DNS unresolved on Wifi.h
- [x] Code refactoring
- [x] Add blockHeight to screen
- [x] Add clock to show current time
- [x] Add new screen with global mining stats
- [x] Add pool support for low difficulty miners
- [x] Add best difficulty on miner screen
- [x] Add suport to standard ESP32 dev-kit / ESP32-WROOM
- [x] Code changes to support adding multiple boards
- [x] Add support to TTGO T-display 1.14
- [x] Add support to Amoled
### On process
- [ ] Create a daisy chain protocol via UART or I2C to support ESP32 hashboards
- [ ] Create new screen like clockMiner but with BTC price
- [ ] Add support to control BM1397
- [ ] Create a daisy chain protocol via UART or I2C to support ESP32 hashboards
- [ ] Create new screen like clockMiner but with BTC price
- [ ] Add support to control BM1397
- [ ] Add password field in web configuration form
### Donations/Project contributions
If you would like to contribute and help dev team with this project you can send a donation to the following LN address ⚡teamnerdminer@getalby.com⚡ or using one of the affiliate links above.
If you want to order a fully assembled Nerdminer you can contribute to my job at [bitronics.store](https://bitronics.store).
If you want to order a fully assembled Nerdminer you can contribute to my job at 🛒[bitronics.store](https://bitronics.store)🛒
Enjoy

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1014 KiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 KiB

View File

@ -10,9 +10,100 @@
[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, M5-StampS3, ESP32-S3-devKitv1, ESP32-S3-mini-wemos, ESP32-S3-mini-weact
;--------------------------------------------------------------------
[env:ESP32-S3-mini-wemos]
platform = espressif32
board = lolin_s3_mini
framework = arduino
monitor_filters =
esp32_exception_decoder
time
log2file
board_build.arduino.memory_type = qio_opi
monitor_speed = 115200
upload_speed = 115200
board_build.partitions = huge_app.csv
build_flags =
-D BOARD_HAS_PSRAM
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
-D S3MINIWEMOS=1
;-D DEBUG_MINING=1
lib_deps =
https://github.com/takkaO/OpenFontRender
bblanchon/ArduinoJson@^6.21.2
https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.2
mathertel/OneButton @ ^2.0.3
arduino-libraries/NTPClient
https://github.com/FastLED/FastLED
lib_ignore =
TFT_eSPI
;--------------------------------------------------------------------
;--------------------------------------------------------------------
[env:ESP32-S3-mini-weact]
platform = espressif32
board = lolin_s3_mini
framework = arduino
monitor_filters =
esp32_exception_decoder
time
log2file
board_build.arduino.memory_type = qio_opi
monitor_speed = 115200
upload_speed = 115200
board_build.partitions = huge_app.csv
build_flags =
-D BOARD_HAS_PSRAM
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
-D S3MINIWEACT=1
;-D DEBUG_MINING=1
lib_deps =
https://github.com/takkaO/OpenFontRender
bblanchon/ArduinoJson@^6.21.2
https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.2
mathertel/OneButton @ ^2.0.3
arduino-libraries/NTPClient
https://github.com/FastLED/FastLED
lib_ignore =
TFT_eSPI
;--------------------------------------------------------------------
[env:ESP32-S3-devKitv1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_filters =
esp32_exception_decoder
time
log2file
board_build.arduino.memory_type = qio_opi
monitor_speed = 115200
upload_speed = 115200
board_build.partitions = huge_app.csv
build_flags =
-D BOARD_HAS_PSRAM
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
-D DEVKITV1RGB=1
;-D DEBUG_MINING=1
lib_deps =
https://github.com/takkaO/OpenFontRender
bblanchon/ArduinoJson@^6.21.2
https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.2
mathertel/OneButton @ ^2.0.3
arduino-libraries/NTPClient
https://github.com/FastLED/FastLED
lib_ignore =
TFT_eSPI
;--------------------------------------------------------------------
[env:NerminerV2]
platform = espressif32
@ -126,6 +217,8 @@ build_flags =
-DNERMINER_S3_DONGLE
-DBOARD_HAS_PSRAM
-DARDUINO_USB_CDC_ON_BOOT
-DTFT_BACKLIGHT_ON=LOW
-DTFT_BL=38
lib_deps =
https://github.com/takkaO/OpenFontRender
bblanchon/ArduinoJson@^6.21.2
@ -256,3 +349,31 @@ lib_deps =
https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.2
mathertel/OneButton @ ^2.0.3
https://github.com/arduino-libraries/NTPClient
;--------------------------------------------------------------------
[env:M5-StampS3]
platform = espressif32
board = m5stack-stamps3
framework = arduino
monitor_filters =
esp32_exception_decoder
time
log2file
monitor_speed = 115200
upload_speed = 115200
board_build.partitions = huge_app.csv
build_flags =
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
-D M5_STAMP_S3=1
lib_deps =
bblanchon/ArduinoJson@^6.21.2
https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.2
mathertel/OneButton @ ^2.0.3
arduino-libraries/NTPClient
lib_ignore =
TFT_eSPI
SD
rm67162
SPI

View File

@ -0,0 +1,398 @@
/************************************************************************************
* written by: Bitmaker
* based on: Blockstream Jade shaLib
* thanks to @LarryBitcoin
* Description:
* NerdSha256plus is a custom C implementation of sha256d based on Blockstream Jade
code https://github.com/Blockstream/Jade
The folowing file can be used on any ESP32 implementation using both cores
*************************************************************************************/
#define NDEBUG
#include <stdio.h>
#include <string.h>
#include <Arduino.h>
#include <esp_log.h>
#include <esp_timer.h>
#include "nerdSHA256plus.h"
#include <math.h>
#include <string.h>
#define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n)))
#ifndef PUT_UINT32_BE
#define PUT_UINT32_BE(n, data, offset) \
{ \
u.num = n; \
p = (data) + (offset); \
*p = u.b[3]; \
*(p + 1) = u.b[2]; \
*(p + 2) = u.b[1]; \
*(p + 3) = u.b[0]; \
}
#endif
#ifndef GET_UINT32_BE
#define GET_UINT32_BE(b, i) \
(((uint32_t)(b)[(i)] << 24) | ((uint32_t)(b)[(i) + 1] << 16) | ((uint32_t)(b)[(i) + 2] << 8) \
| ((uint32_t)(b)[(i) + 3]))
#endif
//DRAM_ATTR static const uint32_t K[] = {
DRAM_ATTR static const uint32_t K[64] = {
0x428A2F98L, 0x71374491L, 0xB5C0FBCFL, 0xE9B5DBA5L, 0x3956C25BL,
0x59F111F1L, 0x923F82A4L, 0xAB1C5ED5L, 0xD807AA98L, 0x12835B01L,
0x243185BEL, 0x550C7DC3L, 0x72BE5D74L, 0x80DEB1FEL, 0x9BDC06A7L,
0xC19BF174L, 0xE49B69C1L, 0xEFBE4786L, 0x0FC19DC6L, 0x240CA1CCL,
0x2DE92C6FL, 0x4A7484AAL, 0x5CB0A9DCL, 0x76F988DAL, 0x983E5152L,
0xA831C66DL, 0xB00327C8L, 0xBF597FC7L, 0xC6E00BF3L, 0xD5A79147L,
0x06CA6351L, 0x14292967L, 0x27B70A85L, 0x2E1B2138L, 0x4D2C6DFCL,
0x53380D13L, 0x650A7354L, 0x766A0ABBL, 0x81C2C92EL, 0x92722C85L,
0xA2BFE8A1L, 0xA81A664BL, 0xC24B8B70L, 0xC76C51A3L, 0xD192E819L,
0xD6990624L, 0xF40E3585L, 0x106AA070L, 0x19A4C116L, 0x1E376C08L,
0x2748774CL, 0x34B0BCB5L, 0x391C0CB3L, 0x4ED8AA4AL, 0x5B9CCA4FL,
0x682E6FF3L, 0x748F82EEL, 0x78A5636FL, 0x84C87814L, 0x8CC70208L,
0x90BEFFFAL, 0xA4506CEBL, 0xBEF9A3F7L, 0xC67178F2L
};
#define SHR(x, n) ((x & 0xFFFFFFFF) >> n)
#define S0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
#define S1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
#define F0(x, y, z) ((x & y) | (z & (x | y)))
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define R(t) (W[t] = S1(W[t - 2]) + W[t - 7] + S0(W[t - 15]) + W[t - 16])
#define P(a, b, c, d, e, f, g, h, x, K) \
{ \
temp1 = h + S3(e) + F1(e, f, g) + K + x; \
temp2 = S2(a) + F0(a, b, c); \
d += temp1; \
h = temp1 + temp2; \
}
uint32_t rotlFixed(uint32_t x, uint32_t y)
{
return (x << y) | (x >> (sizeof(y) * 8 - y));
}
uint32_t ByteReverseWord32(uint32_t value){
value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8);
return rotlFixed(value, 16U);
}
void ByteReverseWords(uint32_t* out, const uint32_t* in, uint32_t byteCount)
{
uint32_t count, i;
count = byteCount/(uint32_t)sizeof(uint32_t);
for (i = 0; i < count; i++) out[i] = ByteReverseWord32(in[i]);
}
IRAM_ATTR void nerd_mids(nerdSHA256_context* midstate, uint8_t* dataIn)
{
uint32_t A[8] = { 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 };
uint32_t temp1, temp2, W[64];
uint8_t i;
W[0] = GET_UINT32_BE(dataIn, 0);
W[1] = GET_UINT32_BE(dataIn, 4);
W[2] = GET_UINT32_BE(dataIn, 8);
W[3] = GET_UINT32_BE(dataIn, 12);
W[4] = GET_UINT32_BE(dataIn, 16);
W[5] = GET_UINT32_BE(dataIn, 20);
W[6] = GET_UINT32_BE(dataIn, 24);
W[7] = GET_UINT32_BE(dataIn, 28);
W[8] = GET_UINT32_BE(dataIn, 32);
W[9] = GET_UINT32_BE(dataIn, 36);
W[10] = GET_UINT32_BE(dataIn, 40);
W[11] = GET_UINT32_BE(dataIn, 44);
W[12] = GET_UINT32_BE(dataIn, 48);
W[13] = GET_UINT32_BE(dataIn, 52);
W[14] = GET_UINT32_BE(dataIn, 56);
W[15] = GET_UINT32_BE(dataIn, 60);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[0], K[0]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[1], K[1]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[2], K[2]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[3], K[3]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[4], K[4]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[5], K[5]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[6], K[6]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[7], K[7]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[8], K[8]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[9], K[9]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[10], K[10]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[11], K[11]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[12], K[12]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[13], K[13]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[14], K[14]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[15], K[15]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(16), K[16]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(17), K[17]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(18), K[18]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(19), K[19]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(20), K[20]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(21), K[21]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(22), K[22]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(23), K[23]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(24), K[24]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(25), K[25]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(26), K[26]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(27), K[27]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(28), K[28]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(29), K[29]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(30), K[30]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(31), K[31]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(32), K[32]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(33), K[33]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(34), K[34]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(35), K[35]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(36), K[36]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(37), K[37]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(38), K[38]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(39), K[39]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(40), K[40]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(41), K[41]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(42), K[42]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(43), K[43]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(44), K[44]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(45), K[45]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(46), K[46]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(47), K[47]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(48), K[48]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(49), K[49]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(50), K[50]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(51), K[51]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(52), K[52]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(53), K[53]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(54), K[54]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(55), K[55]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(56), K[56]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(57), K[57]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(58), K[58]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(59), K[59]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(60), K[60]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(61), K[61]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(62), K[62]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(63), K[63]);
midstate->digest[0] = 0x6A09E667 + A[0];
midstate->digest[1] = 0xBB67AE85 + A[1];
midstate->digest[2] = 0x3C6EF372 + A[2];
midstate->digest[3] = 0xA54FF53A + A[3];
midstate->digest[4] = 0x510E527F + A[4];
midstate->digest[5] = 0x9B05688C + A[5];
midstate->digest[6] = 0x1F83D9AB + A[6];
midstate->digest[7] = 0x5BE0CD19 + A[7];
}
IRAM_ATTR bool nerd_sha256d(nerdSHA256_context* midstate, uint8_t* dataIn, uint8_t* doubleHash)
{
uint32_t temp1, temp2;
uint8_t temp3, temp4;
uint32_t* buffer32;
//*********** Init 1rst SHA ***********
uint32_t W[16] = { GET_UINT32_BE(dataIn, 0), GET_UINT32_BE(dataIn, 4),
GET_UINT32_BE(dataIn, 8), GET_UINT32_BE(dataIn, 12), 0x80000000, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 640};
uint32_t A[8] = { midstate->digest[0], midstate->digest[1], midstate->digest[2], midstate->digest[3],
midstate->digest[4], midstate->digest[5], midstate->digest[6], midstate->digest[7] };
union {
uint32_t num;
uint8_t b[4];
} u;
uint8_t* p = NULL;
uint8_t i;
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[0], K[0]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[1], K[1]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[2], K[2]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[3], K[3]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[4], K[4]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[5], K[5]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[6], K[6]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[7], K[7]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[8], K[8]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[9], K[9]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[10], K[10]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[11], K[11]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[12], K[12]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[13], K[13]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[14], K[14]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[15], K[15]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(16), K[16]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(17), K[17]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(18), K[18]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(19), K[19]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(20), K[20]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(21), K[21]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(22), K[22]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(23), K[23]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(24), K[24]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(25), K[25]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(26), K[26]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(27), K[27]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(28), K[28]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(29), K[29]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(30), K[30]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(31), K[31]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(32), K[32]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(33), K[33]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(34), K[34]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(35), K[35]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(36), K[36]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(37), K[37]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(38), K[38]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(39), K[39]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(40), K[40]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(41), K[41]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(42), K[42]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(43), K[43]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(44), K[44]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(45), K[45]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(46), K[46]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(47), K[47]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(48), K[48]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(49), K[49]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(50), K[50]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(51), K[51]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(52), K[52]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(53), K[53]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(54), K[54]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(55), K[55]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(56), K[56]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(57), K[57]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(58), K[58]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(59), K[59]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(60), K[60]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(61), K[61]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(62), K[62]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(63), K[63]);
//*********** end SHA_finish ***********
/* Calculate the second hash (double SHA-256) */
W[0] = A[0] + midstate->digest[0];
W[1] = A[1] + midstate->digest[1];
W[2] = A[2] + midstate->digest[2];
W[3] = A[3] + midstate->digest[3];
W[4] = A[4] + midstate->digest[4];
W[5] = A[5] + midstate->digest[5];
W[6] = A[6] + midstate->digest[6];
W[7] = A[7] + midstate->digest[7];
W[8] = 0x80000000;
W[9] = 0;
W[10] = 0;
W[11] = 0;
W[12] = 0;
W[13] = 0;
W[14] = 0;
W[15] = 256;
A[0] = 0x6A09E667;
A[1] = 0xBB67AE85;
A[2] = 0x3C6EF372;
A[3] = 0xA54FF53A;
A[4] = 0x510E527F;
A[5] = 0x9B05688C;
A[6] = 0x1F83D9AB;
A[7] = 0x5BE0CD19;
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[0], K[0]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[1], K[1]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[2], K[2]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[3], K[3]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[4], K[4]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[5], K[5]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[6], K[6]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[7], K[7]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[8], K[8]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[9], K[9]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[10], K[10]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[11], K[11]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[12], K[12]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[13], K[13]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[14], K[14]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[15], K[15]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(16), K[16]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(17), K[17]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(18), K[18]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(19), K[19]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(20), K[20]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(21), K[21]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(22), K[22]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(23), K[23]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(24), K[24]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(25), K[25]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(26), K[26]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(27), K[27]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(28), K[28]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(29), K[29]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(30), K[30]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(31), K[31]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(32), K[32]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(33), K[33]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(34), K[34]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(35), K[35]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(36), K[36]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(37), K[37]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(38), K[38]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(39), K[39]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(40), K[40]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(41), K[41]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(42), K[42]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(43), K[43]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(44), K[44]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(45), K[45]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(46), K[46]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(47), K[47]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(48), K[48]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(49), K[49]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(50), K[50]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(51), K[51]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(52), K[52]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(53), K[53]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(54), K[54]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(55), K[55]);
P(A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(56), K[56]);
P(A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(57), K[57]);
P(A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(58), K[58]);
P(A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(59), K[59]);
P(A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(60), K[60]);
P(A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(61), K[61]);
P(A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(62), K[62]);
P(A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(63), K[63]);
PUT_UINT32_BE(0x5BE0CD19 + A[7], doubleHash, 28);
if(doubleHash[31] !=0 || doubleHash[30] !=0) return false;
PUT_UINT32_BE(0x6A09E667 + A[0], doubleHash, 0);
PUT_UINT32_BE(0xBB67AE85 + A[1], doubleHash, 4);
PUT_UINT32_BE(0x3C6EF372 + A[2], doubleHash, 8);
PUT_UINT32_BE(0xA54FF53A + A[3], doubleHash, 12);
PUT_UINT32_BE(0x510E527F + A[4], doubleHash, 16);
PUT_UINT32_BE(0x9B05688C + A[5], doubleHash, 20);
PUT_UINT32_BE(0x1F83D9AB + A[6], doubleHash, 24);
return true;
}

View File

@ -0,0 +1,34 @@
/************************************************************************************
* written by: Bitmaker
* based on: Blockstream Jade shaLib
* thanks to @LarryBitcoin
* Description:
* NerdSha256plus is a custom C implementation of sha256d based on Blockstream Jade
code https://github.com/Blockstream/Jade
The folowing file can be used on any ESP32 implementation using both cores
*************************************************************************************/
#ifndef nerdSHA256plus_H_
#define nerdSHA256plus_H_
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
struct nerdSHA256_context {
uint8_t buffer[64];
uint32_t digest[8];
};
/* Calculate midstate */
IRAM_ATTR void nerd_mids(nerdSHA256_context* midstate, uint8_t* dataIn);
IRAM_ATTR bool nerd_sha256d(nerdSHA256_context* midstate, uint8_t* dataIn, uint8_t* doubleHash);
void ByteReverseWords(uint32_t* out, const uint32_t* in, uint32_t byteCount);
#endif /* nerdSHA256plus_H_ */

View File

@ -19,6 +19,14 @@
#include "lilygoV1TDisplay.h"
#elif defined(ESP32_CAM)
#include "esp32CAM.h"
#elif defined(M5_STAMP_S3)
#include "m5StampS3.h"
#elif defined(DEVKITV1RGB)
#include "esp32DevKitRGB.h"
#elif defined(S3MINIWEMOS)
#include "esp32S3MiniWemos.h"
#elif defined(S3MINIWEACT)
#include "esp32S3MiniWeact.h"
#else
#error "No device defined"

View File

@ -4,7 +4,7 @@
#define PIN_BUTTON_1 0
#define LED_PIN 33
#define DONGLE_DISPLAY // NO_DISPLAY
#define NO_DISPLAY
// example how to configure SD card.
// if you would define everything,

View File

@ -0,0 +1,10 @@
#ifndef _ESP32_DEV_KIT_RGB_H
#define _ESP32_DEV_KIT_RGB_H
#define PIN_BUTTON_1 0
#define RGB_LED_PIN 48
#define LED_DISPLAY
#define USE_LED
#endif

View File

@ -0,0 +1,10 @@
#ifndef _ESP32_S3_MINI_WEACT_H
#define _ESP32_S3_MINI_WEACT_H
#define PIN_BUTTON_1 0
#define RGB_LED_PIN 48
#define LED_DISPLAY
#define USE_LED
#endif

View File

@ -0,0 +1,10 @@
#ifndef _ESP32_S3_MINI_WEMOS_H
#define _ESP32_S3_MINI_WEMOS_H
#define PIN_BUTTON_1 0
#define RGB_LED_PIN 47
#define LED_DISPLAY
#define USE_LED
#endif

View File

@ -0,0 +1,9 @@
#ifndef _M5_STAMP_S3_H
#define _M5_STAMP_S3_H
#define PIN_BUTTON_1 0
#define LED_PIN 9
#define NO_DISPLAY
#endif

View File

@ -1,4 +1,4 @@
#include "DisplayDriver.h"
#include "displayDriver.h"
#ifdef AMOLED_DISPLAY
@ -243,4 +243,4 @@ DisplayDriver amoledDisplayDriver = {
0,
WIDTH,
HEIGHT};
#endif
#endif

View File

@ -4,6 +4,10 @@
DisplayDriver *currentDisplayDriver = &noDisplayDriver;
#endif
#ifdef LED_DISPLAY
DisplayDriver *currentDisplayDriver = &ledDisplayDriver;
#endif
#ifdef T_DISPLAY
DisplayDriver *currentDisplayDriver = &tDisplayDriver;
#endif

View File

@ -1,7 +1,7 @@
#ifndef DISPLAY_H
#define DISPLAY_H
#include "DisplayDriver.h"
#include "displayDriver.h"
extern DisplayDriver *currentDisplayDriver;

View File

@ -29,6 +29,7 @@ typedef struct
extern DisplayDriver *currentDisplayDriver;
extern DisplayDriver noDisplayDriver;
extern DisplayDriver ledDisplayDriver;
extern DisplayDriver tDisplayDriver;
extern DisplayDriver amoledDisplayDriver;
extern DisplayDriver dongleDisplayDriver;

View File

@ -1,4 +1,4 @@
#include "DisplayDriver.h"
#include "displayDriver.h"
#ifdef DONGLE_DISPLAY
@ -103,6 +103,9 @@ void dongleDisplay_Init(void)
void dongleDisplay_AlternateScreenState(void)
{
int screen_state = digitalRead(TFT_BL);
Serial.println("Switching display state");
digitalWrite(TFT_BL, !screen_state);
}
void dongleDisplay_AlternateRotation(void)
@ -169,6 +172,12 @@ void dongleDisplay_AnimateCurrentScreen(unsigned long frame)
void dongleDisplay_DoLedStuff(unsigned long frame)
{
#ifdef USE_LED
if (digitalRead(TFT_BL))
{
FastLED.clear(true);
return;
}
switch (mMonitor.NerdStatus)
{
case NM_waitingConfig:
@ -216,4 +225,4 @@ DisplayDriver dongleDisplayDriver = {
WIDTH,
HEIGHT};
#endif
#endif

View File

@ -1,4 +1,4 @@
#include "DisplayDriver.h"
#include "displayDriver.h"
#ifdef ESP32_2432S028R
@ -356,6 +356,68 @@ void esp32_2432S028R_GlobalHashScreen(unsigned long mElapsed)
printheap();
#endif
}
void esp32_2432S028R_BTCprice(unsigned long mElapsed)
{
if (hasChangedScreen) tft.pushImage(0, 0, priceScreenWidth, priceScreenHeight, priceScreen);
hasChangedScreen = false;
clock_data data = getClockData(mElapsed);
Serial.printf(">>> Completed %s share(s), %s Khashes, avg. hashrate %s KH/s\n",
data.completedShares.c_str(), data.totalKHashes.c_str(), data.currentHashRate.c_str());
// Create background sprite to print data at once
createBackgroundSprite(270,36);
// Print background screen
background.pushImage(0, -130, priceScreenWidth, priceScreenHeight, priceScreen);
// Hashrate
render.setFontSize(25);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 95, 0, TFT_BLACK);
// Print BlockHeight
render.setFontSize(18);
render.rdrawString(data.blockHeight.c_str(), 254, 9, TFT_WHITE);
// Push prepared background to screen
background.pushSprite(0, 130);
// Delete sprite to free the memory heap
background.deleteSprite();
createBackgroundSprite(169,105);
// Print background screen
background.pushImage(-130, -3, priceScreenWidth, priceScreenHeight, priceScreen);
// Print BTC Price
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.currentTime.c_str(), 202-130, 0, GFXFF);
// Print Hour
background.setFreeFont(FF22);
background.setTextSize(2);
background.setTextColor(0xDEDB, TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 0, 50, GFXFF);
// Push prepared background to screen
background.pushSprite(130, 3);
// Delete sprite to free the memory heap
background.deleteSprite();
#ifdef ESP32_2432S028R
printPoolData();
#endif
#ifdef DEBUG_MEMORY
// Print heap
printheap();
#endif
}
void esp32_2432S028R_LoadingScreen(void)
{
@ -443,7 +505,7 @@ void esp32_2432S028R_DoLedStuff(unsigned long frame)
}
CyclicScreenFunction esp32_2432S028RCyclicScreens[] = {esp32_2432S028R_MinerScreen, esp32_2432S028R_ClockScreen, esp32_2432S028R_GlobalHashScreen};
CyclicScreenFunction esp32_2432S028RCyclicScreens[] = {esp32_2432S028R_MinerScreen, esp32_2432S028R_ClockScreen, esp32_2432S028R_GlobalHashScreen, esp32_2432S028R_BTCprice};
DisplayDriver esp32_2432S028RDriver = {
esp32_2432S028R_Init,
@ -458,4 +520,4 @@ DisplayDriver esp32_2432S028RDriver = {
0,
WIDTH,
HEIGHT};
#endif
#endif

View File

@ -0,0 +1,138 @@
#include "displayDriver.h"
#ifdef LED_DISPLAY
#include <Arduino.h>
#include "monitor.h"
#include "wManager.h"
#ifdef USE_LED
#include <FastLED.h>
#endif
#ifdef USE_LED
#define MAX_BRIGHTNESS 16
#define SLOW_FADE 1;
#define FAST_FADE 4;
CRGB leds(0, 0, 0);
int brightness = 0;
int fadeDirection = 1;
int fadeAmount = 0;
#endif // USE_LED
bool ledOn = false;
extern monitor_data mMonitor;
void ledDisplay_Init(void)
{
Serial.println("Led display driver initialized");
#ifdef USE_LED
FastLED.addLeds<WS2812B, RGB_LED_PIN, BGR>(&leds, 1);
FastLED.show();
#endif // USE_LED
}
void ledDisplay_AlternateScreenState(void)
{
Serial.println("Switching display state");
ledOn = !ledOn;
}
void ledDisplay_AlternateRotation(void)
{
}
void ledDisplay_NoScreen(unsigned long mElapsed)
{
mining_data data = getMiningData(mElapsed);
// Print hashrate to serial
Serial.printf(">>> Completed %s share(s), %s Khashes, avg. hashrate %s KH/s\n",
data.completedShares.c_str(), data.totalKHashes.c_str(), data.currentHashRate.c_str());
// Print extended data to serial for no display devices
Serial.printf(">>> Valid blocks: %s\n", data.valids.c_str());
Serial.printf(">>> Block templates: %s\n", data.templates.c_str());
Serial.printf(">>> Best difficulty: %s\n", data.bestDiff.c_str());
Serial.printf(">>> 32Bit shares: %s\n", data.completedShares.c_str());
Serial.printf(">>> Temperature: %s\n", data.temp.c_str());
Serial.printf(">>> Total MHashes: %s\n", data.totalMHashes.c_str());
Serial.printf(">>> Time mining: %s\n", data.timeMining.c_str());
}
void ledDisplay_LoadingScreen(void)
{
Serial.println("Initializing...");
}
void ledDisplay_SetupScreen(void)
{
Serial.println("Setup...");
}
// Variables para controlar el parpadeo con millis()
unsigned long previousMillis = 0;
void ledDisplay_DoLedStuff(unsigned long frame)
{
#ifdef USE_LED
if (!ledOn)
{
FastLED.clear(true);
return;
}
switch (mMonitor.NerdStatus)
{
case NM_waitingConfig:
brightness = MAX_BRIGHTNESS;
leds.setRGB(255, 255, 0);
fadeAmount = 0;
break;
case NM_Connecting:
leds.setRGB(0, 0, 255);
fadeAmount = SLOW_FADE;
break;
case NM_hashing:
leds.setRGB(0, 0, 255);
fadeAmount = FAST_FADE;
break;
}
leds.fadeLightBy(0xFF - brightness);
FastLED.show();
brightness = brightness + (fadeDirection * fadeAmount);
if (brightness <= 0 || brightness >= MAX_BRIGHTNESS)
{
fadeDirection = -fadeDirection;
}
brightness = constrain(brightness, 0, MAX_BRIGHTNESS);
#endif
}
void ledDisplay_AnimateCurrentScreen(unsigned long frame)
{
}
CyclicScreenFunction ledDisplayCyclicScreens[] = {ledDisplay_NoScreen};
DisplayDriver ledDisplayDriver = {
ledDisplay_Init,
ledDisplay_AlternateScreenState,
ledDisplay_AlternateRotation,
ledDisplay_LoadingScreen,
ledDisplay_SetupScreen,
ledDisplayCyclicScreens,
ledDisplay_AnimateCurrentScreen,
ledDisplay_DoLedStuff,
SCREENS_ARRAY_SIZE(ledDisplayCyclicScreens),
0,
0,
0,
};
#endif

View File

@ -1,4 +1,4 @@
#include "DisplayDriver.h"
#include "displayDriver.h"
#ifdef NO_DISPLAY
@ -101,4 +101,4 @@ DisplayDriver noDisplayDriver = {
0,
0,
};
#endif
#endif

View File

@ -1,4 +1,4 @@
#include "DisplayDriver.h"
#include "displayDriver.h"
#ifdef T_DISPLAY
@ -195,6 +195,49 @@ void tDisplay_GlobalHashScreen(unsigned long mElapsed)
background.pushSprite(0, 0);
}
void tDisplay_BTCprice(unsigned long mElapsed)
{
clock_data data = getClockData(mElapsed);
data.currentDate ="01/12/2023";
//if(data.currentDate.indexOf("12/2023")>) { tDisplay_ChristmasContent(data); return; }
// Print background screen
background.pushImage(0, 0, priceScreenWidth, priceScreenHeight, priceScreen);
Serial.printf(">>> Completed %s share(s), %s Khashes, avg. hashrate %s KH/s\n",
data.completedShares.c_str(), data.totalKHashes.c_str(), data.currentHashRate.c_str());
// Hashrate
render.setFontSize(25);
render.setCursor(19, 122);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 94, 129, TFT_BLACK);
// Print BlockHeight
render.setFontSize(18);
render.rdrawString(data.blockHeight.c_str(), 254, 138, TFT_WHITE);
// Print Hour
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.currentTime.c_str(), 222, 3, GFXFF);
// Print BTC Price
background.setFreeFont(FF24);
background.setTextDatum(TR_DATUM);
background.setTextSize(1);
background.setTextColor(0xDEDB, TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 300, 58, GFXFF);
// Push prepared background to screen
background.pushSprite(0, 0);
}
void tDisplay_LoadingScreen(void)
{
tft.fillScreen(TFT_BLACK);
@ -216,7 +259,7 @@ void tDisplay_DoLedStuff(unsigned long frame)
{
}
CyclicScreenFunction tDisplayCyclicScreens[] = {tDisplay_MinerScreen, tDisplay_ClockScreen, tDisplay_GlobalHashScreen};
CyclicScreenFunction tDisplayCyclicScreens[] = {tDisplay_MinerScreen, tDisplay_ClockScreen, tDisplay_GlobalHashScreen, tDisplay_BTCprice};
DisplayDriver tDisplayDriver = {
tDisplay_Init,
@ -231,4 +274,4 @@ DisplayDriver tDisplayDriver = {
0,
WIDTH,
HEIGHT};
#endif
#endif

View File

@ -1,4 +1,4 @@
#include "DisplayDriver.h"
#include "displayDriver.h"
#ifdef V1_DISPLAY
@ -96,7 +96,6 @@ void tDisplay_MinerScreen(unsigned long mElapsed)
// Push prepared background to screen
background.pushSprite(0, 0);
background.deleteSprite();
}
void tDisplay_ClockScreen(unsigned long mElapsed)
@ -135,7 +134,6 @@ void tDisplay_ClockScreen(unsigned long mElapsed)
// Push prepared background to screen
background.pushSprite(0, 0);
background.deleteSprite();
}
void tDisplay_GlobalHashScreen(unsigned long mElapsed)
@ -195,7 +193,44 @@ void tDisplay_GlobalHashScreen(unsigned long mElapsed)
// Push prepared background to screen
background.pushSprite(0, 0);
background.deleteSprite();
}
void tDisplay_BTCprice(unsigned long mElapsed)
{
clock_data data = getClockData(mElapsed);
// Print background screen
background.pushImage(0, 0, priceScreenWidth, priceScreenHeight, priceScreen);
Serial.printf(">>> Completed %s share(s), %s Khashes, avg. hashrate %s KH/s\n",
data.completedShares.c_str(), data.totalKHashes.c_str(), data.currentHashRate.c_str());
// Hashrate
render.setFontSize(25);
render.setCursor(19, 122);
render.setFontColor(TFT_BLACK);
render.rdrawString(data.currentHashRate.c_str(), 70, 103, TFT_BLACK);
// Print BlockHeight
render.setFontSize(18);
render.rdrawString(data.blockHeight.c_str(), 190, 110, TFT_WHITE);
// Print Hour
background.setFreeFont(FSSB9);
background.setTextSize(1);
background.setTextDatum(TL_DATUM);
background.setTextColor(TFT_BLACK);
background.drawString(data.currentTime.c_str(), 148, 1, GFXFF);
// Print BTC Price
background.setFreeFont(FF24);
background.setTextDatum(TR_DATUM);
background.setTextSize(1);
background.setTextColor(0xDEDB, TFT_BLACK);
background.drawString(data.btcPrice.c_str(), 70, 25, GFXFF);
// Push prepared background to screen
background.pushSprite(0, 0);
}
void tDisplay_LoadingScreen(void)
@ -234,4 +269,4 @@ DisplayDriver tDisplayV1Driver = {
0,
WIDTH,
HEIGHT};
#endif
#endif

View File

@ -1,4 +1,4 @@
#include "DisplayDriver.h"
#include "displayDriver.h"
#ifdef T_QT_DISPLAY
@ -177,4 +177,4 @@ DisplayDriver t_qtDisplayDriver = {
0,
WIDTH,
HEIGHT};
#endif
#endif

View File

@ -100,6 +100,7 @@ bool SDCard::loadConfigFile(TSettings* Settings)
Settings->WifiSSID = json[JSON_KEY_SSID] | Settings->WifiSSID;
Settings->WifiPW = json[JSON_KEY_PASW] | Settings->WifiPW;
Settings->PoolAddress = json[JSON_KEY_POOLURL] | Settings->PoolAddress;
strcpy(Settings->PoolPassword, json[JSON_KEY_POOLPASS] | Settings->PoolPassword);
strcpy(Settings->BtcWallet, json[JSON_KEY_WALLETID] | Settings->BtcWallet);
if (json.containsKey(JSON_KEY_POOLPORT))
Settings->PoolPort = json[JSON_KEY_POOLPORT].as<int>();

View File

@ -27,9 +27,12 @@
#include <SPI.h>
#include <SD.h>
#include "..\lib\TFT_eSPI\User_Setup_Select.h"
#ifndef NO_DISPLAY
#if !defined(NO_DISPLAY)
#include "..\lib\TFT_eSPI\User_Setup_Select.h"
#endif
#if !defined(NO_DISPLAY) && !defined(LED_DISPLAY)
#if !defined(SDSPI_CLK) && defined(TFT_CLK)
#define SDSPI_CLK TFT_CLK
#endif // SDSPI_CLK
@ -41,7 +44,7 @@
#endif // SDSPI_MISO
#elif !defined(SDSPI_CLK) || !defined(SDSPI_MOSI) || !defined(SDSPI_MISO)
#error: Please define SDSPI pins!
#endif // NO_DISPLAY
#endif // NO_DISPLAY or LED_DISPLAY
#warning SD card support in SPI mode enabled!
#endif

View File

@ -31,6 +31,7 @@ bool nvMemory::saveConfig(TSettings* Settings)
StaticJsonDocument<512> json;
json[JSON_SPIFFS_KEY_POOLURL] = Settings->PoolAddress;
json[JSON_SPIFFS_KEY_POOLPORT] = Settings->PoolPort;
json[JSON_SPIFFS_KEY_POOLPASS] = Settings->PoolPassword;
json[JSON_SPIFFS_KEY_WALLETID] = Settings->BtcWallet;
json[JSON_SPIFFS_KEY_TIMEZONE] = Settings->Timezone;
json[JSON_SPIFFS_KEY_STATS2NV] = Settings->saveStats;
@ -88,6 +89,7 @@ bool nvMemory::loadConfig(TSettings* Settings)
if (!error)
{
Settings->PoolAddress = json[JSON_SPIFFS_KEY_POOLURL] | Settings->PoolAddress;
strcpy(Settings->PoolPassword, json[JSON_SPIFFS_KEY_POOLPASS] | Settings->PoolPassword);
strcpy(Settings->BtcWallet, json[JSON_SPIFFS_KEY_WALLETID] | Settings->BtcWallet);
if (json.containsKey(JSON_SPIFFS_KEY_POOLPORT))
Settings->PoolPort = json[JSON_SPIFFS_KEY_POOLPORT].as<int>();

View File

@ -9,6 +9,7 @@
#define DEFAULT_SSID "NerdMinerAP"
#define DEFAULT_WIFIPW "MineYourCoins"
#define DEFAULT_POOLURL "public-pool.io"
#define DEFAULT_POOLPASS "x"
#define DEFAULT_WALLETID "yourBtcAddress"
#define DEFAULT_POOLPORT 21496
#define DEFAULT_TIMEZONE 2
@ -21,6 +22,7 @@
#define JSON_KEY_SSID "SSID"
#define JSON_KEY_PASW "WifiPW"
#define JSON_KEY_POOLURL "PoolUrl"
#define JSON_KEY_POOLPASS "PoolPassword"
#define JSON_KEY_WALLETID "BtcWallet"
#define JSON_KEY_POOLPORT "PoolPort"
#define JSON_KEY_TIMEZONE "Timezone"
@ -29,6 +31,7 @@
// JSON config file SPIFFS (different for backward compatibility with existing devices)
#define JSON_SPIFFS_KEY_POOLURL "poolString"
#define JSON_SPIFFS_KEY_POOLPORT "portNumber"
#define JSON_SPIFFS_KEY_POOLPASS "poolPassword"
#define JSON_SPIFFS_KEY_WALLETID "btcString"
#define JSON_SPIFFS_KEY_TIMEZONE "gmtZone"
#define JSON_SPIFFS_KEY_STATS2NV "saveStatsToNVS"
@ -40,6 +43,7 @@ struct TSettings
String WifiPW{ DEFAULT_WIFIPW };
String PoolAddress{ DEFAULT_POOLURL };
char BtcWallet[80]{ DEFAULT_WALLETID };
char PoolPassword[80]{ DEFAULT_POOLPASS };
int PoolPort{ DEFAULT_POOLPORT };
int Timezone{ DEFAULT_TIMEZONE };
bool saveStats{ DEFAULT_SAVESTATS };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,8 @@
#include <esp_task_wdt.h>
#include <nvs_flash.h>
#include <nvs.h>
#include "ShaTests/nerdSHA256.h"
//#include "ShaTests/nerdSHA256plus.h"
//#include "ShaTests/nerdSHA256.h"
#include "ShaTests/nerdSHA256plus.h"
#include "stratum.h"
#include "mining.h"
#include "utils.h"
@ -133,26 +133,12 @@ void runStratumWorker(void *name) {
continue;
}
//Test vars:
//************
//Nerdminerpool
// strcpy(poolString, "nerdminerPool");
// portNumber = 3002;
// strcpy(btcString,"test");
//Braiins
//strcpy(poolString, "eu.stratum.braiins.com");
//portNumber = 3333;
//strcpy(btcString,"Bitmaker.01");
//CKpool
//strcpy(poolString, "solo.ckpool.org");
//portNumber = 3333;
//strcpy(btcString,"test");
if(!checkPoolConnection())
if(!checkPoolConnection()){
//If server is not reachable add random delay for connection retries
srand(millis());
//Generate value between 1 and 15 secs
vTaskDelay(((1 + rand() % 15) * 1000) / portTICK_PERIOD_MS);
//Generate value between 1 and 120 secs
vTaskDelay(((1 + rand() % 120) * 1000) / portTICK_PERIOD_MS);
}
if(!isMinerSuscribed){
@ -167,7 +153,7 @@ void runStratumWorker(void *name) {
}
strcpy(mWorker.wName, Settings.BtcWallet);
strcpy(mWorker.wPass, "x");
strcpy(mWorker.wPass, Settings.PoolPassword);
// STEP 2: Pool authorize work (Block Info)
tx_mining_auth(client, mWorker.wName, mWorker.wPass); //Don't verifies authoritzation, TODO
//tx_mining_auth2(client, mWorker.wName, mWorker.wPass); //Don't verifies authoritzation, TODO
@ -256,14 +242,12 @@ void runMiner(void * task_id) {
mMonitor.NerdStatus = NM_hashing;
//Prepare Premining data
nerd_sha256 nerdMidstate;
//nerdSHA256_context nerdMidstate; //NerdShaplus
nerdSHA256_context nerdMidstate; //NerdShaplus
uint8_t hash[32];
//Calcular midstate
nerd_midstate(&nerdMidstate, mMiner.bytearray_blockheader, 64);
//nerd_mids(&nerdMidstate, mMiner.bytearray_blockheader); //NerdShaplus
nerd_mids(&nerdMidstate, mMiner.bytearray_blockheader); //NerdShaplus
// search a valid nonce
@ -290,8 +274,8 @@ void runMiner(void * task_id) {
memcpy(mMiner.bytearray_blockheader2 + 76, &nonce, 4);
nerd_double_sha2(&nerdMidstate, header64, hash);
//is16BitShare=nerd_sha256d(&nerdMidstate, header64, hash); //Boosted 80Khs sha
//nerd_double_sha2(&nerdMidstate, header64, hash);
is16BitShare=nerd_sha256d(&nerdMidstate, header64, hash); //Boosted 80Khs sha
/*Serial.print("hash1: ");
for (size_t i = 0; i < 32; i++)

View File

@ -152,7 +152,7 @@ String getBTCprice(void){
DynamicJsonDocument doc(1024);
deserializeJson(doc, payload);
if (doc.containsKey("bitcoin")) bitcoin_price = doc["bitcoin"]["usd"];
if (doc.containsKey("last_trade_price")) bitcoin_price = doc["last_trade_price"];
doc.clear();
@ -193,6 +193,24 @@ void getTime(unsigned long* currentHours, unsigned long* currentMinutes, unsigne
*currentSeconds = currentTime % 60;
}
String getDate(){
unsigned long elapsedTime = (millis() - mTriggerUpdate) / 1000; // Tiempo transcurrido en segundos
unsigned long currentTime = initialTime + elapsedTime; // La hora actual
// Convierte la hora actual (epoch time) en una estructura tm
struct tm *tm = localtime((time_t *)&currentTime);
int year = tm->tm_year + 1900; // tm_year es el número de años desde 1900
int month = tm->tm_mon + 1; // tm_mon es el mes del año desde 0 (enero) hasta 11 (diciembre)
int day = tm->tm_mday; // tm_mday es el día del mes
char currentDate[20];
sprintf(currentDate, "%02d/%02d/%04d", tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900);
return String(currentDate);
}
String getTime(void){
unsigned long currentHours, currentMinutes, currentSeconds;
getTime(&currentHours, &currentMinutes, &currentSeconds);
@ -248,6 +266,7 @@ clock_data getClockData(unsigned long mElapsed)
data.btcPrice = getBTCprice();
data.blockHeight = getBlockHeight();
data.currentTime = getTime();
data.currentDate = getDate();
return data;
}
@ -341,4 +360,4 @@ pool_data getPoolData(void){
}
}
return pData;
}
}

View File

@ -13,8 +13,8 @@
#define UPDATE_PERIOD_h 5
//API BTC price
#define getBTCAPI "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd"
#define UPDATE_BTC_min 5
#define getBTCAPI "https://api.blockchain.com/v3/exchange/tickers/BTC-USD"
#define UPDATE_BTC_min 1
//API Block height
#define getHeightAPI "https://mempool.space/api/blocks/tip/height"
@ -76,6 +76,7 @@ typedef struct {
String btcPrice;
String blockHeight;
String currentTime;
String currentDate;
}clock_data;
typedef struct {
@ -116,4 +117,4 @@ pool_data getPoolData(void);
clock_data_t getClockData_t(unsigned long mElapsed);
#endif //MONITOR_API_H
#endif //MONITOR_API_H

View File

@ -1,6 +1,6 @@
#ifndef VERSION_H
#define VERSION_H
#define CURRENT_VERSION "V1.6.2"
#define CURRENT_VERSION "V1.6.3"
#endif // VERSION_H

View File

@ -150,10 +150,13 @@ void init_WifiManager()
strcat(checkboxParams, " checked");
}
WiFiManagerParameter save_stats_to_nvs("SaveStatsToNVS", "Track Uptime, Best Diff, Total Hashes in device Flash memory. (Experimental)", "T", 2, checkboxParams, WFM_LABEL_AFTER);
// Text box (String) - 80 characters maximum
WiFiManagerParameter password_text_box("Poolpassword - Optionl", "Pool password", Settings.PoolPassword, 80);
// Add all defined parameters
wm.addParameter(&pool_text_box);
wm.addParameter(&port_text_box_num);
wm.addParameter(&password_text_box);
wm.addParameter(&addr_text_box);
wm.addParameter(&time_text_box_num);
wm.addParameter(&features_html);
@ -173,6 +176,7 @@ void init_WifiManager()
Serial.println("failed to connect and hit timeout");
Settings.PoolAddress = pool_text_box.getValue();
Settings.PoolPort = atoi(port_text_box_num.getValue());
strncpy(Settings.PoolPassword, password_text_box.getValue(), sizeof(Settings.PoolPassword));
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());
@ -223,6 +227,11 @@ void init_WifiManager()
Serial.print("portNumber: ");
Serial.println(Settings.PoolPort);
// Copy the string value
strncpy(Settings.PoolPassword, password_text_box.getValue(), sizeof(Settings.PoolPassword));
Serial.print("poolPassword: ");
Serial.println(Settings.PoolPassword);
// Copy the string value
strncpy(Settings.BtcWallet, addr_text_box.getValue(), sizeof(Settings.BtcWallet));
Serial.print("btcString: ");