src/eric7/MicroPython/EthernetDialogs/EthernetController.py

branch
eric7
changeset 10153
ffe7432f716b
parent 9885
05cbf70e8f10
child 10167
0a62a4bf749c
equal deleted inserted replaced
10152:33e7b9d3f91c 10153:ffe7432f716b
94 @pyqtSlot() 94 @pyqtSlot()
95 def __connectLanDhcp(self): 95 def __connectLanDhcp(self):
96 """ 96 """
97 Private slot to connect to the LAN with a dynamic IPv4 address (DHCP mode). 97 Private slot to connect to the LAN with a dynamic IPv4 address (DHCP mode).
98 """ 98 """
99 self.__connectLan("dhcp") 99 from .HostnameDialog import HostnameDialog
100
101 dlg = HostnameDialog(self.__mpy)
102 hostname = (
103 dlg.getHostname()
104 if dlg.exec() == QDialog.DialogCode.Accepted
105 else ""
106 )
107 self.__connectLan("dhcp", hostname)
100 108
101 @pyqtSlot() 109 @pyqtSlot()
102 def __connectLanIp(self): 110 def __connectLanIp(self):
103 """ 111 """
104 Private slot to connect to the LAN with a fixed IPv4 address (fixed address 112 Private slot to connect to the LAN with a fixed IPv4 address (fixed address
106 """ 114 """
107 from .IPv4AddressDialog import IPv4AddressDialog 115 from .IPv4AddressDialog import IPv4AddressDialog
108 116
109 dlg = IPv4AddressDialog(withDhcp=False, parent=self.__mpy) 117 dlg = IPv4AddressDialog(withDhcp=False, parent=self.__mpy)
110 if dlg.exec() == QDialog.DialogCode.Accepted: 118 if dlg.exec() == QDialog.DialogCode.Accepted:
111 ifconfig = dlg.getIPv4Address() 119 ifconfig, hostname = dlg.getIPv4Address()
112 self.__connectLan(ifconfig) 120 self.__connectLan(ifconfig, hostname)
113 121
114 def __connectLan(self, config): 122 def __connectLan(self, config, hostname):
115 """ 123 """
116 Private method to connect the connected device to the LAN. 124 Private method to connect the connected device to the LAN.
117 125
118 @param config configuration for the connection (either the string 'dhcp' 126 @param config configuration for the connection (either the string 'dhcp'
119 for a dynamic address or a tuple of four strings with the IPv4 parameters. 127 for a dynamic address or a tuple of four strings with the IPv4 parameters.
120 @type str of tuple of (str, str, str, str) 128 @type str of tuple of (str, str, str, str)
121 """ 129 @param hostname host name of the device
122 success, error = self.__mpy.getDevice().connectToLan(config) 130 @type str
131 """
132 success, error = self.__mpy.getDevice().connectToLan(config, hostname)
123 if success: 133 if success:
124 EricMessageBox.information( 134 EricMessageBox.information(
125 None, 135 None,
126 self.tr("Connect to LAN"), 136 self.tr("Connect to LAN"),
127 self.tr("<p>The device was connected to the LAN successfully.</p>"), 137 self.tr("<p>The device was connected to the LAN successfully.</p>"),
194 """ 204 """
195 from .IPv4AddressDialog import IPv4AddressDialog 205 from .IPv4AddressDialog import IPv4AddressDialog
196 206
197 dlg = IPv4AddressDialog(withDhcp=True, parent=self.__mpy) 207 dlg = IPv4AddressDialog(withDhcp=True, parent=self.__mpy)
198 if dlg.exec() == QDialog.DialogCode.Accepted: 208 if dlg.exec() == QDialog.DialogCode.Accepted:
199 ifconfig = dlg.getIPv4Address() 209 ifconfig, hostname = dlg.getIPv4Address()
200 ok, err = self.__mpy.getDevice().writeLanAutoConnect(ifconfig) 210 ok, err = self.__mpy.getDevice().writeLanAutoConnect(ifconfig, hostname)
201 if ok: 211 if ok:
202 if self.__mpy.getDevice().hasCircuitPython(): 212 if self.__mpy.getDevice().hasCircuitPython():
203 # CircuitPython will reset for the REPL, so no auto-connect 213 # CircuitPython will reset for the REPL, so no auto-connect
204 # available. 214 # available.
205 EricMessageBox.information( 215 EricMessageBox.information(

eric ide

mercurial