main/task_wifi.c

changeset 18
12506716211c
parent 15
64028e178ff1
child 22
9c0bcc91fe1a
equal deleted inserted replaced
17:1599e696d947 18:12506716211c
17 wifi_config_t wifi_Config = { ///< Current STA configuration. 17 wifi_config_t wifi_Config = { ///< Current STA configuration.
18 .sta = { 18 .sta = {
19 .ssid = ESP_WIFI_SSID, 19 .ssid = ESP_WIFI_SSID,
20 .password = ESP_WIFI_PASS, 20 .password = ESP_WIFI_PASS,
21 .scan_method = WIFI_FAST_SCAN, 21 .scan_method = WIFI_FAST_SCAN,
22 .sort_method = WIFI_CONNECT_AP_BY_SECURITY,
23 .threshold.rssi = -127,
24 .threshold.authmode = WIFI_AUTH_WPA2_PSK,
25 }, 22 },
26 }; 23 };
27 WIFI_State *wifi_state = NULL; ///< Public state for other tasks. 24 WIFI_State *wifi_state = NULL; ///< Public state for other tasks.
28 esp_netif_t *sta_netif = NULL; ///< Station interface 25 esp_netif_t *sta_netif = NULL; ///< Station interface
29 26
185 ESP_ERROR_CHECK(esp_wifi_init(&wifi_init_config)); 182 ESP_ERROR_CHECK(esp_wifi_init(&wifi_init_config));
186 183
187 esp_event_handler_instance_t instance_any_id; 184 esp_event_handler_instance_t instance_any_id;
188 esp_event_handler_instance_t instance_got_ip; 185 esp_event_handler_instance_t instance_got_ip;
189 ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL, &instance_any_id) ); 186 ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL, &instance_any_id) );
190 ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, /*IP_EVENT_STA_GOT_IP*/ ESP_EVENT_ANY_ID, &got_ip_event_handler, NULL, &instance_got_ip) ); 187 ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, ESP_EVENT_ANY_ID, &got_ip_event_handler, NULL, &instance_got_ip) );
191 188
192 ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); 189 ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
193 ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_Config) ); 190 ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_Config) );
194 ESP_ERROR_CHECK(esp_wifi_start()); 191 ESP_ERROR_CHECK(esp_wifi_start());
195 192

mercurial