diff -r 07d9cc8d773c -r 28f0ead11a82 src/eric7/MicroPython/Devices/RP2Devices.py --- a/src/eric7/MicroPython/Devices/RP2Devices.py Mon May 05 10:17:49 2025 +0200 +++ b/src/eric7/MicroPython/Devices/RP2Devices.py Mon May 05 17:40:08 2025 +0200 @@ -611,11 +611,21 @@ 'active': wifi.active(), 'connected': wifi.isconnected(), 'status': wifi.status(), - 'ifconfig': wifi.ifconfig(), 'mac': ubinascii.hexlify(wifi.config('mac'), ':').decode(), 'channel': wifi.config('channel'), + 'essid': wifi.config('essid'), 'txpower': wifi.config('txpower'), } + try: + station['ifconfig'] = ( + wifi.ipconfig('addr4') + (wifi.ipconfig('gw4'), network.ipconfig('dns')) + ) + except AttributeError: + station['ifconfig'] = wifi.ifconfig() + try: + station['ipv6_addr'] = [a[0] for a in wifi.ipconfig('addr6')] + except ValueError: + station['ipv6_addr'] = [] print(ujson.dumps(station)) wifi = network.WLAN(network.AP_IF) @@ -623,13 +633,22 @@ 'active': wifi.active(), 'connected': wifi.isconnected(), 'status': wifi.status(), - 'ifconfig': wifi.ifconfig(), 'mac': ubinascii.hexlify(wifi.config('mac'), ':').decode(), 'channel': wifi.config('channel'), 'txpower': wifi.config('txpower'), 'essid': wifi.config('essid'), 'ap_security': security_str(wifi.config('security')), } + try: + ap['ifconfig'] = ( + wifi.ipconfig('addr4') + (wifi.ipconfig('gw4'), network.ipconfig('dns')) + ) + except AttributeError: + ap['ifconfig'] = wifi.ifconfig() + try: + ap['ipv6_addr'] = [a[0] for a in wifi.ipconfig('addr6')] + except ValueError: + ap['ipv6_addr'] = [] print(ujson.dumps(ap)) overall = { @@ -643,6 +662,10 @@ overall['hostname'] = network.hostname() except AttributeError: pass + try: + overall['prefer'] = network.ipconfig('prefer') + except ValueError: + overall['prefer'] = 4 print(ujson.dumps(overall)) wifi_status() @@ -662,13 +685,14 @@ 'active': pw.get_connection_status() not in (0, 7, 8, 9), 'connected': pw.get_connection_status() == 3, 'status': pw.get_connection_status(), + 'mac': ubinascii.hexlify(pw.get_mac_address(), ':').decode(), 'ifconfig': ( ip_str(pw.get_ip_address()), ip_str(pw.get_subnet_mask()), ip_str(pw.get_gateway_ip()), '0.0.0.0' ), - 'mac': ubinascii.hexlify(pw.get_mac_address(), ':').decode(), + 'ipv6_addr': [], } if station['connected']: station.update({ @@ -685,6 +709,7 @@ 'status': pw.get_connection_status(), 'mac': ubinascii.hexlify(pw.get_mac_address(), ':').decode(), 'ap_security': pw.get_current_encryption_type(), + 'ipv6_addr': [], } if ap['active']: ap['essid'] = pw.get_current_ssid() @@ -697,7 +722,8 @@ print(ujson.dumps(ap)) overall = { - 'active': pw.get_connection_status() != 0 + 'active': pw.get_connection_status() != 0, + 'prefer': 4, } print(ujson.dumps(overall)) @@ -1858,8 +1884,9 @@ Public method to get Ethernet status data of the connected board. @return list of tuples containing the translated status data label and - the associated value - @rtype list of tuples of (str, str) + the associated value and a dictionary with keys 'ipv4' and 'ipv6' + containing the respective address information + @rtype tuple of list of tuples of (str, str) and dict @exception OSError raised to indicate an issue with the device """ command = """{0} @@ -1874,13 +1901,26 @@ 'active': nic.active(), 'connected': nic.isconnected(), 'status': nic.status(), - 'ifconfig': nic.ifconfig(), 'mac': ubinascii.hexlify(nic.config('mac'), ':').decode(), }} try: + res['ipv4_addr'] = ( + nic.ipconfig('addr4') + (nic.ipconfig('gw4'), network.ipconfig('dns')) + ) + except AttributeError: + res['ipv4_addr'] = nic.ifconfig() + try: + res['ipv6_addr'] = [a[0] for a in nic.ipconfig('addr6')] + except ValueError: + res['ipv6_addr'] = [] + try: res['hostname'] = network.hostname() except AttributeError: res['hostname'] = '' + try: + res['prefer'] = network.ipconfig('prefer') + except ValueError: + res['prefer'] = 4 print(ujson.dumps(res)) ethernet_status() @@ -1893,29 +1933,26 @@ if err: raise OSError(self._shortError(err)) - status = [] ethStatus = json.loads(out.decode("utf-8")) - status.append((self.tr("Active"), self.bool2str(ethStatus["active"]))) - status.append((self.tr("Connected"), self.bool2str(ethStatus["connected"]))) - status.append( + status = [ + (self.tr("Active"), self.bool2str(ethStatus["active"])), + (self.tr("Connected"), self.bool2str(ethStatus["connected"])), ( self.tr("Status"), self.__statusTranslations["picowiz"][ethStatus["status"]], - ) - ) - status.append( + ), ( self.tr("Hostname"), ethStatus["hostname"] if ethStatus["hostname"] else self.tr("unknown"), - ) - ) - status.append((self.tr("IPv4 Address"), ethStatus["ifconfig"][0])) - status.append((self.tr("Netmask"), ethStatus["ifconfig"][1])) - status.append((self.tr("Gateway"), ethStatus["ifconfig"][2])) - status.append((self.tr("DNS"), ethStatus["ifconfig"][3])) - status.append((self.tr("MAC-Address"), ethStatus["mac"])) + ), + (self.tr("MAC-Address"), ethStatus["mac"]), + ] + addressInfo = { + "ipv4": ethStatus["ipv4_addr"], + "ipv6": ethStatus["ipv6_addr"], + } - return status + return status, addressInfo def connectToLan(self, config, hostname): """