diff --git a/components/bm1397/bm1366.c b/components/bm1397/bm1366.c index 49862d3b..d41760db 100644 --- a/components/bm1397/bm1366.c +++ b/components/bm1397/bm1366.c @@ -166,7 +166,7 @@ void BM1366_send_hash_frequency(float target_freq) if (fb_divider == 0) { puts("Finding dividers failed, using default value (200Mhz)"); } else { - newf = 25.0 / (float) (ref_divider * fb_divider) / (float) (post_divider1 * post_divider2); + newf = 25.0 * (float) (fb_divider) / (float) (ref_divider * post_divider1 * post_divider2); printf("final refdiv: %d, fbdiv: %d, postdiv1: %d, postdiv2: %d, min diff value: %f\n", ref_divider, fb_divider, post_divider1, post_divider2, min_difference); diff --git a/components/bm1397/bm1368.c b/components/bm1397/bm1368.c index 8e431258..bc6a1580 100644 --- a/components/bm1397/bm1368.c +++ b/components/bm1397/bm1368.c @@ -166,7 +166,7 @@ void BM1368_send_hash_frequency(float target_freq) if (fb_divider == 0) { puts("Finding dividers failed, using default value (200Mhz)"); } else { - newf = 25.0 / (float) (ref_divider * fb_divider) / (float) (post_divider1 * post_divider2); + newf = 25.0 * (float) (fb_divider) / (float) (ref_divider * post_divider1 * post_divider2); printf("final refdiv: %d, fbdiv: %d, postdiv1: %d, postdiv2: %d, min diff value: %f\n", ref_divider, fb_divider, post_divider1, post_divider2, min_difference); diff --git a/components/stratum/include/stratum_api.h b/components/stratum/include/stratum_api.h index e96ccf32..7ce73ff2 100644 --- a/components/stratum/include/stratum_api.h +++ b/components/stratum/include/stratum_api.h @@ -19,7 +19,8 @@ typedef enum STRATUM_RESULT, STRATUM_RESULT_SETUP, STRATUM_RESULT_VERSION_MASK, - STRATUM_RESULT_SUBSCRIBE + STRATUM_RESULT_SUBSCRIBE, + CLIENT_RECONNECT } stratum_method; static const int STRATUM_ID_SUBSCRIBE = 1; @@ -60,6 +61,8 @@ typedef struct bool response_success; } StratumApiV1Message; +void STRATUM_V1_reset_uid(); + void STRATUM_V1_initialize_buffer(); char *STRATUM_V1_receive_jsonrpc_line(int sockfd); diff --git a/components/stratum/stratum_api.c b/components/stratum/stratum_api.c index 50de8d5f..c15d50ba 100644 --- a/components/stratum/stratum_api.c +++ b/components/stratum/stratum_api.c @@ -26,6 +26,13 @@ static int send_uid = 1; static void debug_stratum_tx(const char *); int _parse_stratum_subscribe_result_message(const char * result_json_str, char ** extranonce, int * extranonce2_len); +void STRATUM_V1_reset_uid() +{ + ESP_LOGI(TAG, "Resetting stratum uid"); + + send_uid = 1; +} + void STRATUM_V1_initialize_buffer() { json_rpc_buffer = malloc(BUFFER_SIZE); @@ -128,6 +135,8 @@ void STRATUM_V1_parse(StratumApiV1Message * message, const char * stratum_json) result = MINING_SET_DIFFICULTY; } else if (strcmp("mining.set_version_mask", method_json->valuestring) == 0) { result = MINING_SET_VERSION_MASK; + } else if (strcmp("client.reconnect", method_json->valuestring) == 0) { + result = CLIENT_RECONNECT; } else { ESP_LOGI(TAG, "unhandled method in stratum message: %s", stratum_json); } diff --git a/main/http_server/axe-os/src/app/components/home/home.component.html b/main/http_server/axe-os/src/app/components/home/home.component.html index 1bf6b5de..8b70042c 100644 --- a/main/http_server/axe-os/src/app/components/home/home.component.html +++ b/main/http_server/axe-os/src/app/components/home/home.component.html @@ -121,7 +121,7 @@
Heat
-
+
ASIC Temperature @@ -139,12 +139,12 @@ Danger: High Temperature
-
+
Fan %
-
+
Fan RPM @@ -191,26 +191,27 @@ -
+
Pool Information
- + - + - + - +
Quick Link:{{quickLink}} + {{quickLink}} +
URL:{{info.stratumURL}}{{info.stratumURL}}
Port:{{info.stratumPort}}{{info.stratumPort}}
User:{{info.stratumUser}}{{info.stratumUser}}
diff --git a/main/http_server/axe-os/src/app/components/home/home.component.ts b/main/http_server/axe-os/src/app/components/home/home.component.ts index f5216f74..12b03b7d 100644 --- a/main/http_server/axe-os/src/app/components/home/home.component.ts +++ b/main/http_server/axe-os/src/app/components/home/home.component.ts @@ -144,6 +144,12 @@ export class HomeComponent { } else if (info.stratumURL.includes('ocean.xyz')) { const address = info.stratumUser.split('.')[0] return `https://ocean.xyz/stats/${address}`; + } else if (info.stratumURL.includes('solo.d-central.tech')) { + const address = info.stratumUser.split('.')[0] + return `https://solo.d-central.tech/#/app/${address}`; + } else if (info.stratumURL.includes('solo.ckpool.org')) { + const address = info.stratumUser.split('.')[0] + return `https://solostats.ckpool.org/stats/${address}`; } else { return undefined; } diff --git a/main/tasks/asic_task.h b/main/tasks/asic_task.h index 19f58e87..d2f906cd 100644 --- a/main/tasks/asic_task.h +++ b/main/tasks/asic_task.h @@ -2,6 +2,7 @@ #define ASIC_TASK_H_ #include "freertos/FreeRTOS.h" +#include "freertos/semphr.h" #include "mining.h" typedef struct { @@ -15,4 +16,4 @@ typedef struct void ASIC_task(void *pvParameters); -#endif \ No newline at end of file +#endif diff --git a/main/tasks/stratum_task.c b/main/tasks/stratum_task.c index 003b213d..8c88d4e7 100644 --- a/main/tasks/stratum_task.c +++ b/main/tasks/stratum_task.c @@ -53,6 +53,19 @@ bool is_wifi_connected() { } } +void cleanQueue(GlobalState * GLOBAL_STATE) { + ESP_LOGI(TAG, "Clean Jobs: clearing queue"); + GLOBAL_STATE->abandon_work = 1; + queue_clear(&GLOBAL_STATE->stratum_queue); + + pthread_mutex_lock(&GLOBAL_STATE->valid_jobs_lock); + ASIC_jobs_queue_clear(&GLOBAL_STATE->ASIC_jobs_queue); + for (int i = 0; i < 128; i = i + 4) { + GLOBAL_STATE->valid_jobs[i] = 0; + } + pthread_mutex_unlock(&GLOBAL_STATE->valid_jobs_lock); +} + void stratum_task(void * pvParameters) { GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters; @@ -136,6 +149,9 @@ void stratum_task(void * pvParameters) continue; } + STRATUM_V1_reset_uid(); + cleanQueue(GLOBAL_STATE); + ///// Start Stratum Action // mining.subscribe - ID: 1 STRATUM_V1_subscribe(GLOBAL_STATE->sock, GLOBAL_STATE->asic_model_str); @@ -171,16 +187,7 @@ void stratum_task(void * pvParameters) SYSTEM_notify_new_ntime(GLOBAL_STATE, stratum_api_v1_message.mining_notification->ntime); if (stratum_api_v1_message.should_abandon_work && (GLOBAL_STATE->stratum_queue.count > 0 || GLOBAL_STATE->ASIC_jobs_queue.count > 0)) { - ESP_LOGI(TAG, "Clean Jobs: clearing queue"); - GLOBAL_STATE->abandon_work = 1; - queue_clear(&GLOBAL_STATE->stratum_queue); - - pthread_mutex_lock(&GLOBAL_STATE->valid_jobs_lock); - ASIC_jobs_queue_clear(&GLOBAL_STATE->ASIC_jobs_queue); - for (int i = 0; i < 128; i = i + 4) { - GLOBAL_STATE->valid_jobs[i] = 0; - } - pthread_mutex_unlock(&GLOBAL_STATE->valid_jobs_lock); + cleanQueue(GLOBAL_STATE); } if (GLOBAL_STATE->stratum_queue.count == QUEUE_SIZE) { mining_notify * next_notify_json_str = (mining_notify *) queue_dequeue(&GLOBAL_STATE->stratum_queue); @@ -202,12 +209,18 @@ void stratum_task(void * pvParameters) } else if (stratum_api_v1_message.method == STRATUM_RESULT_SUBSCRIBE) { GLOBAL_STATE->extranonce_str = stratum_api_v1_message.extranonce_str; GLOBAL_STATE->extranonce_2_len = stratum_api_v1_message.extranonce_2_len; + } else if (stratum_api_v1_message.method == CLIENT_RECONNECT) { + ESP_LOGE(TAG, "Pool requested client reconnect..."); + shutdown(GLOBAL_STATE->sock, SHUT_RDWR); + close(GLOBAL_STATE->sock); + vTaskDelay(1000 / portTICK_PERIOD_MS); // Delay before attempting to reconnect + break; } else if (stratum_api_v1_message.method == STRATUM_RESULT) { if (stratum_api_v1_message.response_success) { ESP_LOGI(TAG, "message result accepted"); SYSTEM_notify_accepted_share(GLOBAL_STATE); } else { - ESP_LOGE(TAG, "message result rejected"); + ESP_LOGW(TAG, "message result rejected"); SYSTEM_notify_rejected_share(GLOBAL_STATE); } } else if (stratum_api_v1_message.method == STRATUM_RESULT_SETUP) {