Check if ssid, password, ip and gateway are ""
This commit is contained in:
parent
37c7280a15
commit
bd2e6e56cf
|
@ -2,12 +2,12 @@ import network
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
def connect(ssid, password, ip, gateway):
|
def connect(ssid, password, ip, gateway):
|
||||||
if ssid is None or password is None:
|
if ssid == "" or password == "":
|
||||||
print("Missing ssid or password")
|
print("Missing ssid or password")
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
sta_if = network.WLAN(network.STA_IF)
|
sta_if = network.WLAN(network.STA_IF)
|
||||||
if ip is not None and gateway is not None:
|
if ip != "" and gateway != "":
|
||||||
sta_if.ifconfig((ip, '255.255.255.0', gateway, '1.1.1.1'))
|
sta_if.ifconfig((ip, '255.255.255.0', gateway, '1.1.1.1'))
|
||||||
if not sta_if.isconnected():
|
if not sta_if.isconnected():
|
||||||
print('connecting to network...')
|
print('connecting to network...')
|
||||||
|
|
Loading…
Reference in New Issue