src/eric7/MicroPython/EthernetDialogs/EthernetController.py

branch
eric7
changeset 10153
ffe7432f716b
parent 9885
05cbf70e8f10
child 10167
0a62a4bf749c
--- a/src/eric7/MicroPython/EthernetDialogs/EthernetController.py	Wed Aug 02 17:22:20 2023 +0200
+++ b/src/eric7/MicroPython/EthernetDialogs/EthernetController.py	Thu Aug 03 17:33:07 2023 +0200
@@ -96,7 +96,15 @@
         """
         Private slot to connect to the LAN with a dynamic IPv4 address (DHCP mode).
         """
-        self.__connectLan("dhcp")
+        from .HostnameDialog import HostnameDialog
+
+        dlg = HostnameDialog(self.__mpy)
+        hostname = (
+            dlg.getHostname()
+            if dlg.exec() == QDialog.DialogCode.Accepted
+            else ""
+        )
+        self.__connectLan("dhcp", hostname)
 
     @pyqtSlot()
     def __connectLanIp(self):
@@ -108,18 +116,20 @@
 
         dlg = IPv4AddressDialog(withDhcp=False, parent=self.__mpy)
         if dlg.exec() == QDialog.DialogCode.Accepted:
-            ifconfig = dlg.getIPv4Address()
-            self.__connectLan(ifconfig)
+            ifconfig, hostname = dlg.getIPv4Address()
+            self.__connectLan(ifconfig, hostname)
 
-    def __connectLan(self, config):
+    def __connectLan(self, config, hostname):
         """
         Private method to connect the connected device to the LAN.
 
         @param config configuration for the connection (either the string 'dhcp'
             for a dynamic address or a tuple of four strings with the IPv4 parameters.
         @type str of tuple of (str, str, str, str)
+        @param hostname host name of the device
+        @type str
         """
-        success, error = self.__mpy.getDevice().connectToLan(config)
+        success, error = self.__mpy.getDevice().connectToLan(config, hostname)
         if success:
             EricMessageBox.information(
                 None,
@@ -196,8 +206,8 @@
 
         dlg = IPv4AddressDialog(withDhcp=True, parent=self.__mpy)
         if dlg.exec() == QDialog.DialogCode.Accepted:
-            ifconfig = dlg.getIPv4Address()
-            ok, err = self.__mpy.getDevice().writeLanAutoConnect(ifconfig)
+            ifconfig, hostname = dlg.getIPv4Address()
+            ok, err = self.__mpy.getDevice().writeLanAutoConnect(ifconfig, hostname)
             if ok:
                 if self.__mpy.getDevice().hasCircuitPython():
                     # CircuitPython will reset for the REPL, so no auto-connect

eric ide

mercurial