make password configs be in a different file, don't publish passwords in git

This commit is contained in:
Maff 2018-06-02 00:23:08 +01:00
parent 3a17e7f218
commit 2f8c2ef767
4 changed files with 12 additions and 8 deletions

2
.gitignore vendored
View File

@ -96,3 +96,5 @@ ENV/
.idea/ .idea/
.vscode/ .vscode/
/wifi_cfg.py
/webrepl_cfg.py

14
boot.py
View File

@ -1,5 +1,6 @@
from network import WLAN as wlan, STA_IF as staif, AP_IF as apif from network import WLAN as wlan, STA_IF as staif, AP_IF as apif
from time import sleep_ms from time import sleep_ms
from wifi_cfg import wlan_nets
sleep_ms(100) sleep_ms(100)
#make sure AP mode is off and station mode is on #make sure AP mode is off and station mode is on
@ -15,14 +16,11 @@ if wlan(staif).isconnected() != True:
nets=wlan(staif).scan() nets=wlan(staif).scan()
found_net=False found_net=False
for net in nets: for net in nets:
if net[0] == b'WiFiNetworkName': for cfg_net in wlan_nets.keys():
wlan(staif).connect("WiFiNetworkName","WiFiNetworkPSK") if net[0] == b'%s' % cfg_net:
found_net=True wlan(staif).connect(cfg_net, wlan_nets[cfg_net])
break found_net=True
elif net[0] == b'WiFiNetworkName': break
wlan(staif).connect("WiFiNetworkName","WiFiNetworkPSK")
found_net=True
break
if found_net == False: if found_net == False:
print("couldn't connect to wifi, nets found: %s" % nets) print("couldn't connect to wifi, nets found: %s" % nets)
print("to fix temporarily, run: wlan(staif).connect('yournet','yourpass'), followed shortly after by wlan(staif).ifconfig()") print("to fix temporarily, run: wlan(staif).connect('yournet','yourpass'), followed shortly after by wlan(staif).ifconfig()")

1
webrepl_cfg.sample.py Normal file
View File

@ -0,0 +1 @@
PASS='MyWebREPLPassword'

3
wifi_cfg.sample.py Normal file
View File

@ -0,0 +1,3 @@
wlan_nets={
'YourNetwork': 'YourPSK',
}