MicroPython eric7

Tue, 19 Nov 2024 16:08:15 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 19 Nov 2024 16:08:15 +0100
branch
eric7
changeset 11051
e8a7be10b76c
parent 11050
f0b91a949398
child 11052
316be9cd43bc

MicroPython
- Enhanced the WiFi and BLE detection for Pimoroni RP2350 boards because their firmware has modules for these even if the CYW43 chip is not present.

src/eric7/MicroPython/Devices/RP2Devices.py file | annotate | diff | comparison | revisions
--- a/src/eric7/MicroPython/Devices/RP2Devices.py	Tue Nov 12 19:26:31 2024 +0100
+++ b/src/eric7/MicroPython/Devices/RP2Devices.py	Tue Nov 19 16:08:15 2024 +0100
@@ -451,6 +451,10 @@
     try:
         import network
         if hasattr(network, 'WLAN'):
+            wifi = network.WLAN(network.STA_IF)
+            if not wifi.active():
+                wifi.active(True)
+                wifi.active(False)
             return True, 'picow'
     except ImportError:
         try:
@@ -476,6 +480,10 @@
             else:
                 # pimoroni firmware loaded but no pico wireless present
                 return False, ""
+        if b"Failed to start CYW43" in out:
+            # network module present but no CYW43 chip
+            # (pimoroni firmware has everything)
+            return False, ""
         return ast.literal_eval(out.decode("utf-8"))
 
     def hasWifiCountry(self):
@@ -1467,8 +1475,12 @@
     try:
         import bluetooth
         if hasattr(bluetooth, 'BLE'):
+            ble = bluetooth.BLE()
+            if not ble.active():
+                ble.active(True)
+                ble.active(False)
             return True
-    except ImportError:
+    except (ImportError, OSError):
         pass
 
     return False

eric ide

mercurial