src/eric7/MicroPython/EthernetDialogs/EthernetController.py

branch
mpy_network
changeset 9885
05cbf70e8f10
parent 9878
a82014a9e57b
child 10153
ffe7432f716b
--- a/src/eric7/MicroPython/EthernetDialogs/EthernetController.py	Sun Mar 12 17:01:54 2023 +0100
+++ b/src/eric7/MicroPython/EthernetDialogs/EthernetController.py	Tue Mar 14 13:16:06 2023 +0100
@@ -82,8 +82,9 @@
         from .EthernetStatusDialog import EthernetStatusDialog
 
         try:
-            status = self.__mpy.getDevice().getEthernetStatus()
-            # status is a list of user labels and associated values
+            with EricOverrideCursor():
+                status = self.__mpy.getDevice().getEthernetStatus()
+                # status is a list of user labels and associated values
 
             dlg = EthernetStatusDialog(status, self.__mpy)
             dlg.exec()
@@ -161,7 +162,8 @@
         """
         Private slot to check the availability of an internet connection.
         """
-        success, error = self.__mpy.getDevice().checkInternetViaLan()
+        with EricOverrideCursor():
+            success, error = self.__mpy.getDevice().checkInternetViaLan()
         if not error:
             msg = (
                 self.tr("<p>The internet connection is <b>available</b>.</p>")
@@ -197,15 +199,29 @@
             ifconfig = dlg.getIPv4Address()
             ok, err = self.__mpy.getDevice().writeLanAutoConnect(ifconfig)
             if ok:
-                EricMessageBox.information(
-                    None,
-                    self.tr("Write Auto-Connect Script"),
-                    self.tr(
-                        "<p>The auto-connect script and associated configuration was"
-                        " saved on the device. The device will connect to the LAN at"
-                        " boot time.</p>"
-                    ),
-                )
+                if self.__mpy.getDevice().hasCircuitPython():
+                    # CircuitPython will reset for the REPL, so no auto-connect
+                    # available.
+                    EricMessageBox.information(
+                        None,
+                        self.tr("Write Auto-Connect Script"),
+                        self.tr(
+                            "<p>The auto-connect script and associated configuration"
+                            " was saved on the device. Use the script like this:</p>"
+                            "<p>import wiznet_connect<br/>"
+                            "nic = wiznet_connect.connect_lan()</p>"
+                        ),
+                    )
+                else:
+                    EricMessageBox.information(
+                        None,
+                        self.tr("Write Auto-Connect Script"),
+                        self.tr(
+                            "<p>The auto-connect script and associated configuration"
+                            " was saved on the device. The device will connect to the"
+                            " LAN at boot time.</p>"
+                        ),
+                    )
             else:
                 EricMessageBox.critical(
                     None,
@@ -235,14 +251,24 @@
         if ok:
             ok, err = self.__mpy.getDevice().removeLanAutoConnect()
             if ok:
-                EricMessageBox.information(
-                    None,
-                    self.tr("Remove Auto-Connect Script"),
-                    self.tr(
-                        "<p>The IPv4 parameters were removed from the device. The"
-                        " device will not connect to the LAN at boot time anymore.</p>"
-                    ),
-                )
+                if self.__mpy.getDevice().hasCircuitPython():
+                    EricMessageBox.information(
+                        None,
+                        self.tr("Remove Auto-Connect Script"),
+                        self.tr(
+                            "<p>The IPv4 parameters were removed from the device.</p>"
+                        ),
+                    )
+                else:
+                    EricMessageBox.information(
+                        None,
+                        self.tr("Remove Auto-Connect Script"),
+                        self.tr(
+                            "<p>The IPv4 parameters were removed from the device. The"
+                            " device will not connect to the LAN at boot time anymore."
+                            "</p>"
+                        ),
+                    )
             else:
                 EricMessageBox.critical(
                     None,
@@ -285,13 +311,17 @@
         device = self.__mpy.getDevice()
         if not device.getDeviceData("ntp"):
             if device.hasCircuitPython():
+                if device.getDeviceData("ethernet"):
+                    moduleName = "adafruit_wiznet5k"
+                else:
+                    moduleName = "adafruit_ntp"
                 EricMessageBox.warning(
                     None,
                     self.tr("Set Network Time"),
                     self.tr(
                         "<p>The device does not support network time synchronization."
-                        " The module <b>adafruit_ntp</b> is not installed.</p>"
-                    ),
+                        " The module <b>{0}</b> is not installed.</p>"
+                    ).format(moduleName),
                 )
             else:
                 EricMessageBox.critical(

eric ide

mercurial