add gitignore, update config.ini and read config.ini in boot.py

This commit is contained in:
Michaël Ricart 2018-03-08 23:36:46 +01:00
parent f08049b4a6
commit 38360f58e1
3 changed files with 27 additions and 6 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.pyc

View file

@ -1,18 +1,31 @@
def do_connect():
import uConfigParser
import gc
import webrepl
def do_connect(ssid, key):
import network
import gc
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect("MIPS", "importthis")
wlan.connect(ssid, key)
while not wlan.isconnected():
pass
print('network config:', wlan.ifconfig())
gc.collect()
config_obj = uConfigParser.ConfigParser()
config_obj.read('config.ini')
config = config_obj.config_dict
if config_obj.has_option('DEFAULT','ssid') and config_obj.has_option('DEFAULT','key'):
do_connect(config['DEFAULT']['ssid'], config['DEFAULT']['key'])
else:
do_connect()
import gc
import webrepl
if config_obj.has_option('DEFAULT','webrepl_passwd'):
webrepl.start(password=config['DEFAULT']['webrepl_passwd'])
else:
webrepl.start()
gc.collect()

View file

@ -0,0 +1,7 @@
[DEFAULT]
ssid = MIPS
key = importthis
webrepl_passwd = totocaca