Page 1 of 1

Need Example to configure and start WPS mode into ESP32-IDF RTOS SDK

Posted: Thu Mar 09, 2017 10:43 am
by Ritesh
Hi,

I am working on ESP32-IDF 2.0 RC1 RTOS SDK and I want to enable and start WPS mode into Station Mode. I have written some cdoe but not sure it will be worked or not.

Please find following code to start WPS mode.

Code: Select all

void WifiInIt()
{
	esp_err_t error_code = 0;
	
	tcpip_adapter_init();
       wifi_event_group = xEventGroupCreate();
       ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
       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_FLASH) );

	/// Added for WPS support only
	error_code = esp_wifi_set_mode(WIFI_MODE_STA);
	if(error_code)
	{
		printf("esp_wifi_set_mode is failed to execute...\n");
	}
	else
	{
		printf("esp_wifi_set_mode is executed successfully...\n");
	}
	/// End edit
}

Code: Select all

int app_main(void)
{
	esp_err_t error_code = 0;
        nvs_flash_init();

       WifiInIt();
	
	/// Added code to check WPS support only
	//error_code = esp_wifi_wps_enable(WPS_TYPE_PIN);	/// WPS PIN Configuration Type
	error_code = esp_wifi_wps_enable(WPS_TYPE_PBC);		/// WPS PBC (Push Button Configuration) Type
	if(error_code)
	{
		printf("esp_wifi_wps_enable is failed to execute...\n");
	}
	else
	{
		printf("esp_wifi_wps_enable is executed successfully...\n");
		
		Delay(5000);
		
		/* 120 milliseconds blocking time*/
		error_code = esp_wifi_wps_start(120);
		if(error_code)
		{
			printf("esp_wifi_wps_start is failed to execute...\n");
		}
		else
		{
			printf("esp_wifi_wps_start is executed successfully...\n");
		}
		
		Delay(5000);
	}
	/// End edit

        return 0;
}
Let me know if anyone has configured WPS mode in PBC or PIN mode configuration and started it successfully without any issue. Also provide me if any sample program for that

Re: Need Example to configure and start WPS mode into ESP32-IDF RTOS SDK

Posted: Thu Mar 09, 2017 2:50 pm
by Ritesh
Hi,

I have successfully connected my device with WPS supported router using WPS_TYPE_PBC in local access not with external access as router is not connected with external network.

I have tried with WPS_TYPE_PIN mode but it always failed as it required PIN configuration and right now there is no any WPS supported API to do that.

Please let me know if anyone has any information regarding WPS_TYPE_PIN mode or when WPS_TYPE_PIN will be supported into ESP32-IDF stack?