Wireless Protected Setup (WPS)

From openPicus Wiki
Jump to: navigation, search

Contents

What you are going to learn

You'll learn how to use the new function to connect to a WiFi infrastructure with the Wireless Protected Setup (WPS).

Flyport Wi-Fi B does not support this feature.

Disclaimer

As always this is all free software provided as is, no explicit and/or implied responsibilities are admitted and/or accepted.

Code

Explanation

The latest versions of Access Point have the Wireless Protected Setup with relative push button.

You can connect a device without add password but only pushing the WPS button on the router when the device try to connect with it.
The AP and the device share the password automatically, you can use the WLAN with the device normally after some seconds.

We try to connect to WLAN with Flyport and the same time we push the WPS button. Flyport catches the SSID name, password type and Passkey numbers and then saves it in custom profile. Next time Flyport is powered up, custom profile is saved and you can avoid the WPS method.

Source

Here is the entire taskFlyport.c

#include "taskFlyport.h"
char myPSKWPS[32];
char mySSIDname[32];
BYTE myPSKType = 0;
 
void FlyportTask()
{
	vTaskDelay(100);
 
	// Default Profile is already set on IDE Wizard
	if(WFCustomExist() == FALSE)
	{
		// Setup Custom Parameters for WPS Push Button
		NETSetParam(SSID_NAME, ""); // A blank string is used to connect to the first WPS network Flyport will find
		NETSetParam(NETWORK_TYPE, INFRASTRUCTURE);
		WFSetSecurity(WF_SECURITY_WPS_PUSH_BUTTON, "", 0, 0);
 
		// Flyport connects to custom network:
		_dbgline("Flyport will try to connect to your Network using WPS Button security type.");
		_dbgline("Please, push WPS Button on your router when Flyport is ready, and wait for passkey calculation.");
 
		WFConnect(WF_CUSTOM);
		while(WFGetStat() != CONNECTED);
		vTaskDelay(25);
		UARTWrite(1,"Flyport Wi-fi connected...hello world!\r\n");
 
		// Get SSID name:
		WFGetSSID(mySSIDname);
		_dbgwrite("SSID name: ");
		_dbgline(mySSIDname);
 
		// Get used security method
		WFGetSecType(&myPSKType);
 
		// Save Calculated PSK for future usages
		WFGetPSK(myPSKWPS);
 
		// Set again custom network params
		NETSetParam(SSID_NAME, mySSIDname);
		WFSetSecurity(myPSKType, myPSKWPS, 32, 0);
 
		NETCustomSave();
	}
	else
	{
		_dbgline("Custom parameters detected!\r\nConnecting to network...");
		NETCustomLoad();
		WFConnect(WF_CUSTOM);
		while(WFGetStat() != CONNECTED);
		vTaskDelay(25);
		_dbgline("Flyport Wi-fi connected...hello world!");
	}
 
	while(1)
	{
		//	Main user's firmware loop
	}
}
Personal tools
Namespaces

Variants
Actions
START HERE
DEVELOPMENT
HARDWARE INFO
RESOURCES
PHASED OUT
Toolbox