23 def __init__(self, microPython, parent=None): |
23 def __init__(self, microPython, parent=None): |
24 """ |
24 """ |
25 Constructor |
25 Constructor |
26 |
26 |
27 @param microPython reference to the MicroPython widget |
27 @param microPython reference to the MicroPython widget |
28 @type MicroPythonWidgep |
28 @type MicroPythonWidget |
29 @param parent reference to the parent object (defaults to None) |
29 @param parent reference to the parent object (defaults to None) |
30 @type QObject (optional) |
30 @type QObject (optional) |
31 """ |
31 """ |
32 super().__init__(parent) |
32 super().__init__(parent) |
33 |
33 |
91 from .WifiStatusDialog import WifiStatusDialog |
91 from .WifiStatusDialog import WifiStatusDialog |
92 |
92 |
93 try: |
93 try: |
94 clientStatus, apStatus, overallStatus = self.__mpy.getDevice().getWifiData() |
94 clientStatus, apStatus, overallStatus = self.__mpy.getDevice().getWifiData() |
95 |
95 |
96 dlg = WifiStatusDialog(clientStatus, apStatus, overallStatus) |
96 dlg = WifiStatusDialog( |
|
97 clientStatus, apStatus, overallStatus, parent=self.__mpy |
|
98 ) |
97 dlg.exec() |
99 dlg.exec() |
98 except Exception as exc: |
100 except Exception as exc: |
99 self.__mpy.showError("getWifiData()", str(exc)) |
101 self.__mpy.showError("getWifiData()", str(exc)) |
100 |
102 |
101 @pyqtSlot() |
103 @pyqtSlot() |
103 """ |
105 """ |
104 Private slot to connect the current device to a WiFi network. |
106 Private slot to connect the current device to a WiFi network. |
105 """ |
107 """ |
106 from .WifiConnectionDialog import WifiConnectionDialog |
108 from .WifiConnectionDialog import WifiConnectionDialog |
107 |
109 |
108 dlg = WifiConnectionDialog() |
110 dlg = WifiConnectionDialog(parent=self.__mpy) |
109 if dlg.exec() == QDialog.DialogCode.Accepted: |
111 if dlg.exec() == QDialog.DialogCode.Accepted: |
110 ssid, password, hostname = dlg.getConnectionParameters() |
112 ssid, password, hostname = dlg.getConnectionParameters() |
111 success, error = self.__mpy.getDevice().connectWifi( |
113 success, error = self.__mpy.getDevice().connectWifi( |
112 ssid, password, hostname |
114 ssid, password, hostname |
113 ) |
115 ) |
194 |
196 |
195 This will also modify the boot script to perform an automatic WiFi connection. |
197 This will also modify the boot script to perform an automatic WiFi connection. |
196 """ |
198 """ |
197 from .WifiConnectionDialog import WifiConnectionDialog |
199 from .WifiConnectionDialog import WifiConnectionDialog |
198 |
200 |
199 dlg = WifiConnectionDialog(withCountry=self.__mpy.getDevice().hasWifiCountry()) |
201 dlg = WifiConnectionDialog( |
|
202 withCountry=self.__mpy.getDevice().hasWifiCountry(), |
|
203 parent=self.__mpy, |
|
204 ) |
200 if dlg.exec() == QDialog.DialogCode.Accepted: |
205 if dlg.exec() == QDialog.DialogCode.Accepted: |
201 ssid, password, hostname = dlg.getConnectionParameters() |
206 ssid, password, hostname = dlg.getConnectionParameters() |
202 country = dlg.getCountryCode() |
207 country = dlg.getCountryCode() |
203 success, error = self.__mpy.getDevice().writeCredentials( |
208 success, error = self.__mpy.getDevice().writeCredentials( |
204 ssid, password, hostname, country |
209 ssid, password, hostname, country |
294 @param withIP flag indicating to start the access point with an IP configuration |
299 @param withIP flag indicating to start the access point with an IP configuration |
295 @type bool |
300 @type bool |
296 """ |
301 """ |
297 from .WifiApConfigDialog import WifiApConfigDialog |
302 from .WifiApConfigDialog import WifiApConfigDialog |
298 |
303 |
299 dlg = WifiApConfigDialog(withIP=withIP) |
304 dlg = WifiApConfigDialog(withIP=withIP, parent=self.__mpy) |
300 if dlg.exec() == QDialog.DialogCode.Accepted: |
305 if dlg.exec() == QDialog.DialogCode.Accepted: |
301 ssid, password, security, hostname, ifconfig = dlg.getApConfig() |
306 ssid, password, security, hostname, ifconfig = dlg.getApConfig() |
302 |
307 |
303 ok, err = self.__mpy.getDevice().startAccessPoint( |
308 ok, err = self.__mpy.getDevice().startAccessPoint( |
304 ssid, |
309 ssid, |
368 |
373 |
369 if err: |
374 if err: |
370 self.__mpy.showError("getConnectedClients()", err) |
375 self.__mpy.showError("getConnectedClients()", err) |
371 else: |
376 else: |
372 if stations: |
377 if stations: |
373 dlg = WifiApStationsDialog(stations) |
378 dlg = WifiApStationsDialog(stations, parent=self.__mpy) |
374 dlg.exec() |
379 dlg.exec() |
375 else: |
380 else: |
376 EricMessageBox.information( |
381 EricMessageBox.information( |
377 None, |
382 None, |
378 self.tr("Show Connected Clients"), |
383 self.tr("Show Connected Clients"), |
431 " The module <b>ntptime</b> is not available.</p>" |
436 " The module <b>ntptime</b> is not available.</p>" |
432 ), |
437 ), |
433 ) |
438 ) |
434 return |
439 return |
435 |
440 |
436 dlg = NtpParametersDialog(self.__mpy) |
441 dlg = NtpParametersDialog(parent=self.__mpy) |
437 if dlg.exec() == QDialog.DialogCode.Accepted: |
442 if dlg.exec() == QDialog.DialogCode.Accepted: |
438 server, tzOffset, isDst, timeout = dlg.getParameters() |
443 server, tzOffset, isDst, timeout = dlg.getParameters() |
439 if isDst: |
444 if isDst: |
440 tzOffset += 1 |
445 tzOffset += 1 |
441 |
446 |
474 """ |
479 """ |
475 from ..MicroPythonWebreplParametersDialog import ( |
480 from ..MicroPythonWebreplParametersDialog import ( |
476 MicroPythonWebreplParametersDialog, |
481 MicroPythonWebreplParametersDialog, |
477 ) |
482 ) |
478 |
483 |
479 dlg = MicroPythonWebreplParametersDialog() |
484 dlg = MicroPythonWebreplParametersDialog(parent=self.__mpy) |
480 if dlg.exec() == QDialog.DialogCode.Accepted: |
485 if dlg.exec() == QDialog.DialogCode.Accepted: |
481 (password,) = dlg.getParameters() |
486 (password,) = dlg.getParameters() |
482 success, error = self.__mpy.getDevice().enableWebrepl(password) |
487 success, error = self.__mpy.getDevice().enableWebrepl(password) |
483 if success: |
488 if success: |
484 EricMessageBox.information( |
489 EricMessageBox.information( |