Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

add WPS support #218

Closed
wants to merge 1 commit into from
Closed

add WPS support #218

wants to merge 1 commit into from

Conversation

jhgoebbert
Copy link

@jhgoebbert jhgoebbert commented Nov 3, 2017

This adds WPS support.
In Python WPS can be used like this:

from network import WLAN,STA_IF
from network import STA_WPS_PROBING, STA_WPS_SUCCESS, STA_WPS_FAILED, STA_WPS_TIMEOUT
from time import sleep

wlan = WLAN(STA_IF) # get current object, without changing the mode
wlan.active(True)

wlan.start_wps()
while wlan.status() == STA_WPS_PROBING:
    print("probing with WPS")
	sleep(0.5)
	
if wlan.status() == STA_WPS_SUCCESS:
    print("WPS successful")
	print("   ESSID:    ", wlan.config('essid')
	print("   Password: ", wlan.config('password')
	
	# connect using these credentials
	wlan.connect(wlan.config('essid'), wlan.config('password'))
	print("Waiting for connection...")
    while not wlan.isconnected():
        idle() # save power while waiting
    print("Connected.")
	
elif wlan.status() == STA_WPS_FAILED:
    print("WPS failed")
	# attention: triggers disconnect event (which results in a reconnect with last essid/passwd)
	
elif wlan.status() == STA_WPS_TIMEOUT:
    print("WPS timeout")
	# attention: triggers disconnect event (which results in a reconnect with last essid/passwd)

@mactijn
Copy link

mactijn commented Dec 30, 2017

I've backported this to the main repo: micropython/micropython#3530

Also, in your example, lines 15 and 16 both miss a ")" at the end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants