kopia lustrzana https://github.com/tayfunulu/WiFiManager
code: fix wording / grammar
rodzic
b23e52ec53
commit
1ea05254a4
19
main.py
19
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):
|
||||
|
@ -20,25 +20,24 @@ def do_connect(ntwrk_ssid, netwrk_pass):
|
|||
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)
|
||||
|
||||
|
@ -73,4 +72,4 @@ if check_connection():
|
|||
# import sample_mqtt.py
|
||||
|
||||
else:
|
||||
print("There is something wrong")
|
||||
print("There is something wrong.")
|
||||
|
|
|
@ -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
|
||||
|
@ -29,7 +29,7 @@ def do_connect(ntwrk_ssid, netwrk_pass):
|
|||
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:
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue