/*
 *	README: WPS STA as an Enrollee or Registrar
*/

0. Build WPS function. Please set 'HAS_WSC=y'.
	
1. Enrollee Mode

1.1) PIN mode:

Running Scenarios (case 'a' and 'b')
	--------------------------------------------------------
	a. Adding an Enrollee to AP+Registrar (EAP)
	[AP+Registrar]<----EAP--->[Enrollee Client]
	--------------------------------------------------------
	b. Adding an Enrollee with external Registrar (UPnP/EAP)
	[External Registrar]<----UPnP--->[AP_Proxy]<---EAP--->[Enrollee Client]
	--------------------------------------------------------
	Note: 'EAP' indicates to use wireless medium and 'UPnP' indicates to use 
	wired or wireless medium.

(i) [Registrar] or [AP+Registrar]
	Enter the Enrollee PinCode on the Registrar and start WPS on the Registrar.
	Note: How to get the Enrollee PinCode? Use 'iwpriv ra0 stat' on the Enrollee. 

(ii)[RT2860 Linux WPS STA]
	iwpriv ra0 wsc_conf_mode 1		;; Enrollee
	iwpriv ra0 wsc_mode 1			;; PIN
	iwpriv ra0 wsc_ap_band 0 (or 1)	;; 0: prefer 2.4G, 1: prefer 5G
	iwpriv ra0 wsc_ssid "AP's SSID"
	iwpriv ra0 wsc_start

{iii) If the registration is successful, the Enrollee will be re-configured 
	with the new parameters, and will connect to the AP with these new parameters.
 
1.2) PBC mode:

 Running Scenarios (case 'a' only)
 	--------------------------------------------------------
	a. Adding an Enrollee to AP+Registrar (EAP)
	[AP+Registrar]<----EAP--->[Client]
	--------------------------------------------------------

(i) [AP+Registrar]
	Start PBC on the Registrar.
		
{ii)[RT2860 Linux WPS STA]
	iwpriv ra0 wsc_conf_mode 1		;; Enrollee
	iwpriv ra0 wsc_mode 2			;; PBC
	iwpriv ra0 wsc_ap_band 0 (or 1)	;; 0: prefer 2.4G, 1: prefer 5G
	iwpriv ra0 wsc_start

{iii) If the registration is successful, the Enrollee will be re-configured 
	with the new parameters, and will connect to the AP with these new parameters.


2. Registrar Mode

2.1) PIN mode:

Running Scenarios (case 'a' and 'b')
 	--------------------------------------------------------
	a. Configure the un-configured AP
	[Unconfigured AP]<----EAP--->[Registrar]
	--------------------------------------------------------
	b. Configure the configured AP
	[Configured AP]<----EAP--->[Registrar]
	--------------------------------------------------------

(i) [AP]
	Start PIN on the Enrollee WPS AP.

(ii)[RT2860 Linux WPS STA]
	iwpriv ra0 wsc_conf_mode 2		;; Registrar
	iwpriv ra0 wsc_mode 1			;; PIN
	iwpriv ra0 wsc_pin xxxxxxxx		;; AP's PIN Code
	iwpriv ra0 wsc_ap_band 0 (or 1)	;; 0: prefer 2.4G, 1: prefer 5G
	iwpriv ra0 wsc_ssid "AP's SSID"
	iwpriv ra0 wsc_start

{iii) If the registration is successful;
	in case 'a': 
		The Registrar will be re-configured with the new parameters, 
		and will connect to the AP with these new parameters;
	in case 'b': 
		The Registrar will be re-configured with AP's configurations, 
		and will connect to the AP with these new parameters.

2.2) PBC mode: 
	 	same scenarios as PIN mod

(i) [AP]
	Start PBC on the Enrollee WPS AP.

(ii)[RT2860 Linux WPS STA]
	iwpriv ra0 wsc_conf_mode 2		;; Registrar
	iwpriv ra0 wsc_mode 2			;; PBC
	iwpriv ra0 wsc_ap_band 0 (or 1)	;; 0: prefer 2.4, 1: prefer 5G
	iwpriv ra0 wsc_start

{iii) If the registration is successful;
	in case 'a': 
		The Registrar will be re-configured with the new parameters, 
		and will connect to the AP with these new parameters;
	in case 'b': 
		The Registrar will be re-configured with AP's configurations, 
		and will connect to the AP with these new parameters.


3. Others
	iwpriv ra0 wsc_cred_count 1					;; Set count of credentials, Only support one credential for M8 in Registrar mode.
		integer: 1 ~ 8

	iwpriv ra0 wsc_cred_ssid "idx ssid_str"		;; Set SSID into credtentail[idx]
		string:
				 idx: 0 ~ 7
				 ssid_str: SSID for AP
		example:
				 iwpriv ra0 wsc_cred_ssid "0 wps_ap1"

	iwpriv ra0 wsc_cred_auth "idx auth_str"		;; Set AuthMode into credtentail[idx]
		string:
				 idx: 0 ~ 7
				 auth_str: OPEN, WPAPSK, WPA2PSK, SHARED, WPA, WPA2
		example:
				 iwpriv ra0 wsc_cred_auth "0 WPAPSK"

	iwpriv ra0 wsc_cred_encr "idx encr_str"		;; Set EncrypType into credtentail[idx]
		string:
				 idx: 0 ~ 7
				 encr_str: NONE, WEP, TKIP, AES
		example:
				 iwpriv ra0 wsc_cred_encr "0 TKIP"

	iwpriv ra0 wsc_cred_keyIdx "idx key_index"	;; Set Key Index into credtentail[idx]
		string:
				 idx: 0 ~ 7
				 key_index: 1 ~ 4
		example:
				 iwpriv ra0 wsc_cred_keyIdx "0 1"

	iwpriv ra0 wsc_cred_key "idx key"			;; Set Key into credtentail[idx]
		string:
				 idx: 0 ~ 7
				 key: ASCII string (wep_key_len(=5,13), passphrase_len(=8~63)) 
					  OR 
					  Hex string (wep_key_len(=10,26), passphrase_len(=64))
		example:
				 iwpriv ra0 wsc_cred_key "0 12345678"	;; Passphrase
				 iwpriv ra0 wsc_cred_key "0 abcd"		;; WEP Key

	iwpriv ra0 wsc_cred_mac "idx mac_str"		;; Set AP's MAC into credtentail[idx]
		string:
				 idx: 0 ~ 7
				 mac_str: xx:xx:xx:xx:xx:xx
		example:
				 iwpriv ra0 wsc_cred_mac "0 00:11:22:33:44:55"

	iwpriv ra0 wsc_conn_by_idx	0				;; Connect AP by credential index.
		integer: 0 ~ 7

	iwpriv ra0 wsc_auto_conn 0					;; If the registration is successful, driver will re-connect to AP or not.
		integer: 0		;; Disabled, driver won't re-connect to AP with new configurations.
				 1		;; Enabled, driver will re-connect to AP with new configurations.
		Note. Default value is 1.

	iwpriv ra0 wsc_stop			;; Stop WSC work and don't wait upon two-minute timeout	
	iwpriv ra0 wsc_ap_band val
		val: 0	;; prefer 2.4G AP
			 1	;; prefer 5G AP
			 2	;; Auto
	iwpriv ra0 stat				;; Read statistics counter and WPS status.		
   