Skip to content

Commit

Permalink
first fix for esp8266
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Crippa committed Mar 16, 2024
1 parent c410a68 commit c260df3
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 34 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# v0.0.11

- Improved network handling
# v0.0.12

- Fix ESP8266 getting stuck on the job
- Fix EPS8266 network
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ The SHA256 code is based on a tweaked version of [NerdSHA256plus](https://github

| Board | Status | Expected Hashrate |
| :---------------- | :----: | :---------------- |
| ESP8266 | 🟩 | ±16 kH/s |
| ESP8266 | 🟩 | ±16 kH/s |
| ESP32 | 🟩 | ±48 kH/s |
| ESP32-S2 | 🟩 | ±19 kH/s |
| ESP32-S3 | 🟩 | ±80 kH/s |
| LILYGO-T-S3 | 🟩 | ±80 kH/s |
| SMALLTV (ESP8266) | 🟩 | ±16 kH/s |
| SMALLTV (ESP8266) | 🟩 | ±16 kH/s |

_Legend_
| Icon | Description |
Expand Down Expand Up @@ -57,12 +57,12 @@ _Legend_

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

- Browse to [ESPWebtool](https://esp.huhn.me/) using a Chrome based browser and follow the instructions.

Expand Down Expand Up @@ -115,11 +115,11 @@ Starting from version **0.0.6**, we now offer the capability for mass deployment

If you want to support this project, consider donating:

| | |
| :------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| AliExpress Referral | Use referral links in the list of hardware above |
| ⚡️ Lightning | `[email protected]` |
| Bitcoin | `bc1quqr7agnx6e0k9kn8h24zfj5dueeurhzflt3qjg` |
| | |
| :------------------ | :----------------------------------------------- |
| AliExpress Referral | Use referral links in the list of hardware above |
| ⚡️ Lightning | `[email protected]` |
| Bitcoin | `bc1quqr7agnx6e0k9kn8h24zfj5dueeurhzflt3qjg` |

## Credits

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.11"
#define _VERSION "0.0.12"
#define DIFFICULTY 1e-4

// Mining
Expand Down
44 changes: 28 additions & 16 deletions src/network/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,16 @@ short network_getJob()
return 1;
}

void enqueue(const char *payload) {
if (payloads_count < MAX_PAYLOADS) {
void enqueue(const char *payload)
{
if (payloads_count < MAX_PAYLOADS)
{
strncpy(payloads[payloads_count], payload, MAX_PAYLOAD_SIZE - 1);
payloads_count++;
l_debug(TAG_NETWORK, "Payload queued: %s", payload);
} else {
}
else
{
l_error(TAG_NETWORK, "Payload queue is full");
}
}
Expand All @@ -386,22 +390,23 @@ void network_send(const std::string &job_id, const std::string &extranonce2, con
char payload[MAX_PAYLOAD_SIZE];
snprintf(payload, sizeof(payload), "{\"id\":%llu,\"method\":\"mining.submit\",\"params\":[\"%s\",\"%s\",\"%s\",\"%s\",\"%08x\"]}\n", nextId(), configuration.wallet_address.c_str(), job_id.c_str(), extranonce2.c_str(), ntime.c_str(), nonce);
#if defined(ESP8266)
network_listen();
request(payload);
delay(33);
network_listen();
#else
enqueue(payload);
#endif
}

void network_listen()
{
#if defined(ESP8266)
#if defined(ESP8266)
if (isListening == 1)
{
return;
}
isListening = 1;
#endif
#endif

int len = 0;
isConnected();
Expand All @@ -416,33 +421,40 @@ void network_listen()
}
} while (len > 0);

#if defined(ESP8266)
#if defined(ESP8266)
isListening = 0;
#endif
#endif
}

void network_submit(const char *payload) {
if (isConnected() == -1) {
void network_submit(const char *payload)
{
if (isConnected() == -1)
{
return; // Handle connection failure
}

request(payload);

// Remove the submitted payload from the array
for (size_t i = 0; i < payloads_count; ++i) {
if (strcmp(payloads[i], payload) == 0) {
for (size_t i = 0; i < payloads_count; ++i)
{
if (strcmp(payloads[i], payload) == 0)
{
// Shift remaining payloads
for (size_t j = i; j < payloads_count - 1; ++j) {
strcpy(payloads[j], payloads[j+1]);
for (size_t j = i; j < payloads_count - 1; ++j)
{
strcpy(payloads[j], payloads[j + 1]);
}
payloads_count--;
break;
}
}
}

void network_submit_all() {
for (size_t i = 0; i < payloads_count; ++i) {
void network_submit_all()
{
for (size_t i = 0; i < payloads_count; ++i)
{
network_submit(payloads[i]);
}
}
Expand Down
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.11",
"current": "0.0.12",
"link": "https://github.com/matteocrippa/leafminer/releases/download/v{{version}}/firmware_{{device}}.bin",
"devices": [
"esp8266",
Expand Down

0 comments on commit c260df3

Please sign in to comment.