diff --git a/shittyrobot.py b/shittyrobot.py index dd9bca5..d2c330f 100644 --- a/shittyrobot.py +++ b/shittyrobot.py @@ -5,6 +5,7 @@ import select import neopixel from machine import Pin import errno +import machine def do_connect(tries=0): if tries > 3: @@ -33,22 +34,23 @@ def do_connect(tries=0): def do_ap(): ap_if = network.WLAN(network.WLAN.IF_AP) ap_if.active(True) - ap_if.config(ssid='My AP123', channel=13, key='asdf1234') + ap_if.config(ssid='My AP123', channel=11, key='asdf1234') ap_if.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8')) print(ap_if.config('ssid')) print(ap_if.config('channel')) print('AP ready.') - # wait for someone to connect - for i in range(30): - if ap_if.isconnected(): - print('Client connected') - return - time.sleep(1) + if False: + # wait for someone to connect + for i in range(60): + if ap_if.isconnected(): + print('Client connected') + return + time.sleep(1) - # reset device - print('Timeout waiting for client. Resetting device..') - machine.reset() + # reset device + print('Timeout waiting for client. Resetting device..') + machine.reset() def setup_listener(): @@ -157,7 +159,7 @@ def mainloop(l): print('RCV: ', a) y.write(a) except OSError as e: - if e.errno == errno.EWOULDBLOCK or e.errno == errno.EAGAIN: + if e.errno == errno.ETIMEDOUT or e.errno == errno.EAGAIN: # timeout a = b'x' else: