Failsafe WLAN script

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
Post Reply
Posts: 15
Joined: Thu Aug 04, 2016 3:04 pm

Failsafe WLAN script

Post by quantalume » Wed Sep 14, 2016 6:55 pm

I'm trying to come up with a script that will attempt to connect to the local wireless router in station mode but fall back to access point if unsuccessful. Here is what I have:

Code: Select all

# -- put your code here!
from network import WLAN
import time

ssid = 'xxxxx'
auth = (WLAN.WPA2, 'xxxxxxxx')

wlan.connect(ssid=ssid, auth=auth, timeout=30000)
secs = 0

while (not wlan.isconnected() and secs < 30):
    secs += 1

if secs == 30:
    wlan.init(mode=WLAN.AP, ssid='wipy-wlan', auth=(WLAN.WPA2,''), channel=7, antenna=WLAN.EXT_ANT)
When the configured router is absent, the WiPy does not go into access point mode (it never appears in lists of local access points). Any idea why my script is failing? Thanks.

Post Reply