diff --git a/.vscode/settings.json b/.vscode/settings.json index 97cf7e5e..c856832a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "idf.flashType": "UART", - "idf.portWin": "COM30", + "idf.portWin": "COM3", "idf.adapterTargetName": "esp32s3", "idf.openOcdConfigs": [ "interface/ftdi/esp32_devkitj_v1.cfg", diff --git a/components/connect/connect.c b/components/connect/connect.c index aa1c9302..0a95ef56 100644 --- a/components/connect/connect.c +++ b/components/connect/connect.c @@ -60,18 +60,12 @@ static void event_handler(void * arg, esp_event_base_t event_base, int32_t event } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) { // Wait a little - vTaskDelay(1000 / portTICK_PERIOD_MS); + vTaskDelay(2500 / portTICK_PERIOD_MS); + esp_wifi_connect(); + s_retry_num++; + ESP_LOGI(TAG, "Retrying WiFi connection..."); + MINER_set_wifi_status(WIFI_RETRYING, s_retry_num); - if (s_retry_num < WIFI_MAXIMUM_RETRY) { - esp_wifi_connect(); - s_retry_num++; - ESP_LOGI(TAG, "Retrying WiFi connection..."); - MINER_set_wifi_status(WIFI_RETRYING, s_retry_num); - } else { - xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT); - ESP_LOGI(TAG, "Could not connect to WiFi."); - MINER_set_wifi_status(WIFI_CONNECT_FAILED, 0); - } } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { ip_event_got_ip_t * event = (ip_event_got_ip_t *) event_data; ESP_LOGI(TAG, "Bitaxe ip:" IPSTR, IP2STR(&event->ip_info.ip)); @@ -133,6 +127,12 @@ void wifi_softap_off(void) ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); } +void wifi_softap_on(void) +{ + ESP_LOGI(TAG, "ESP_WIFI Access Point On"); + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA)); +} + /* Initialize wifi station */ esp_netif_t * wifi_init_sta(const char * wifi_ssid, const char * wifi_pass) { diff --git a/components/connect/include/connect.h b/components/connect/include/connect.h index cff09b73..be5ff401 100644 --- a/components/connect/include/connect.h +++ b/components/connect/include/connect.h @@ -9,7 +9,7 @@ #define WIFI_SSID CONFIG_ESP_WIFI_SSID #define WIFI_PASS CONFIG_ESP_WIFI_PASSWORD -#define WIFI_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY + /* The event group allows multiple bits for each event, but we only care about two events: * - we are connected to the AP with an IP @@ -29,6 +29,7 @@ typedef enum } wifi_status_t; void toggle_wifi_softap(void); +void wifi_softap_on(void); void wifi_softap_off(void); void wifi_init(const char * wifi_ssid, const char * wifi_pass); EventBits_t wifi_connect(void); diff --git a/main/main.c b/main/main.c index 42bf6f60..88e0dcaf 100644 --- a/main/main.c +++ b/main/main.c @@ -147,7 +147,7 @@ void app_main(void) void MINER_set_wifi_status(wifi_status_t status, uint16_t retry_count) { if (status == WIFI_RETRYING) { - snprintf(GLOBAL_STATE.SYSTEM_MODULE.wifi_status, 20, "Retrying: %d/%d", retry_count, WIFI_MAXIMUM_RETRY); + snprintf(GLOBAL_STATE.SYSTEM_MODULE.wifi_status, 20, "Retrying: %d", retry_count); return; } else if (status == WIFI_CONNECT_FAILED) { snprintf(GLOBAL_STATE.SYSTEM_MODULE.wifi_status, 20, "Connect Failed!"); diff --git a/main/system.c b/main/system.c index 0c4abe81..2f43a6a3 100644 --- a/main/system.c +++ b/main/system.c @@ -79,7 +79,7 @@ static void _init_system(GlobalState * global_state, SystemModule * module) DS4432U_set_vcore(nvs_config_get_u16(NVS_CONFIG_ASIC_VOLTAGE, CONFIG_ASIC_VOLTAGE) / 1000.0); EMC2101_init(nvs_config_get_u16(NVS_CONFIG_INVERT_FAN_POLARITY, 1)); - EMC2101_set_fan_speed(1); + vTaskDelay(500 / portTICK_PERIOD_MS); diff --git a/main/tasks/power_management_task.c b/main/tasks/power_management_task.c index fedba203..c927e9c4 100644 --- a/main/tasks/power_management_task.c +++ b/main/tasks/power_management_task.c @@ -148,7 +148,7 @@ void POWER_MANAGEMENT_task(void * pvParameters) (power_management->frequency_value > 50 || power_management->voltage > 1000)) { ESP_LOGE(TAG, "OVERHEAT"); - + EMC2101_set_fan_speed(1); if (power_management->HAS_POWER_EN) { gpio_set_level(GPIO_NUM_10, 1); } else { diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 1edd6314..20ace2a4 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -5,7 +5,6 @@ CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y CONFIG_ESPTOOLPY_FLASHSIZE="16MB" -CONFIG_ESP_MAXIMUM_RETRY=5 CONFIG_HTTPD_WS_SUPPORT=y CONFIG_SPIFFS_OBJ_NAME_LEN=64 CONFIG_HTTPD_MAX_URI_LEN=2048