66 lines
1.8 KiB
Python
Raw Normal View History

2023-01-24 21:00:02 +08:00
import _network
2023-01-24 21:10:06 +08:00
STA_IF = _network.STA_IF
AP_IF = _network.AP_IF
2023-01-24 21:00:02 +08:00
2023-01-24 21:10:06 +08:00
STAT_IDLE = _network.STAT_IDLE
STAT_CONNECTING = _network.STAT_CONNECTING
STAT_WRONG_PASSWORD = _network.STAT_WRONG_PASSWORD
STAT_NO_AP_FOUND = _network.STAT_NO_AP_FOUND
STAT_CONNECT_FAIL = _network.STAT_CONNECT_FAIL
STAT_GOT_IP = _network.STAT_GOT_IP
2023-01-24 21:00:02 +08:00
2023-07-17 10:11:12 +08:00
_instence:"WLAN" = None
2023-01-24 21:00:02 +08:00
class WLAN(_network.WLAN):
2023-01-24 23:40:41 +08:00
def __init__(self, interface_id: int):
2023-07-17 10:11:12 +08:00
global _instence
2023-01-24 21:00:02 +08:00
super().__init__(interface_id)
2023-07-17 10:11:12 +08:00
if _instence is None:
_instence = self
2023-01-24 23:40:41 +08:00
2023-01-24 21:00:02 +08:00
def active(self, is_active=None):
if is_active is None:
return super().checkActive()
else:
return super().active(is_active)
2023-01-24 23:40:41 +08:00
2023-01-24 21:00:02 +08:00
def connect(self, ssid=None, key=None, bssid=None):
if bssid is None:
return super().connect(ssid, key)
else:
return super().connectWithBssid(ssid, key, bssid)
2023-01-24 23:40:41 +08:00
2023-01-24 21:00:02 +08:00
def disconnect(self):
return super().disconnect()
2023-01-24 23:40:41 +08:00
2023-01-24 21:00:02 +08:00
def status(self, param=None):
if param is None:
return super().status()
else:
return super().statusWithParam(param)
2023-01-24 23:40:41 +08:00
2023-01-24 21:00:02 +08:00
def isconnected(self) -> int:
return super().isconnected()
2023-01-24 23:40:41 +08:00
2023-01-24 21:00:02 +08:00
def config(self, *para, **kwargs):
if len(para) == 1:
return super().checkConfig(para[0])
else:
return super().config(**kwargs)
2023-01-24 23:40:41 +08:00
2023-01-24 21:00:02 +08:00
def ifconfig(self, config=None):
if config is None:
2023-01-24 23:40:41 +08:00
t = super().checkIfconfig()
return (t[0], t[1], t[2], t[3])
2023-01-24 21:00:02 +08:00
else:
2023-01-24 23:40:41 +08:00
return super().ifconfig(
2023-01-27 22:47:48 +08:00
config[0], config[1], config[2], config[3])
2023-01-24 23:40:41 +08:00
def scan(self):
return super().scan()
2023-07-17 10:11:12 +08:00
def isconnected():
if _instence is None:
return False
return _instence.isconnected()