src/eric7/MicroPython/Devices/CircuitPythonDevices.py

branch
eric7
changeset 11263
28f0ead11a82
parent 11236
75c26fe1d1c7
child 11267
9fc085d7e4fd
--- a/src/eric7/MicroPython/Devices/CircuitPythonDevices.py	Mon May 05 10:17:49 2025 +0200
+++ b/src/eric7/MicroPython/Devices/CircuitPythonDevices.py	Mon May 05 17:40:08 2025 +0200
@@ -800,13 +800,14 @@
     station = {
         'active': r.enabled and r.ipv4_address is not None,
         'connected': r.ipv4_address is not None,
+        'mac': binascii.hexlify(r.mac_address, ':').decode(),
         'ifconfig': (
             str(r.ipv4_address) if r.ipv4_address else'0.0.0.0',
             str(r.ipv4_subnet) if r.ipv4_subnet else'0.0.0.0',
             str(r.ipv4_gateway) if r.ipv4_gateway else'0.0.0.0',
             str(r.ipv4_dns) if r.ipv4_dns else'0.0.0.0',
         ),
-        'mac': binascii.hexlify(r.mac_address, ':').decode(),
+        'ipv6_addr': [],
     }
     try:
         station['txpower'] = r.tx_power
@@ -834,13 +835,14 @@
     ap = {
         'active': r.enabled and r.ipv4_address_ap is not None,
         'connected': r.ipv4_address_ap is not None,
+        'mac': binascii.hexlify(r.mac_address_ap, ':').decode(),
         'ifconfig': (
             str(r.ipv4_address_ap) if r.ipv4_address_ap else'0.0.0.0',
             str(r.ipv4_subnet_ap) if r.ipv4_subnet_ap else'0.0.0.0',
             str(r.ipv4_gateway_ap) if r.ipv4_gateway_ap else'0.0.0.0',
             str(r.ipv4_dns) if r.ipv4_dns else'0.0.0.0',
         ),
-        'mac': binascii.hexlify(r.mac_address_ap, ':').decode(),
+        'ipv6_addr': [],
     }
     try:
         ap['txpower'] = r.tx_power
@@ -852,6 +854,7 @@
         'active': r.enabled,
         'hostname': r.hostname,
     }
+    overall['prefer'] = 4
     print(json.dumps(overall))
 
 wifi_status()
@@ -1388,8 +1391,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}
@@ -1402,7 +1406,7 @@
     res = {{
         'active': nic.link_status != 0,
         'connected': nic.link_status == 1 and nic.ifconfig[0] != b'\x00\x00\x00\x00',
-        'ifconfig': (
+        'ipv4_addr': (
             nic.pretty_ip(nic.ifconfig[0]),
             nic.pretty_ip(nic.ifconfig[1]),
             nic.pretty_ip(nic.ifconfig[2]),
@@ -1424,19 +1428,20 @@
         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((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"]))
-        status.append((self.tr("Chip Type"), ethStatus["chip"]))
-        status.append((self.tr("max. Sockets"), ethStatus["max_sockets"]))
+        status = [
+            (self.tr("Active"), self.bool2str(ethStatus["active"])),
+            (self.tr("Connected"), self.bool2str(ethStatus["connected"])),
+            (self.tr("MAC-Address"), ethStatus["mac"]),
+            (self.tr("Chip Type"), ethStatus["chip"]),
+            (self.tr("max. Sockets"), ethStatus["max_sockets"]),
+        ]
+        addressInfo = {
+            "ipv4": ethStatus["ipv4_addr"],
+            "ipv6": [],
+        }
 
-        return status
+        return status, addressInfo
 
     def connectToLan(self, config, hostname):
         """

eric ide

mercurial