Skip to content

Conversation

Rotzbua
Copy link
Contributor

@Rotzbua Rotzbua commented May 30, 2022

Description of Change

Remove duplicate setting of SSID and password.
Done by function call of wifi_sta_config.

Tests scenarios

Normal WiFi connection example.

Related links

None.

Done by function call of `wifi_sta_config`.
Copy link
Collaborator

@mrengineer7777 mrengineer7777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since wifi_sta_config() overwrites conf.sta.ssid and conf.sta.password, the targeted code has no effect. I see no dependency on sta.ssid or sta.password values before they are overwritten. LGTM.

static void wifi_sta_config(wifi_config_t * wifi_config, const char * ssid=NULL, const char * password=NULL, const uint8_t * bssid=NULL, uint8_t channel=0, wifi_scan_method_t scan_method=WIFI_ALL_CHANNEL_SCAN, wifi_sort_method_t sort_method=WIFI_CONNECT_AP_BY_SIGNAL, uint16_t listen_interval=0, bool pmf_required=false){
    wifi_config->sta.channel = channel;
    wifi_config->sta.listen_interval = listen_interval;
    wifi_config->sta.scan_method = scan_method;//WIFI_ALL_CHANNEL_SCAN or WIFI_FAST_SCAN
    wifi_config->sta.sort_method = sort_method;//WIFI_CONNECT_AP_BY_SIGNAL or WIFI_CONNECT_AP_BY_SECURITY
    wifi_config->sta.threshold.rssi = -127;
    wifi_config->sta.pmf_cfg.capable = true;
    wifi_config->sta.pmf_cfg.required = pmf_required;
    wifi_config->sta.bssid_set = 0;
    memset(wifi_config->sta.bssid, 0, 6);
    wifi_config->sta.threshold.authmode = WIFI_AUTH_OPEN;
    wifi_config->sta.ssid[0] = 0;
    wifi_config->sta.password[0] = 0;
    if(ssid != NULL && ssid[0] != 0){
        _wifi_strncpy((char*)wifi_config->sta.ssid, ssid, 32);
    	if(password != NULL && password[0] != 0){
    		wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
    		_wifi_strncpy((char*)wifi_config->sta.password, password, 64);
    	}
        if(bssid != NULL){
            wifi_config->sta.bssid_set = 1;
            memcpy(wifi_config->sta.bssid, bssid, 6);
        }
    }
}

@VojtechBartoska VojtechBartoska added the Area: BT&Wifi BT & Wifi related issues label Jun 2, 2022
@me-no-dev me-no-dev merged commit e909172 into espressif:master Jun 12, 2022
@me-no-dev
Copy link
Member

Thanks @Rotzbua

@Rotzbua Rotzbua deleted the wifista_remove_dublicate_code branch June 23, 2022 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BT&Wifi BT & Wifi related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants