diff -r b984f0085bed -r 75c26fe1d1c7 src/eric7/MicroPython/Devices/RP2Devices.py --- a/src/eric7/MicroPython/Devices/RP2Devices.py Fri Apr 25 16:22:02 2025 +0200 +++ b/src/eric7/MicroPython/Devices/RP2Devices.py Fri Apr 25 16:23:02 2025 +0200 @@ -98,6 +98,25 @@ }, } + self.__securityMapping = { + "SEC_DPP": "DPP", + "SEC_OPEN": self.tr("Open"), + "SEC_OWE": "OWE", + "SEC_WAPI": "WAPI", + "SEC_WEP": "WEP", + "SEC_WPA": "WPA", + "SEC_WPA_WPA2": "WPA/WPA2", + "SEC_WPA2": "WPA2", + "SEC_WPA2_ENT": "WPA2 Enterprise", + "SEC_WPA2_WPA3": "WPA2/WPA3", + "SEC_WPA2_WPA3_ENT": "WPA2/WPA3 Enterprise", + "SEC_WPA3": "WPA3", + "SEC_WPA3_ENT": "WPA3 Enterprise", + "SEC_WPA3_ENT_192": "WPA3 Enterprise (192-bit)", + "SEC_WPA3_EXT_PSK": "WPA3 Extended", + "SEC_WPA3_EXT_PSK_MIXED_MODE": "WPA3 Extended, Mixed Mode", + } + def setButtons(self): """ Public method to enable the supported action buttons. @@ -560,6 +579,12 @@ import network import rp2 + def security_str(mode): + for sm in [e for e in dir(network.WLAN) if e.startswith('SEC_')]: + if getattr(network.WLAN, sm, 0) == mode: + return sm + return "" + wifi = network.WLAN(network.STA_IF) station = { 'active': wifi.active(), @@ -582,6 +607,7 @@ 'channel': wifi.config('channel'), 'txpower': wifi.config('txpower'), 'essid': wifi.config('essid'), + 'ap_security': security_str(wifi.config('security')), } print(ujson.dumps(ap)) @@ -698,6 +724,12 @@ station["ap_security"] = self.tr("unknown ({0})").format( station["ap_security"] ) + if "ap_security" in ap and self._deviceData["wifi_type"] == "picow": + try: + ap["ap_security"] = self.__securityMapping[ap["ap_security"]] + except KeyError: + ap["ap_security"] = self.tr("unknown ({0})").format(ap["ap_security"]) + return station, ap, overall def connectWifi(self, ssid, password, hostname): @@ -1219,8 +1251,8 @@ @param ssid SSID of the access point @type str - @param security security method (defaults to None) - @type int (optional) + @param security security mode (defaults to None) (unused) + @type str (optional) @param password password (defaults to None) @type str (optional) @param hostname host name of the device (defaults to None) @@ -1232,15 +1264,13 @@ @rtype tuple of (bool, str) """ if security is None or password is None: - security = 0 + security = "SEC_OPEN" password = "" # secok if self._deviceData["wifi_type"] == "picow": country = Preferences.getMicroPython("WifiCountry").upper() - if security: - security = 4 # Pico W supports just WPA/WPA2 command = """ -def start_ap(ssid, security, password, hostname, ifconfig, country): +def start_ap(ssid, password, hostname, ifconfig, country): import network import rp2 from time import sleep @@ -1257,19 +1287,19 @@ ap.active(True) if ifconfig: ap.ifconfig(ifconfig) - ap.config(ssid=ssid, security=security, password=password) + ap.config(ssid=ssid, security=network.WLAN.{5}, password=password) sleep(0.1) print(ap.status() == network.STAT_GOT_IP) -start_ap({0}, {1}, {2}, {3}, {4}, {5}) +start_ap({0}, {1}, {2}, {3}, {4}) del start_ap """.format( repr(ssid), - security, repr(password), repr(hostname), ifconfig, repr(country if country else "XX"), + security, ) elif self._deviceData["wifi_type"] == "picowireless": if ifconfig: