54 wifiMenu.addSeparator() |
54 wifiMenu.addSeparator() |
55 wifiMenu.addAction(self.tr("Write WiFi Credentials"), self.__writeCredentials) |
55 wifiMenu.addAction(self.tr("Write WiFi Credentials"), self.__writeCredentials) |
56 wifiMenu.addAction(self.tr("Remove WiFi Credentials"), self.__removeCredentials) |
56 wifiMenu.addAction(self.tr("Remove WiFi Credentials"), self.__removeCredentials) |
57 wifiMenu.addSeparator() |
57 wifiMenu.addSeparator() |
58 wifiMenu.addAction(self.tr("Start WiFi Access Point"), self.__startAccessPoint) |
58 wifiMenu.addAction(self.tr("Start WiFi Access Point"), self.__startAccessPoint) |
|
59 wifiMenu.addAction( |
|
60 self.tr("Start WiFi Access Point with IP"), self.__startAccessPointIP |
|
61 ) |
59 wifiMenu.addAction( |
62 wifiMenu.addAction( |
60 self.tr("Show Connected Clients"), self.__showConnectedClients |
63 self.tr("Show Connected Clients"), self.__showConnectedClients |
61 ) |
64 ) |
62 wifiMenu.addAction(self.tr("Stop WiFi Access Point"), self.__stopAccessPoint) |
65 wifiMenu.addAction(self.tr("Stop WiFi Access Point"), self.__stopAccessPoint) |
63 wifiMenu.addSeparator() |
66 wifiMenu.addSeparator() |
254 "</p><p>Reason: {0}</p>" |
257 "</p><p>Reason: {0}</p>" |
255 ).format(error if error else self.tr("unknown")), |
258 ).format(error if error else self.tr("unknown")), |
256 ) |
259 ) |
257 |
260 |
258 @pyqtSlot() |
261 @pyqtSlot() |
259 def __startAccessPoint(self): |
262 def __startAccessPoint(self, withIP=False): |
260 """ |
263 """ |
261 Private slot to start the Access Point interface of the connected device. |
264 Private slot to start the Access Point interface of the connected device. |
|
265 |
|
266 @param withIP flag indicating to start the access point with an IP configuration |
|
267 @type bool |
262 """ |
268 """ |
263 from .WifiApConfigDialog import WifiApConfigDialog |
269 from .WifiApConfigDialog import WifiApConfigDialog |
264 |
270 |
265 dlg = WifiApConfigDialog() |
271 dlg = WifiApConfigDialog(withIP=withIP) |
266 if dlg.exec() == QDialog.DialogCode.Accepted: |
272 if dlg.exec() == QDialog.DialogCode.Accepted: |
267 ssid, password, security, remember = dlg.getApConfig() |
273 ssid, password, security, remember, ifconfig = dlg.getApConfig() |
268 |
274 |
269 if remember: |
275 if remember: |
270 Preferences.setMicroPython("WifiApName", ssid) |
276 Preferences.setMicroPython("WifiApName", ssid) |
271 Preferences.setMicroPython("WifiApPassword", password) |
277 Preferences.setMicroPython("WifiApPassword", password) |
272 Preferences.setMicroPython("WifiApAuthMode", security) |
278 Preferences.setMicroPython("WifiApAuthMode", security) |
|
279 if withIP: |
|
280 Preferences.setMicroPython("WifiApAddress", ifconfig[0]) |
|
281 Preferences.setMicroPython("WifiApNetmask", ifconfig[1]) |
|
282 Preferences.setMicroPython("WifiApGateway", ifconfig[2]) |
|
283 Preferences.setMicroPython("WifiApDNS", ifconfig[3]) |
273 |
284 |
274 ok, err = self.__mpy.getDevice().startAccessPoint( |
285 ok, err = self.__mpy.getDevice().startAccessPoint( |
275 ssid, security=security, password=password |
286 ssid, |
|
287 security=security, |
|
288 password=password, |
|
289 ifconfig=ifconfig if withIP else None, |
276 ) |
290 ) |
277 if ok: |
291 if ok: |
278 EricMessageBox.information( |
292 EricMessageBox.information( |
279 None, |
293 None, |
280 self.tr("Start WiFi Access Point"), |
294 self.tr("Start WiFi Access Point"), |
291 self.tr("Start WiFi Access Point"), |
305 self.tr("Start WiFi Access Point"), |
292 msg, |
306 msg, |
293 ) |
307 ) |
294 |
308 |
295 @pyqtSlot() |
309 @pyqtSlot() |
|
310 def __startAccessPointIP(self): |
|
311 """ |
|
312 Private slot to start the Access Point interface of the connected device |
|
313 with given IP parameters. |
|
314 """ |
|
315 self.__startAccessPoint(withIP=True) |
|
316 |
|
317 @pyqtSlot() |
296 def __stopAccessPoint(self): |
318 def __stopAccessPoint(self): |
297 """ |
319 """ |
298 Private slot to stop the Access Point interface of the connected device. |
320 Private slot to stop the Access Point interface of the connected device. |
299 """ |
321 """ |
300 ok, err = self.__mpy.getDevice().stopAccessPoint() |
322 ok, err = self.__mpy.getDevice().stopAccessPoint() |