src/eric7/MicroPython/Devices/RP2040Devices.py

branch
mpy_network
changeset 9789
d8e0ab86ddca
parent 9788
12294115900a
child 9793
30eb6d3b3eb0
--- a/src/eric7/MicroPython/Devices/RP2040Devices.py	Wed Feb 22 07:48:57 2023 +0100
+++ b/src/eric7/MicroPython/Devices/RP2040Devices.py	Wed Feb 22 08:20:34 2023 +0100
@@ -49,16 +49,16 @@
 
         self.__statusTranslations = {
             "picow": {
-                -3: self.tr('authentication failed'),
-                -2: self.tr('no matching access point found'),
-                -1: self.tr('connection failed'),
-                0: self.tr('idle'),
-                1: self.tr('connecting'),
-                2: self.tr('connected, waiting for IP address'),
-                3: self.tr('connected'),
+                -3: self.tr("authentication failed"),
+                -2: self.tr("no matching access point found"),
+                -1: self.tr("connection failed"),
+                0: self.tr("idle"),
+                1: self.tr("connecting"),
+                2: self.tr("connected, waiting for IP address"),
+                3: self.tr("connected"),
             },
             "pimoroni": {
-            # TODO: not yet implemented
+                # TODO: not yet implemented
             },
         }
         self.__securityTranslations = {
@@ -69,7 +69,7 @@
             4: "WPA/WPA2",
             5: "WPA2 (CCMP)",
             6: "WPA3",
-            7: "WPA2/WPA3"
+            7: "WPA2/WPA3",
         }
 
     def setButtons(self):
@@ -421,11 +421,12 @@
 
     def getWifiData(self):
         """
-        Public method to get data related to the current WiFi status
+        Public method to get data related to the current WiFi status.
 
         @return tuple of two dictionaries containing the WiFi status data
             for the WiFi client and access point
         @rtype tuple of (dict, dict)
+        @exception OSError raised to indicate an issue with the device
         """
         if self._deviceData["wifi_type"] == "picow":
             command = """
@@ -471,7 +472,7 @@
         else:
             return super().getWifiData()
 
-        out, err = self._interface.execute(command)##, timeout=10000)
+        out, err = self._interface.execute(command)
         if err:
             raise OSError(self._shortError(err))
 
@@ -485,9 +486,9 @@
         except KeyError:
             station["status"] = str(station["status"])
         try:
-            ap["status"] = self.__statusTranslations[
-                self._deviceData["wifi_type"]
-            ][ap["status"]]
+            ap["status"] = self.__statusTranslations[self._deviceData["wifi_type"]][
+                ap["status"]
+            ]
         except KeyError:
             ap["status"] = str(ap["status"])
         return station, ap
@@ -530,10 +531,10 @@
 connect_wifi({0}, {1}, {2})
 del connect_wifi
 """.format(
-            repr(ssid),
-            repr(password if password else ""),
-            repr(country if country else "XX"),
-        )
+                repr(ssid),
+                repr(password if password else ""),
+                repr(country if country else "XX"),
+            )
         elif self._deviceData["wifi_type"] == "pimoroni":
             # TODO: not yet implemented
             pass
@@ -550,9 +551,9 @@
             error = ""
         else:
             try:
-                error = self.__statusTranslations[
-                    self._deviceData["wifi_type"]
-                ][result["status"]]
+                error = self.__statusTranslations[self._deviceData["wifi_type"]][
+                    result["status"]
+                ]
             except KeyError:
                 error = str(result["status"])
 
@@ -629,7 +630,7 @@
             secrets = "WIFI_SSID = {0}\nWIFI_KEY = {1}\nWIFI_COUNTRY={2}".format(
                 repr(ssid),
                 repr(password) if password else '""',
-                repr(country) if country else '""'
+                repr(country) if country else '""',
             )
             wifiConnectFile = "picowWiFiConnect.py"
         else:
@@ -643,9 +644,7 @@
             self.putData("/secrets.py", secrets.encode("utf-8"))
             # copy auto-connect file
             self.put(
-                os.path.join(
-                    os.path.dirname(__file__), "MCUScripts", wifiConnectFile
-                ),
+                os.path.join(os.path.dirname(__file__), "MCUScripts", wifiConnectFile),
                 "/wifi_connect.py",
             )
         except OSError as err:
@@ -740,7 +739,9 @@
 
 scan_networks()
 del scan_networks
-""".format(repr(country if country else "XX"))
+""".format(
+                repr(country if country else "XX")
+            )
 
         elif self._deviceData["wifi_type"] == "pimoroni":
             # TODO: not yet implemented
@@ -797,7 +798,9 @@
 
 deactivate()
 del deactivate
-""".format(interface)
+""".format(
+                interface
+            )
         elif self._deviceData["wifi_type"] == "pimoroni":
             # TODO: not yet implemented
             pass
@@ -847,7 +850,9 @@
 
 start_ap()
 del start_ap
-""".format(repr(ssid), security, repr(password), repr(country if country else "XX"))
+""".format(
+                repr(ssid), security, repr(password), repr(country if country else "XX")
+            )
         elif self._deviceData["wifi_type"] == "pimoroni":
             # TODO: not yet implemented
             pass
@@ -930,7 +935,9 @@
             command = """
 import rp2
 rp2.country({0})
-""".format(repr(country))
+""".format(
+                repr(country)
+            )
 
             out, err = self._interface.execute(command)
             if err:

eric ide

mercurial