add gitignore, update config.ini and read config.ini in boot.py
This commit is contained in:
parent
f08049b4a6
commit
38360f58e1
3 changed files with 27 additions and 6 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.pyc
|
|
@ -1,18 +1,31 @@
|
||||||
def do_connect():
|
import uConfigParser
|
||||||
|
import gc
|
||||||
|
import webrepl
|
||||||
|
|
||||||
|
def do_connect(ssid, key):
|
||||||
import network
|
import network
|
||||||
|
import gc
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
if not wlan.isconnected():
|
if not wlan.isconnected():
|
||||||
print('connecting to network...')
|
print('connecting to network...')
|
||||||
wlan.connect("MIPS", "importthis")
|
wlan.connect(ssid, key)
|
||||||
while not wlan.isconnected():
|
while not wlan.isconnected():
|
||||||
pass
|
pass
|
||||||
print('network config:', wlan.ifconfig())
|
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()
|
do_connect()
|
||||||
|
if config_obj.has_option('DEFAULT','webrepl_passwd'):
|
||||||
import gc
|
webrepl.start(password=config['DEFAULT']['webrepl_passwd'])
|
||||||
import webrepl
|
else:
|
||||||
webrepl.start()
|
webrepl.start()
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
[DEFAULT]
|
||||||
|
|
||||||
|
ssid = MIPS
|
||||||
|
|
||||||
|
key = importthis
|
||||||
|
|
||||||
|
webrepl_passwd = totocaca
|
Loading…
Reference in a new issue