network.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 LAN(_network.LAN):
  12. def __init__(self, interface_id: int):
  13. super().__init__(interface_id)
  14. def active(self, is_active=None):
  15. if is_active is None:
  16. return super().checkActive()
  17. else:
  18. return super().active(is_active)
  19. def status(self, param=None):
  20. if param is None:
  21. return super().status()
  22. else:
  23. return super().statusWithParam(param)
  24. def isconnected(self) -> int:
  25. return super().isconnected()
  26. def config(self, *para, **kwargs):
  27. if len(para) == 1:
  28. return super().checkConfig(para[0])
  29. else:
  30. return super().config(**kwargs)
  31. def ifconfig(self, config=None):
  32. if config is None:
  33. t = super().checkIfconfig()
  34. return (t[0], t[1], t[2], t[3])
  35. else:
  36. return super().ifconfig(
  37. config[0], config[1], config[2], config[3])
  38. class WLAN(_network.WLAN):
  39. def __init__(self, interface_id: int):
  40. global _instence
  41. super().__init__(interface_id)
  42. if _instence is None:
  43. _instence = self
  44. def active(self, is_active=None):
  45. if is_active is None:
  46. return super().checkActive()
  47. else:
  48. return super().active(is_active)
  49. def connect(self, ssid=None, key=None, bssid=None):
  50. if bssid is None:
  51. return super().connect(ssid, key)
  52. else:
  53. return super().connectWithBssid(ssid, key, bssid)
  54. def disconnect(self):
  55. return super().disconnect()
  56. def status(self, param=None):
  57. if param is None:
  58. return super().status()
  59. else:
  60. return super().statusWithParam(param)
  61. def isconnected(self) -> int:
  62. return super().isconnected()
  63. def config(self, *para, **kwargs):
  64. if len(para) == 1:
  65. return super().checkConfig(para[0])
  66. else:
  67. return super().config(**kwargs)
  68. def ifconfig(self, config=None):
  69. if config is None:
  70. t = super().checkIfconfig()
  71. return (t[0], t[1], t[2], t[3])
  72. else:
  73. return super().ifconfig(
  74. config[0], config[1], config[2], config[3])
  75. def scan(self):
  76. return super().scan()
  77. def isconnected():
  78. if _instence is None:
  79. return False
  80. return _instence.isconnected()