2121#include "connect.h"
2222#include "asic_reset.h"
2323#include "asic_init.h"
24+ #include "filesystem.h"
25+ #include "input.h"
2426
2527static GlobalState GLOBAL_STATE ;
2628
@@ -73,25 +75,30 @@ void app_main(void)
7375 return ;
7476 }
7577
76- if (self_test (& GLOBAL_STATE ))
78+ if (self_test_init (& GLOBAL_STATE ) != ESP_OK ) {
79+ ESP_LOGE (TAG , "Failed to init self test" );
7780 return ;
81+ }
7882
7983 SYSTEM_init_system (& GLOBAL_STATE );
8084
81- // init AP and connect to wifi
82- wifi_init (& GLOBAL_STATE );
85+ if (!GLOBAL_STATE .SELF_TEST_MODULE .is_active ) {
86+ wifi_init (& GLOBAL_STATE );
87+ }
8388
8489 SYSTEM_init_peripherals (& GLOBAL_STATE );
8590
8691 if (xTaskCreate (POWER_MANAGEMENT_task , "power management" , 8192 , (void * ) & GLOBAL_STATE , 10 , NULL ) != pdPASS ) {
8792 ESP_LOGE (TAG , "Error creating power management task" );
8893 }
89- if (xTaskCreate (FAN_CONTROLLER_task , "fan_controller" , 8192 , (void * ) & GLOBAL_STATE , 5 , NULL ) != pdPASS ) {
90- ESP_LOGE (TAG , "Error creating fan controller task" );
91- }
9294
93- // start the API for AxeOS
94- start_rest_server ((void * ) & GLOBAL_STATE );
95+ if (!GLOBAL_STATE .SELF_TEST_MODULE .is_active ) {
96+ if (xTaskCreate (FAN_CONTROLLER_task , "fan_controller" , 8192 , (void * ) & GLOBAL_STATE , 5 , NULL ) != pdPASS ) {
97+ ESP_LOGE (TAG , "Error creating fan controller task" );
98+ }
99+ // start the API for AxeOS
100+ start_rest_server ((void * ) & GLOBAL_STATE );
101+ }
95102
96103 // After mounting SPIFFS
97104 SYSTEM_init_versions (& GLOBAL_STATE );
@@ -113,15 +120,23 @@ void app_main(void)
113120 return ;
114121 }
115122
116- if (xTaskCreate (stratum_task , "stratum admin" , 8192 , (void * ) & GLOBAL_STATE , 5 , NULL ) != pdPASS ) {
117- ESP_LOGE (TAG , "Error creating stratum admin task" );
118- }
119123 if (xTaskCreate (create_jobs_task , "stratum miner" , 8192 , (void * ) & GLOBAL_STATE , 20 , NULL ) != pdPASS ) {
120124 ESP_LOGE (TAG , "Error creating stratum miner task" );
121125 }
122126 if (xTaskCreate (ASIC_result_task , "asic result" , 8192 , (void * ) & GLOBAL_STATE , 15 , NULL ) != pdPASS ) {
123127 ESP_LOGE (TAG , "Error creating asic result task" );
124128 }
129+
130+ if (!GLOBAL_STATE .SELF_TEST_MODULE .is_active ) {
131+ if (xTaskCreate (stratum_task , "stratum admin" , 8192 , (void * ) & GLOBAL_STATE , 5 , NULL ) != pdPASS ) {
132+ ESP_LOGE (TAG , "Error creating stratum admin task" );
133+ }
134+ } else {
135+ if (xTaskCreate (self_test_task , "self_test" , 8192 , (void * ) & GLOBAL_STATE , 10 , NULL ) != pdPASS ) {
136+ ESP_LOGE (TAG , "Error creating self test task" );
137+ }
138+ }
139+
125140 if (xTaskCreateWithCaps (hashrate_monitor_task , "hashrate monitor" , 8192 , (void * ) & GLOBAL_STATE , 5 , NULL , MALLOC_CAP_SPIRAM ) !=
126141 pdPASS ) {
127142 ESP_LOGE (TAG , "Error creating hashrate monitor task" );
0 commit comments