From 2f8c2ef767fb3297f7c8a349ff79c9b988dfd88f Mon Sep 17 00:00:00 2001 From: Maff Date: Sat, 2 Jun 2018 00:23:08 +0100 Subject: [PATCH] make password configs be in a different file, don't publish passwords in git --- .gitignore | 2 ++ boot.py | 14 ++++++-------- webrepl_cfg.sample.py | 1 + wifi_cfg.sample.py | 3 +++ 4 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 webrepl_cfg.sample.py create mode 100644 wifi_cfg.sample.py diff --git a/.gitignore b/.gitignore index cee105b..bf4867b 100644 --- a/.gitignore +++ b/.gitignore @@ -96,3 +96,5 @@ ENV/ .idea/ .vscode/ +/wifi_cfg.py +/webrepl_cfg.py \ No newline at end of file diff --git a/boot.py b/boot.py index 84c470e..4f9dcf9 100644 --- a/boot.py +++ b/boot.py @@ -1,5 +1,6 @@ from network import WLAN as wlan, STA_IF as staif, AP_IF as apif from time import sleep_ms +from wifi_cfg import wlan_nets sleep_ms(100) #make sure AP mode is off and station mode is on @@ -15,14 +16,11 @@ if wlan(staif).isconnected() != True: nets=wlan(staif).scan() found_net=False for net in nets: - if net[0] == b'WiFiNetworkName': - wlan(staif).connect("WiFiNetworkName","WiFiNetworkPSK") - found_net=True - break - elif net[0] == b'WiFiNetworkName': - wlan(staif).connect("WiFiNetworkName","WiFiNetworkPSK") - found_net=True - break + for cfg_net in wlan_nets.keys(): + if net[0] == b'%s' % cfg_net: + wlan(staif).connect(cfg_net, wlan_nets[cfg_net]) + found_net=True + break if found_net == False: 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()") diff --git a/webrepl_cfg.sample.py b/webrepl_cfg.sample.py new file mode 100644 index 0000000..9eb6b82 --- /dev/null +++ b/webrepl_cfg.sample.py @@ -0,0 +1 @@ +PASS='MyWebREPLPassword' \ No newline at end of file diff --git a/wifi_cfg.sample.py b/wifi_cfg.sample.py new file mode 100644 index 0000000..96ff3a6 --- /dev/null +++ b/wifi_cfg.sample.py @@ -0,0 +1,3 @@ +wlan_nets={ + 'YourNetwork': 'YourPSK', +} \ No newline at end of file