Add integration with SR mining pool for Bitcoin Amsterdam '24

This commit is contained in:
Djuri Baars 2024-09-25 17:27:39 +02:00
parent e8a9e253f7
commit 6dc3a2c3c8
4 changed files with 46 additions and 6 deletions

View File

@ -9,7 +9,7 @@ std::array<std::string, NUM_SCREENS> parseBitaxeHashRate(std::string text)
// Calculate the position where the digits should start // Calculate the position where the digits should start
// Account for the position of the "mdi:pickaxe" and the "GH/S" label // Account for the position of the "mdi:pickaxe" and the "GH/S" label
std::size_t startIndex = NUM_SCREENS - 1 - textLength; std::size_t startIndex = NUM_SCREENS - textLength;
// Insert the "mdi:pickaxe" icon just before the digits // Insert the "mdi:pickaxe" icon just before the digits
if (startIndex > 0) if (startIndex > 0)
@ -23,7 +23,9 @@ std::array<std::string, NUM_SCREENS> parseBitaxeHashRate(std::string text)
ret[startIndex + i] = text.substr(i, 1); ret[startIndex + i] = text.substr(i, 1);
} }
ret[NUM_SCREENS - 1] = "GH/S"; char lastChar = text[textLength - 1];
ret[NUM_SCREENS - 1] = std::string(1, lastChar) + "H/S";
ret[0] = "BIT/AXE"; ret[0] = "BIT/AXE";
return ret; return ret;

View File

@ -17,14 +17,18 @@ std::string getBitaxeBestDiff()
void taskBitaxeFetch(void *pvParameters) void taskBitaxeFetch(void *pvParameters)
{ {
WiFiClientSecure client;
client.setCACert(srpool_ca);
for (;;) for (;;)
{ {
ulTaskNotifyTake(pdTRUE, portMAX_DELAY); ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
HTTPClient http; HTTPClient http;
http.setUserAgent(USER_AGENT); http.setUserAgent(USER_AGENT);
String bitaxeApiUrl = "http://" + preferences.getString("bitaxeHostname", DEFAULT_BITAXE_HOSTNAME) + "/api/system/info"; String bitaxeApiUrl = preferences.getString("bitaxeHostname", DEFAULT_BITAXE_HOSTNAME);
http.begin(bitaxeApiUrl.c_str()); http.begin(client, bitaxeApiUrl.c_str());
int httpCode = http.GET(); int httpCode = http.GET();
@ -33,8 +37,8 @@ void taskBitaxeFetch(void *pvParameters)
String payload = http.getString(); String payload = http.getString();
JsonDocument doc; JsonDocument doc;
deserializeJson(doc, payload); deserializeJson(doc, payload);
bitaxeHashrate = std::to_string(static_cast<int>(std::round(doc["hashRate"].as<float>()))); bitaxeHashrate = doc["hashrate1m"].as<std::string>();
bitaxeBestDiff = doc["bestDiff"].as<std::string>(); bitaxeBestDiff = formatNumberWithSuffix(doc["bestever"].as<uint64_t>());
if (workQueue != nullptr && (getCurrentScreen() == SCREEN_BITAXE_HASHRATE || getCurrentScreen() == SCREEN_BITAXE_BESTDIFF)) if (workQueue != nullptr && (getCurrentScreen() == SCREEN_BITAXE_HASHRATE || getCurrentScreen() == SCREEN_BITAXE_BESTDIFF))
{ {

View File

@ -1,5 +1,38 @@
#include "shared.hpp" #include "shared.hpp"
const char *srpool_ca = \
"-----BEGIN CERTIFICATE-----\n" \
"MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw\n" \
"TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n" \
"cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4\n" \
"WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu\n" \
"ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY\n" \
"MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc\n" \
"h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+\n" \
"0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U\n" \
"A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA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8NwdC\n" \
"jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc\n" \
"oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq\n" \
"4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA\n" \
"mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d\n" \
"emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n" \
"-----END CERTIFICATE-----\n";
const char *github_root_ca = const char *github_root_ca =
"-----BEGIN CERTIFICATE-----\n" "-----BEGIN CERTIFICATE-----\n"
"MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDEL\n" "MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDEL\n"

View File

@ -69,6 +69,7 @@ const int usPerSecond = 1000000;
const int usPerMinute = 60 * usPerSecond; const int usPerMinute = 60 * usPerSecond;
extern const char *github_root_ca; extern const char *github_root_ca;
extern const char *srpool_ca;
const PROGMEM char UPDATE_FIRMWARE = U_FLASH; const PROGMEM char UPDATE_FIRMWARE = U_FLASH;
const PROGMEM char UPDATE_WEBUI = U_SPIFFS; const PROGMEM char UPDATE_WEBUI = U_SPIFFS;