network.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import _network
  2. STA_IF = _network.STA_IF
  3. AP_IF = _network.AP_IF
  4. STAT_IDLE = _network.STAT_IDLE
  5. STAT_CONNECTING = _network.STAT_CONNECTING
  6. STAT_WRONG_PASSWORD = _network.STAT_WRONG_PASSWORD
  7. STAT_NO_AP_FOUND = _network.STAT_NO_AP_FOUND
  8. STAT_CONNECT_FAIL = _network.STAT_CONNECT_FAIL
  9. STAT_GOT_IP = _network.STAT_GOT_IP
  10. _instence:"WLAN" = None
  11. class WLAN(_network.WLAN):
  12. def __init__(self, interface_id: int):
  13. global _instence
  14. super().__init__(interface_id)
  15. if _instence is None:
  16. _instence = self
  17. def active(self, is_active=None):
  18. if is_active is None:
  19. return super().checkActive()
  20. else:
  21. return super().active(is_active)
  22. def connect(self, ssid=None, key=None, bssid=None):
  23. if bssid is None:
  24. return super().connect(ssid, key)
  25. else:
  26. return super().connectWithBssid(ssid, key, bssid)
  27. def disconnect(self):
  28. return super().disconnect()
  29. def status(self, param=None):
  30. if param is None:
  31. return super().status()
  32. else:
  33. return super().statusWithParam(param)
  34. def isconnected(self) -> int:
  35. return super().isconnected()
  36. def config(self, *para, **kwargs):
  37. if len(para) == 1:
  38. return super().checkConfig(para[0])
  39. else:
  40. return super().config(**kwargs)
  41. def ifconfig(self, config=None):
  42. if config is None:
  43. t = super().checkIfconfig()
  44. return (t[0], t[1], t[2], t[3])
  45. else:
  46. return super().ifconfig(
  47. config[0], config[1], config[2], config[3])
  48. def scan(self):
  49. return super().scan()
  50. def isconnected():
  51. if _instence is None:
  52. return False
  53. return _instence.isconnected()