diff --git a/ESP-IDF_Robot/main/blink_example_main.c b/ESP-IDF_Robot/main/blink_example_main.c index c70b7ea05..c2a790332 100644 --- a/ESP-IDF_Robot/main/blink_example_main.c +++ b/ESP-IDF_Robot/main/blink_example_main.c @@ -280,20 +280,12 @@ static void wifi_init() wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); - ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); - wifi_config_t wifi_config = { - .sta = { - .ssid = "IoT_bots", - .password = "208208208", - } - }; - ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); - ESP_ERROR_CHECK( esp_wifi_start() ); - ESP_ERROR_CHECK( esp_wifi_connect() ); - // Do not set channel manually in STA mode for MQTT compatibility - // #if CONFIG_ESPNOW_ENABLE_LONG_RANGE - // ESP_ERROR_CHECK( esp_wifi_set_protocol(ESPNOW_WIFI_IF, WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_LR) ); - // #endif + ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA));//ESPNOW_WIFI_MODE)); + ESP_ERROR_CHECK( esp_wifi_start()); + ESP_ERROR_CHECK( esp_wifi_set_channel(CONFIG_ESPNOW_CHANNEL, WIFI_SECOND_CHAN_NONE)); + #if CONFIG_ESPNOW_ENABLE_LONG_RANGE + ESP_ERROR_CHECK( esp_wifi_set_protocol(ESPNOW_WIFI_IF, WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_LR) ); + #endif } static void led_task (void *arg) {