Check if ssid, password, ip and gateway are ""

This commit is contained in:
jimmy 2025-05-19 19:31:30 +12:00
parent 37c7280a15
commit bd2e6e56cf
1 changed files with 2 additions and 2 deletions

View File

@ -2,12 +2,12 @@ import network
from time import sleep
def connect(ssid, password, ip, gateway):
if ssid is None or password is None:
if ssid == "" or password == "":
print("Missing ssid or password")
return None
try:
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'))
if not sta_if.isconnected():
print('connecting to network...')