Function esp_idf_sys::esp_wifi_connect

source ·
pub unsafe extern "C" fn esp_wifi_connect() -> esp_err_t
Expand description

@brief Connect WiFi station to the AP.

@attention 1. This API only impact WIFI_MODE_STA or WIFI_MODE_APSTA mode @attention 2. If station interface is connected to an AP, call esp_wifi_disconnect to disconnect. @attention 3. The scanning triggered by esp_wifi_scan_start() will not be effective until connection between device and the AP is established. If device is scanning and connecting at the same time, it will abort scanning and return a warning message and error number ESP_ERR_WIFI_STATE. @attention 4. This API attempts to connect to an Access Point (AP) only once. To enable reconnection in case of a connection failure, please use the ‘failure_retry_cnt’ feature in the ‘wifi_sta_config_t’. Users are suggested to implement reconnection logic in their application for scenarios where the specified AP does not exist, or reconnection is desired after the device has received a disconnect event.

@return

  • ESP_OK: succeed
  • ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
  • ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
  • ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
  • ESP_ERR_WIFI_SSID: SSID of AP which station connects is invalid