add
This commit is contained in:
25
ESP-codes/MicroPython/wifi.py
Normal file
25
ESP-codes/MicroPython/wifi.py
Normal file
@@ -0,0 +1,25 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user