26 lines
649 B
Python
26 lines
649 B
Python
import esp
|
|
import network
|
|
|
|
def disable_dhcp():
|
|
esp.osdebug(None)
|
|
nic = network.WLAN(network.STA_IF)
|
|
nic.active(True)
|
|
nic.ifconfig((nic.ifconfig()[0], '255.255.255.0', '0.0.0.0', '0.0.0.0'))
|
|
|
|
def connect(ssid, password):
|
|
esp.sleep_type(esp.SLEEP_LIGHT)
|
|
nic = network.WLAN(network.STA_IF)
|
|
nic.active(True)
|
|
if not nic.isconnected():
|
|
nic.connect(ssid, password)
|
|
|
|
def config(ip, subnet, gateway):
|
|
esp.sleep_type(esp.SLEEP_LIGHT)
|
|
nic = network.WLAN(network.STA_IF)
|
|
nic.ifconfig((ip, subnet, gateway, '0.0.0.0'))
|
|
|
|
def isconnected():
|
|
esp.sleep_type(esp.SLEEP_LIGHT)
|
|
nic = network.WLAN(network.STA_IF)
|
|
return nic.isconnected()
|