Skip to content

Commit

Permalink
V/0.0.14 (#34)
Browse files Browse the repository at this point in the history
* bump build

* introduce reset connection handler

* skipe enqueue for 1 core devices

* add auto update flag

* updated security

* show ip, mac

* add configuration debug print

* add chip info

* new release script

* updated readme

* updated script

* updates

---------

Co-authored-by: Matteo Crippa <[email protected]>
  • Loading branch information
matteocrippa and Matteo Crippa authored Apr 19, 2024
1 parent d0cc742 commit d22d93f
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 19 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,22 @@ jobs:
- name: Archive Artifacts
run: |
mkdir -p artifacts
find .pio/build -name "firmware.bin" -exec sh -c 'cp "{}" "artifacts/firmware_$(basename $(dirname {})).bin"' \;
find .pio/build -name "bootloader.bin" -exec sh -c 'cp "{}" "artifacts/bootloader_$(basename $(dirname {})).bin"' \;
find .pio/build -name "partitions.bin" -exec sh -c 'cp "{}" "artifacts/partitions_$(basename $(dirname {})).bin"' \;
# Define the mapping of board names to file prefixes
declare -A board_map=(
["esp8266"]="0x0000_firmware"
["geekmagic-smalltv"]="0x0000_firmware"
["esp32"]="0x10000_firmware 0x1000_bootloader 0x8000_partitions"
["esp32-s2"]="0x10000_firmware 0x1000_bootloader 0x8000_partitions"
["esp32-s3"]="0x10000_firmware 0x1000_bootloader 0x8000_partitions"
["lilygo-t-display-s3"]="0x10000_firmware 0x1000_bootloader 0x8000_partitions"
)
# Iterate through each board and copy corresponding files
for board in "${!board_map[@]}"; do
for file_type in ${board_map[$board]}; do
find .pio/build -name "${file_type}.bin" -exec sh -c 'cp "{}" "artifacts/'"${board_map[$board]}"'_$(basename $(dirname {})).bin"' \;
done
done
working-directory: ${{ github.workspace }}

- name: Upload Artifacts
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v0.0.13
# v0.0.14

- Investigated issue with reboot on ESP8266
- Add support for disable auto update to WebUI
- Fix WebUI bug for blinking
- Add new build script with address to write the binaries
- Updated readme
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ _Legend_

| Board | Link |
| :------------------------------------------------------- | :----------------------------------------------------------- |
| [ESP8266](https://s.click.aliexpress.com/e/_EuwffHJ) | [0.0.13](https://github.com/matteocrippa/leafminer/releases) |
| [GeekMagic SmartTV]() | [0.0.13](https://github.com/matteocrippa/leafminer/releases) |
| [ESP32](https://s.click.aliexpress.com/e/_Ey6AJnT) | [0.0.13](https://github.com/matteocrippa/leafminer/releases) |
| [ESP32-S2](https://s.click.aliexpress.com/e/_EGJcibR) | [0.0.13](https://github.com/matteocrippa/leafminer/releases) |
| [ESP32-S3](https://s.click.aliexpress.com/e/_EJbAXyl) | [0.0.13](https://github.com/matteocrippa/leafminer/releases) |
| [LILYGO-T-S3](https://s.click.aliexpress.com/e/_ExRWk6H) | [0.0.13](https://github.com/matteocrippa/leafminer/releases) |

- Browse to [ESPWebtool](https://esp.huhn.me/) using a Chrome based browser and follow the instructions.
| [ESP8266](https://s.click.aliexpress.com/e/_EuwffHJ) | [0.0.14](https://github.com/matteocrippa/leafminer/releases) |
| [GeekMagic SmartTV]() | [0.0.14](https://github.com/matteocrippa/leafminer/releases) |
| [ESP32](https://s.click.aliexpress.com/e/_Ey6AJnT) | [0.0.14](https://github.com/matteocrippa/leafminer/releases) |
| [ESP32-S2](https://s.click.aliexpress.com/e/_EGJcibR) | [0.0.14](https://github.com/matteocrippa/leafminer/releases) |
| [ESP32-S3](https://s.click.aliexpress.com/e/_EJbAXyl) | [0.0.14](https://github.com/matteocrippa/leafminer/releases) |
| [LILYGO-T-S3](https://s.click.aliexpress.com/e/_ExRWk6H) | [0.0.14](https://github.com/matteocrippa/leafminer/releases) |

- Browse to [ESPWebtool](https://esp.huhn.me/) using a Chrome based browser and upload the file according to the address in the file name.

For example this is how ESP32-S3 will look like:

<img width="687" alt="LeafMiner Web flash" src="https://github.com/matteocrippa/leafminer/assets/475463/f483b8fe-a563-4249-98f8-092a45a9b4f8">

Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

The following versions of LeafMiner are currently supported with security updates:

- 0.0.8
- 0.0.14

## Reporting a Vulnerability

Expand Down
12 changes: 12 additions & 0 deletions src/current.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,16 @@ void current_setJob(const Notification &notification)
l_debug(TAG_CURRENT, "Job: %s is cleaned and replaced with %s", current_job->job_id.c_str(), notification.job_id.c_str());
}
}

if (current_job_is_valid == 1)
{
#if CORES > 1
current_job_next = new Job(notification, *current_subscribe, current_difficulty);
l_info(TAG_CURRENT, "Job: %s queued", current_job_next->job_id.c_str());
#endif
return;
}

current_job = new Job(notification, *current_subscribe, current_difficulty);
current_job_is_valid = 1;
l_info(TAG_CURRENT, "Job: %s ready to be mined", current_job->job_id.c_str());
Expand Down Expand Up @@ -127,6 +131,14 @@ const char *current_getUptime()
return uptimeString;
}

/**
* @brief Resets the current session by setting the current_subscribe pointer to nullptr.
*/
void current_resetSession()
{
current_subscribe = nullptr;
}

/**
* Sets the Subscribe object for the Current class.
*
Expand Down
1 change: 1 addition & 0 deletions src/current.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const char *current_getJobId();
const char *current_getUptime();
void current_setSubscribe(Subscribe *subscribe);
const char *current_getSessionId();
void current_resetSession();
void current_setDifficulty(double difficulty);
const double current_getDifficulty();
void current_increment_block_found();
Expand Down
22 changes: 20 additions & 2 deletions src/html/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,37 @@ <h1>LeafMiner</h1>
<label>Pool Port:</label>
<input type="number" name="pool_port" value="{{pool_port}}" />
<br />
<label>Auto Update:</label>
Off
<input
type="radio"
id="auto_update_off"
name="auto_update"
value="off"
{{auto_update_off}}
/>
On
<input
type="radio"
id="auto_update_on"
name="auto_update"
value="on"
{{auto_update_on}}
/>
<br />
<label>Blinking Enabled:</label>
Off
<input
type="radio"
id="lcd_on_start_off"
id="blink_enabled_off"
name="blink_enabled"
value="off"
{{blink_enabled_off}}
/>
On
<input
type="radio"
id="lcd_on_start_on"
id="blink_enabled_on"
name="blink_enabled"
value="on"
{{blink_enabled_on}}
Expand Down
2 changes: 1 addition & 1 deletion src/leafminer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef LEAFMINER_H
#define LEAFMINER_H

#define _VERSION "0.0.13"
#define _VERSION "0.0.14"
#define DIFFICULTY 1e-4

// Mining
Expand Down
19 changes: 18 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ void setup()
Serial.begin(115200);
delay(1500);
l_info(TAG_MAIN, "LeafMiner - v.%s - (C: %d)", _VERSION, CORE);
l_info(TAG_MAIN, "Compiled: %s %s", __DATE__, __TIME__);
l_info(TAG_MAIN, "Free memory: %d", ESP.getFreeHeap());
#if defined(ESP32)
l_info(TAG_MAIN, "Chip Model: %s - Rev: %d", ESP.getChipModel(), ESP.getChipRevision());
uint32_t chipID = 0;
for (int i = 0; i < 17; i = i + 8)
{
chipID |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}
l_info(TAG_MAIN, "Chip ID: %s", chipID);
#else
l_info(TAG_MAIN, "Chip ID: %s", ESP.getChipId());
#endif

#if defined(ESP8266)
l_info(TAG_MAIN, "ESP8266 - Disable WDT");
Expand All @@ -46,6 +59,7 @@ void setup()
force_ap = button_setup();

storage_load(&configuration);
configuration.print();

if (configuration.wifi_ssid == "" || force_ap)
{
Expand All @@ -70,7 +84,10 @@ void setup()
screen_setup();
#endif // HAS_LCD

autoupdate();
if (configuration.auto_update == "on")
{
autoupdate();
}

if (network_getJob() == -1)
{
Expand Down
17 changes: 17 additions & 0 deletions src/model/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <string>
#include <stdio.h>
#include "utils/log.h"

struct Configuration
{
Expand All @@ -16,6 +17,22 @@ struct Configuration
int blink_brightness = 256;
std::string lcd_on_start = "";
std::string miner_type = "";
std::string auto_update = "";

void print()
{
l_info("wifi_ssid: %s", wifi_ssid.c_str());
l_info("wifi_password: %s", wifi_password.c_str());
l_info("wallet_address: %s", wallet_address.c_str());
l_info("pool_password: %s", pool_password.c_str());
l_info("pool_url: %s", pool_url.c_str());
l_info("pool_port: %d", std::to_string(pool_port).c_str());
l_info("blink_enabled: %s", blink_enabled.c_str());
l_info("blink_brightness: %s", std::to_string(blink_brightness).c_str());
l_info("lcd_on_start: %s", lcd_on_start.c_str());
l_info("miner_type: %s", miner_type.c_str());
l_info("auto_update: %s", auto_update.c_str());
}
};

#endif
4 changes: 4 additions & 0 deletions src/network/accesspoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ std::string prepareHtmlWithValues(const Configuration &configuration)
bool is_lcd_on = strcmp(configuration.lcd_on_start.c_str(), "on") == 0;
replacePattern(html, "{{lcd_on_start_on}}", is_lcd_on ? "checked=\"checked\"" : "");
replacePattern(html, "{{lcd_on_start_off}}", !is_lcd_on ? "checked=\"checked\"" : "");
bool is_autoupdate_on = strcmp(configuration.auto_update.c_str(), "on") == 0;
replacePattern(html, "{{auto_update_on}}", is_autoupdate_on ? "checked=\"checked\"" : "");
replacePattern(html, "{{auto_update_off}}", !is_autoupdate_on ? "checked=\"checked\"" : "");
return html;
}

Expand Down Expand Up @@ -121,6 +124,7 @@ void accesspoint_webserver()
conf.blink_enabled = request->arg("blink_enabled").c_str();
conf.blink_brightness = request->arg("blink_brightness").toInt();
conf.lcd_on_start = request->arg("lcd_on_start").c_str();
conf.auto_update = request->arg("auto_update").c_str();
storage_save(conf);

request->send(200, "text/html", "<html><body>Data saved successfully!<br/><br/>Please reboot your board!</body></html>"); });
Expand Down
12 changes: 11 additions & 1 deletion src/network/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ short isConnected()
return -1;
}

l_info(TAG_NETWORK, "Connected to WiFi");
l_info(TAG_NETWORK, "IP address: %s", WiFi.localIP().toString().c_str());
l_info(TAG_NETWORK, "MAC address: %s", WiFi.macAddress().c_str());

uint16_t wifi_stratum = 0;

// and we are connected to the host
Expand Down Expand Up @@ -358,6 +362,7 @@ short network_getJob()

if (isConnected() == -1)
{
current_resetSession();
return -1;
}

Expand Down Expand Up @@ -408,7 +413,11 @@ void network_listen()
#endif

int len = 0;
isConnected();
if (isConnected() == -1)
{
current_resetSession();
return; // Handle connection failure
}
do
{
char data[NETWORK_BUFFER_SIZE];
Expand All @@ -429,6 +438,7 @@ void network_submit(const char *payload)
{
if (isConnected() == -1)
{
current_resetSession();
return; // Handle connection failure
}

Expand Down
2 changes: 2 additions & 0 deletions src/storage/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void storage_save(const Configuration &conf)
preferences.putString("blink_enabled", conf.blink_enabled.c_str());
preferences.putUInt("blink_bright", conf.blink_brightness);
preferences.putString("lcd_on_start", conf.lcd_on_start.c_str());
preferences.putString("auto_update", conf.auto_update.c_str());
preferences.end();
}

Expand All @@ -37,4 +38,5 @@ void storage_load(Configuration *conf)
conf->blink_enabled = preferences.getString("blink_enabled", "on").c_str();
conf->blink_brightness = preferences.getUInt("blink_bright", 256);
conf->lcd_on_start = preferences.getString("lcd_on_start", "on").c_str();
conf->auto_update = preferences.getString("auto_update", "on").c_str();
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"current": "0.0.13",
"current": "0.0.14",
"link": "https://github.com/matteocrippa/leafminer/releases/download/v{{version}}/firmware_{{device}}.bin",
"devices": [
"esp8266",
Expand Down

0 comments on commit d22d93f

Please sign in to comment.