From 1ea05254a419a59b04e019aeb4fe59a22bb70857 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 11 Dec 2017 15:06:47 +0100 Subject: [PATCH] code: fix wording / grammar --- main.py | 25 ++++++++++++------------- networkconfig.py | 15 +++++++-------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/main.py b/main.py index 9181aa8..6c359ac 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ def do_connect(ntwrk_ssid, netwrk_pass): sta_if = network.WLAN(network.STA_IF) sta_if.active(True) if not sta_if.isconnected(): - print('try to connect : ' + ntwrk_ssid + ' network...') + print('Trying to connect to %s...' % ntwrk_ssid) sta_if.connect(ntwrk_ssid, netwrk_pass) a = 0 while not sta_if.isconnected() | (a > 99): @@ -17,28 +17,27 @@ def do_connect(ntwrk_ssid, netwrk_pass): a += 1 print('.', end='') if sta_if.isconnected(): - print('\nConnected. Network config:', sta_if.ifconfig()) + print('\nConnected. Network config: ', sta_if.ifconfig()) return (True) else: - print('\nProblem. Not Connected to :' + ntwrk_ssid) + print('\nFailed. Not Connected to: ' + ntwrk_ssid) return (False) def check_connection(): global wlan_sta - # Firstly check is there any connection + # First check if there already is any connection: if wlan_sta.isconnected(): return (True) try: - # connection of ESP to WiFi takes time - # wait 3 sec. and try again. + # ESP connecting to WiFi takes time, wait a bit and try again: time.sleep(3) if not wlan_sta.isconnected(): - # inside passwd file. there are list of WiFi network CSV file + # inside passwd file, there is a list of WiFi networks (CSV format) f = open("passwd.dat") data = f.readlines() f.close() - # Search WiFi's in range + # Search WiFis in range ssids_found = wlan_sta.scan() # matching... @@ -47,7 +46,7 @@ def check_connection(): for i in ssids_found: if ssid_list[0] in i[0]: - print("OK. WiFi is Founded") + print("OK. WiFi found.") if do_connect(ssid_list[0], ssid_list[1]): return (True) @@ -58,7 +57,7 @@ def check_connection(): return (True) except OSError: - # Web server for connection manager + # start web server for connection manager: if networkconfig.start(): return (True) @@ -69,8 +68,8 @@ if check_connection(): # Main Code is here print("ESP OK") -# to import your code; -# import sample_mqtt.py + # to import your code; + # import sample_mqtt.py else: - print("There is something wrong") + print("There is something wrong.") diff --git a/networkconfig.py b/networkconfig.py index 34738f2..4b75a33 100644 --- a/networkconfig.py +++ b/networkconfig.py @@ -6,7 +6,7 @@ import time wlan_ap = network.WLAN(network.AP_IF) wlan_sta = network.WLAN(network.STA_IF) -# setup for ssid +# SSID/Password for setup ssid_name = "WifiManager" ssid_password = "tayfunulu" @@ -17,7 +17,7 @@ def do_connect(ntwrk_ssid, netwrk_pass): sta_if = network.WLAN(network.STA_IF) sta_if.active(True) if not sta_if.isconnected(): - print('try to connect : ' + ntwrk_ssid + ' network...') + print('Trying to connect to %s...' % ntwrk_ssid) sta_if.active(True) sta_if.connect(ntwrk_ssid, netwrk_pass) a = 0 @@ -26,10 +26,10 @@ def do_connect(ntwrk_ssid, netwrk_pass): a += 1 print('.', end='') if sta_if.isconnected(): - print('\nConnected. Network config:', sta_if.ifconfig()) + print('\nConnected. Network config: ', sta_if.ifconfig()) return (True) else: - print('\nProblem. Not Connected to :' + ntwrk_ssid) + print('\nFailed. Not Connected to: ' + ntwrk_ssid) return (False) @@ -117,7 +117,6 @@ def handle_configure(client, request): fo = open("passwd.dat", "w") fo.write(ssid + ";" + password + "\n") fo.close() - return (True) else: response_footer = """ @@ -163,9 +162,9 @@ def start(port=80): server_socket.bind(addr) server_socket.listen(1) - print('Connect to Wifi ssid :' + ssid_name + ' , Default pass: ' + ssid_password) - print('And connect to esp via your favorite web browser (like 192.168.4.1)') - print('listening on', addr) + print('Connect to WiFi ssid ' + ssid_name + ', default password: ' + ssid_password) + print('and access the ESP via your favorite web browser at 192.168.4.1.') + print('Listening on:', addr) while True: