MicroPython eric7

Thu, 09 Mar 2023 16:56:24 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 09 Mar 2023 16:56:24 +0100
branch
eric7
changeset 9866
0cf5dda5512f
parent 9865
2eb7b5516a60
child 9867
e69788b71c00
child 9873
38f3435daeef

MicroPython
- fixed a few bugs
- fixed support for ESP devices with CircuitPython with one USB port

src/eric7/APIs/Python3/eric7.api file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
src/eric7/Documentation/Source/eric7.MicroPython.Devices.CircuitPythonDevices.html file | annotate | diff | comparison | revisions
src/eric7/Documentation/Source/eric7.MicroPython.Devices.EspDevices.html file | annotate | diff | comparison | revisions
src/eric7/MicroPython/BluetoothDialogs/BluetoothAdvertisement.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/CircuitPythonDevices.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/EspDevices.py file | annotate | diff | comparison | revisions
--- a/src/eric7/APIs/Python3/eric7.api	Thu Mar 09 14:55:17 2023 +0100
+++ b/src/eric7/APIs/Python3/eric7.api	Thu Mar 09 16:56:24 2023 +0100
@@ -2615,11 +2615,12 @@
 eric7.MicroPython.Devices.CircuitPythonDevices.CircuitPythonDevice.scanNetworks?4()
 eric7.MicroPython.Devices.CircuitPythonDevices.CircuitPythonDevice.setButtons?4()
 eric7.MicroPython.Devices.CircuitPythonDevices.CircuitPythonDevice.setConnected?4(connected)
+eric7.MicroPython.Devices.CircuitPythonDevices.CircuitPythonDevice.showCircuitPythonVersions?4()
 eric7.MicroPython.Devices.CircuitPythonDevices.CircuitPythonDevice.startAccessPoint?4(ssid, security=None, password=None, ifconfig=None)
 eric7.MicroPython.Devices.CircuitPythonDevices.CircuitPythonDevice.stopAccessPoint?4()
 eric7.MicroPython.Devices.CircuitPythonDevices.CircuitPythonDevice.supportsLocalFileAccess?4()
 eric7.MicroPython.Devices.CircuitPythonDevices.CircuitPythonDevice.writeCredentials?4(ssid, password)
-eric7.MicroPython.Devices.CircuitPythonDevices.CircuitPythonDevice?1(microPythonWidget, deviceType, boardName, parent=None)
+eric7.MicroPython.Devices.CircuitPythonDevices.CircuitPythonDevice?1(microPythonWidget, deviceType, boardName, hasWorkspace=True, parent=None)
 eric7.MicroPython.Devices.CircuitPythonDevices.createDevice?4(microPythonWidget, deviceType, vid, pid, boardName, serialNumber)
 eric7.MicroPython.Devices.CircuitPythonUpdater.CircuitPythonUpdaterInterface.CircuitPythonUpdaterInterface.installCircup?4()
 eric7.MicroPython.Devices.CircuitPythonUpdater.CircuitPythonUpdaterInterface.CircuitPythonUpdaterInterface.populateMenu?4(menu)
@@ -2747,6 +2748,7 @@
 eric7.MicroPython.Devices.EspDevices.EspDevice.runScript?4(script)
 eric7.MicroPython.Devices.EspDevices.EspDevice.scanNetworks?4()
 eric7.MicroPython.Devices.EspDevices.EspDevice.setButtons?4()
+eric7.MicroPython.Devices.EspDevices.EspDevice.setConnected?4(connected)
 eric7.MicroPython.Devices.EspDevices.EspDevice.startAccessPoint?4(ssid, security=None, password=None, ifconfig=None)
 eric7.MicroPython.Devices.EspDevices.EspDevice.stopAccessPoint?4()
 eric7.MicroPython.Devices.EspDevices.EspDevice.writeCredentials?4(ssid, password)
Binary file src/eric7/Documentation/Help/source.qch has changed
--- a/src/eric7/Documentation/Help/source.qhp	Thu Mar 09 14:55:17 2023 +0100
+++ b/src/eric7/Documentation/Help/source.qhp	Thu Mar 09 16:56:24 2023 +0100
@@ -2845,7 +2845,6 @@
       <keyword name="CircuitPythonDevice.__flashCircuitPython" id="CircuitPythonDevice.__flashCircuitPython" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.__flashCircuitPython" />
       <keyword name="CircuitPythonDevice.__installLibraryFiles" id="CircuitPythonDevice.__installLibraryFiles" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.__installLibraryFiles" />
       <keyword name="CircuitPythonDevice.__resetDevice" id="CircuitPythonDevice.__resetDevice" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.__resetDevice" />
-      <keyword name="CircuitPythonDevice.__showCircuitPythonVersions" id="CircuitPythonDevice.__showCircuitPythonVersions" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.__showCircuitPythonVersions" />
       <keyword name="CircuitPythonDevice.__showTeensyFlashInstructions" id="CircuitPythonDevice.__showTeensyFlashInstructions" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.__showTeensyFlashInstructions" />
       <keyword name="CircuitPythonDevice.__startTeensyLoader" id="CircuitPythonDevice.__startTeensyLoader" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.__startTeensyLoader" />
       <keyword name="CircuitPythonDevice.activateBluetoothInterface" id="CircuitPythonDevice.activateBluetoothInterface" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.activateBluetoothInterface" />
@@ -2876,6 +2875,7 @@
       <keyword name="CircuitPythonDevice.scanNetworks" id="CircuitPythonDevice.scanNetworks" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.scanNetworks" />
       <keyword name="CircuitPythonDevice.setButtons" id="CircuitPythonDevice.setButtons" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.setButtons" />
       <keyword name="CircuitPythonDevice.setConnected" id="CircuitPythonDevice.setConnected" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.setConnected" />
+      <keyword name="CircuitPythonDevice.showCircuitPythonVersions" id="CircuitPythonDevice.showCircuitPythonVersions" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.showCircuitPythonVersions" />
       <keyword name="CircuitPythonDevice.startAccessPoint" id="CircuitPythonDevice.startAccessPoint" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.startAccessPoint" />
       <keyword name="CircuitPythonDevice.stopAccessPoint" id="CircuitPythonDevice.stopAccessPoint" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.stopAccessPoint" />
       <keyword name="CircuitPythonDevice.supportsLocalFileAccess" id="CircuitPythonDevice.supportsLocalFileAccess" ref="eric7.MicroPython.Devices.CircuitPythonDevices.html#CircuitPythonDevice.supportsLocalFileAccess" />
@@ -6229,6 +6229,7 @@
       <keyword name="EspDevice" id="EspDevice" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice" />
       <keyword name="EspDevice (Constructor)" id="EspDevice (Constructor)" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.__init__" />
       <keyword name="EspDevice.__backupFlash" id="EspDevice.__backupFlash" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.__backupFlash" />
+      <keyword name="EspDevice.__createCpyDevice" id="EspDevice.__createCpyDevice" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.__createCpyDevice" />
       <keyword name="EspDevice.__createEsp32Submenu" id="EspDevice.__createEsp32Submenu" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.__createEsp32Submenu" />
       <keyword name="EspDevice.__eraseFlash" id="EspDevice.__eraseFlash" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.__eraseFlash" />
       <keyword name="EspDevice.__firmwareVersionResponse" id="EspDevice.__firmwareVersionResponse" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.__firmwareVersionResponse" />
@@ -6268,6 +6269,7 @@
       <keyword name="EspDevice.runScript" id="EspDevice.runScript" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.runScript" />
       <keyword name="EspDevice.scanNetworks" id="EspDevice.scanNetworks" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.scanNetworks" />
       <keyword name="EspDevice.setButtons" id="EspDevice.setButtons" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.setButtons" />
+      <keyword name="EspDevice.setConnected" id="EspDevice.setConnected" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.setConnected" />
       <keyword name="EspDevice.startAccessPoint" id="EspDevice.startAccessPoint" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.startAccessPoint" />
       <keyword name="EspDevice.stopAccessPoint" id="EspDevice.stopAccessPoint" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.stopAccessPoint" />
       <keyword name="EspDevice.writeCredentials" id="EspDevice.writeCredentials" ref="eric7.MicroPython.Devices.EspDevices.html#EspDevice.writeCredentials" />
--- a/src/eric7/Documentation/Source/eric7.MicroPython.Devices.CircuitPythonDevices.html	Thu Mar 09 14:55:17 2023 +0100
+++ b/src/eric7/Documentation/Source/eric7.MicroPython.Devices.CircuitPythonDevices.html	Thu Mar 09 16:56:24 2023 +0100
@@ -115,10 +115,6 @@
 <td>Private slot to reset the connected device.</td>
 </tr>
 <tr>
-<td><a href="#CircuitPythonDevice.__showCircuitPythonVersions">__showCircuitPythonVersions</a></td>
-<td>Private slot to show the CircuitPython version of a connected device and the latest available one (from Github).</td>
-</tr>
-<tr>
 <td><a href="#CircuitPythonDevice.__showTeensyFlashInstructions">__showTeensyFlashInstructions</a></td>
 <td>Private slot to show a message box because Teensy does not support the UF2 bootloader yet.</td>
 </tr>
@@ -239,6 +235,10 @@
 <td>Public method to set the connection state.</td>
 </tr>
 <tr>
+<td><a href="#CircuitPythonDevice.showCircuitPythonVersions">showCircuitPythonVersions</a></td>
+<td>Public slot to show the CircuitPython version of a connected device and the latest available one (from Github).</td>
+</tr>
+<tr>
 <td><a href="#CircuitPythonDevice.startAccessPoint">startAccessPoint</a></td>
 <td>Public method to start the access point interface.</td>
 </tr>
@@ -263,7 +263,7 @@
 
 <a NAME="CircuitPythonDevice.__init__" ID="CircuitPythonDevice.__init__"></a>
 <h4>CircuitPythonDevice (Constructor)</h4>
-<b>CircuitPythonDevice</b>(<i>microPythonWidget, deviceType, boardName, parent=None</i>)
+<b>CircuitPythonDevice</b>(<i>microPythonWidget, deviceType, boardName, hasWorkspace=True, parent=None</i>)
 
 <p>
         Constructor
@@ -282,6 +282,11 @@
 <dd>
 name of the board
 </dd>
+<dt><i>hasWorkspace</i> (bool (optional))</dt>
+<dd>
+flag indicating that the devices supports access via
+            a mounted volume (defaults to True)
+</dd>
 <dt><i>parent</i> (QObject)</dt>
 <dd>
 reference to the parent object
@@ -457,14 +462,6 @@
 <p>
         Private slot to reset the connected device.
 </p>
-<a NAME="CircuitPythonDevice.__showCircuitPythonVersions" ID="CircuitPythonDevice.__showCircuitPythonVersions"></a>
-<h4>CircuitPythonDevice.__showCircuitPythonVersions</h4>
-<b>__showCircuitPythonVersions</b>(<i></i>)
-
-<p>
-        Private slot to show the CircuitPython version of a connected device and
-        the latest available one (from Github).
-</p>
 <a NAME="CircuitPythonDevice.__showTeensyFlashInstructions" ID="CircuitPythonDevice.__showTeensyFlashInstructions"></a>
 <h4>CircuitPythonDevice.__showTeensyFlashInstructions</h4>
 <b>__showTeensyFlashInstructions</b>(<i></i>)
@@ -1087,6 +1084,14 @@
 connection state
 </dd>
 </dl>
+<a NAME="CircuitPythonDevice.showCircuitPythonVersions" ID="CircuitPythonDevice.showCircuitPythonVersions"></a>
+<h4>CircuitPythonDevice.showCircuitPythonVersions</h4>
+<b>showCircuitPythonVersions</b>(<i></i>)
+
+<p>
+        Public slot to show the CircuitPython version of a connected device and
+        the latest available one (from Github).
+</p>
 <a NAME="CircuitPythonDevice.startAccessPoint" ID="CircuitPythonDevice.startAccessPoint"></a>
 <h4>CircuitPythonDevice.startAccessPoint</h4>
 <b>startAccessPoint</b>(<i>ssid, security=None, password=None, ifconfig=None</i>)
--- a/src/eric7/Documentation/Source/eric7.MicroPython.Devices.EspDevices.html	Thu Mar 09 14:55:17 2023 +0100
+++ b/src/eric7/Documentation/Source/eric7.MicroPython.Devices.EspDevices.html	Thu Mar 09 16:56:24 2023 +0100
@@ -80,6 +80,10 @@
 <td>Private slot to backup the currently flashed firmware.</td>
 </tr>
 <tr>
+<td><a href="#EspDevice.__createCpyDevice">__createCpyDevice</a></td>
+<td>Private method to create a CircuitPython device interface.</td>
+</tr>
+<tr>
 <td><a href="#EspDevice.__createEsp32Submenu">__createEsp32Submenu</a></td>
 <td>Private method to create the ESP32 submenu.</td>
 </tr>
@@ -236,6 +240,10 @@
 <td>Public method to enable the supported action buttons.</td>
 </tr>
 <tr>
+<td><a href="#EspDevice.setConnected">setConnected</a></td>
+<td>Public method to set the connection state.</td>
+</tr>
+<tr>
 <td><a href="#EspDevice.startAccessPoint">startAccessPoint</a></td>
 <td>Public method to start the access point interface.</td>
 </tr>
@@ -283,6 +291,13 @@
 <p>
         Private slot to backup the currently flashed firmware.
 </p>
+<a NAME="EspDevice.__createCpyDevice" ID="EspDevice.__createCpyDevice"></a>
+<h4>EspDevice.__createCpyDevice</h4>
+<b>__createCpyDevice</b>(<i></i>)
+
+<p>
+        Private method to create a CircuitPython device interface.
+</p>
 <a NAME="EspDevice.__createEsp32Submenu" ID="EspDevice.__createEsp32Submenu"></a>
 <h4>EspDevice.__createEsp32Submenu</h4>
 <b>__createEsp32Submenu</b>(<i></i>)
@@ -950,6 +965,24 @@
 <p>
         Public method to enable the supported action buttons.
 </p>
+<a NAME="EspDevice.setConnected" ID="EspDevice.setConnected"></a>
+<h4>EspDevice.setConnected</h4>
+<b>setConnected</b>(<i>connected</i>)
+
+<p>
+        Public method to set the connection state.
+</p>
+<p>
+        Note: This method can be overwritten to perform actions upon connect
+        or disconnect of the device.
+</p>
+<dl>
+
+<dt><i>connected</i> (bool)</dt>
+<dd>
+connection state
+</dd>
+</dl>
 <a NAME="EspDevice.startAccessPoint" ID="EspDevice.startAccessPoint"></a>
 <h4>EspDevice.startAccessPoint</h4>
 <b>startAccessPoint</b>(<i>ssid, security=None, password=None, ifconfig=None</i>)
--- a/src/eric7/MicroPython/BluetoothDialogs/BluetoothAdvertisement.py	Thu Mar 09 14:55:17 2023 +0100
+++ b/src/eric7/MicroPython/BluetoothDialogs/BluetoothAdvertisement.py	Thu Mar 09 16:56:24 2023 +0100
@@ -29,11 +29,12 @@
 ADV_TYPE_MANUFACTURER = 0xFF
 
 ManufacturerId = {
-    0x4C: "Apple, Inc.",
-    0xE0: "Google",
-    0x75: "Samsung Electronics Co. Ltd.",
-    0x87: "Garmin International Inc.",
-    0x822: "adafruit industries",
+    0x0006: "Microsoft",
+    0x004C: "Apple, Inc.",
+    0x0075: "Samsung Electronics Co. Ltd.",
+    0x0087: "Garmin International Inc.",
+    0x00E0: "Google",
+    0x0822: "adafruit industries",
 }
 
 
--- a/src/eric7/MicroPython/Devices/CircuitPythonDevices.py	Thu Mar 09 14:55:17 2023 +0100
+++ b/src/eric7/MicroPython/Devices/CircuitPythonDevices.py	Thu Mar 09 16:56:24 2023 +0100
@@ -39,7 +39,9 @@
 
     DeviceVolumeName = "CIRCUITPY"
 
-    def __init__(self, microPythonWidget, deviceType, boardName, parent=None):
+    def __init__(
+        self, microPythonWidget, deviceType, boardName, hasWorkspace=True, parent=None
+    ):
         """
         Constructor
 
@@ -49,6 +51,9 @@
         @type str
         @param boardName name of the board
         @type str
+        @param hasWorkspace flag indicating that the devices supports access via
+            a mounted volume (defaults to True)
+        @type bool (optional)
         @param parent reference to the parent object
         @type QObject
         """
@@ -57,7 +62,10 @@
         self._submitMode = "paste"  # use 'paste' mode to avoid loosing state
 
         self.__boardName = boardName
-        self.__workspace = self.__findWorkspace()
+
+        self.__workspace = (
+            self.__findWorkspace() if hasWorkspace else None
+        )
 
         self.__updater = CircuitPythonUpdaterInterface(self)
 
@@ -300,7 +308,7 @@
 
         self.__cpyMenu = QMenu(self.tr("CircuitPython Functions"))
         self.__cpyMenu.addAction(
-            self.tr("Show CircuitPython Versions"), self.__showCircuitPythonVersions
+            self.tr("Show CircuitPython Versions"), self.showCircuitPythonVersions
         )
         self.__cpyMenu.addSeparator()
         self.__flashCpyAct = self.__cpyMenu.addMenu(self.__flashMenu)
@@ -473,9 +481,9 @@
         flashAddonFirmware(self.microPython.getCurrentPort())
 
     @pyqtSlot()
-    def __showCircuitPythonVersions(self):
+    def showCircuitPythonVersions(self):
         """
-        Private slot to show the CircuitPython version of a connected device and
+        Public slot to show the CircuitPython version of a connected device and
         the latest available one (from Github).
         """
         ui = ericApp().getObject("UserInterface")
--- a/src/eric7/MicroPython/Devices/EspDevices.py	Thu Mar 09 14:55:17 2023 +0100
+++ b/src/eric7/MicroPython/Devices/EspDevices.py	Thu Mar 09 16:56:24 2023 +0100
@@ -27,6 +27,7 @@
 from ..MicroPythonWidget import HAS_QTCHART
 from . import FirmwareGithubUrls
 from .DeviceBase import BaseDevice
+from .CircuitPythonDevices import CircuitPythonDevice
 
 
 class EspDevice(BaseDevice):
@@ -49,6 +50,9 @@
 
         self.__createEsp32Submenu()
 
+        self.__cpyDevice = None
+        # needed to delegate some methods to a CircuitPython variant
+
         self.__statusTranslations = {
             200: self.tr("beacon timeout"),
             201: self.tr("no matching access point found"),
@@ -70,6 +74,35 @@
             7: "WPA2/WPA3",
         }
 
+    def __createCpyDevice(self):
+        """
+        Private method to create a CircuitPython device interface.
+        """
+        if self.hasCircuitPython() and self.__cpyDevice is None:
+            self.__cpyDevice = CircuitPythonDevice(
+                self.microPython,
+                "esp32_circuitpython",
+                "esp32",
+                hasWorkspace=False,
+                parent=self.parent(),
+            )
+
+    def setConnected(self, connected):
+        """
+        Public method to set the connection state.
+
+        Note: This method can be overwritten to perform actions upon connect
+        or disconnect of the device.
+
+        @param connected connection state
+        @type bool
+        """
+        super().setConnected(connected)
+
+        if self.hasCircuitPython():
+            self._submitMode = "paste"
+            self.__createCpyDevice()
+
     def setButtons(self):
         """
         Public method to enable the supported action buttons.
@@ -341,6 +374,9 @@
         Private slot to show the firmware version of the connected device and the
         available firmware version.
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.showCircuitPythonVersions()
+
         if self.microPython.isConnected():
             if self._deviceData["mpy_name"] == "micropython":
                 url = QUrl(FirmwareGithubUrls["micropython"])
@@ -471,7 +507,7 @@
         """
         Private slot to reset the connected device.
         """
-        if self.microPython.isConnected():
+        if self.microPython.isConnected() and not self.hasCircuitPython():
             self.microPython.deviceInterface().execute(
                 "import machine\nmachine.reset()\n", mode=self._submitMode
             )
@@ -509,6 +545,9 @@
         @return documentation URL of the device
         @rtype str
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.getDocumentationUrl()
+
         return Preferences.getMicroPython("MicroPythonDocuUrl")
 
     def getFirmwareUrl(self):
@@ -518,6 +557,9 @@
         @return firmware download URL of the device
         @rtype str
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.getFirmwareUrl()
+
         return Preferences.getMicroPython("MicroPythonFirmwareUrl")
 
     ##################################################################
@@ -551,6 +593,9 @@
         # https://docs.micropython.org/en/latest/library/machine.RTC.html#machine-rtc
         #
         # LoBo variant of MPy deviates.
+        if self.hasCircuitPython():
+            return super()._getSetTimeCode()
+
         return """
 def set_time(rtc_time):
     import machine
@@ -578,6 +623,10 @@
             and the WiFi type (esp32)
         @rtype tuple of (bool, str)
         """
+        if self.hasCircuitPython():
+            self.__createCpyDevice()
+            return self.__cpyDevice.hasWifi()
+
         return True, "esp32"
 
     def getWifiData(self):
@@ -589,6 +638,9 @@
         @rtype tuple of (dict, dict, dict)
         @exception OSError raised to indicate an issue with the device
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.getWifiData()
+
         command = """
 def wifi_status():
     import ubinascii
@@ -665,6 +717,9 @@
         @return tuple containing the connection status and an error string
         @rtype tuple of (bool, str)
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.connectWifi(ssid, password)
+
         command = """
 def connect_wifi(ssid, password):
     import network
@@ -714,6 +769,9 @@
         @return tuple containing a flag indicating success and an error string
         @rtype tuple of (bool, str)
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.disconnectWifi()
+
         command = """
 def disconnect_wifi():
     import network
@@ -747,6 +805,9 @@
         @return tuple containing a flag indicating success and an error message
         @rtype tuple of (bool, str)
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.writeCredentials(ssid, password)
+
         nvsCommand = """
 def save_wifi_creds(ssid, password):
     import esp32
@@ -809,6 +870,9 @@
         @return tuple containing a flag indicating success and an error message
         @rtype tuple of (bool, str)
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.removeCredentials()
+
         nvsCommand = """
 def delete_wifi_creds():
     import esp32
@@ -838,6 +902,9 @@
         @return tuple containing a flag indicating reachability and an error string
         @rtype tuple of (bool, str)
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.checkInternet()
+
         command = """
 def check_internet():
     import network
@@ -873,6 +940,9 @@
             'MAC-Address', 'channel', 'RSSI' and 'security' and an error string
         @rtype tuple of (list of tuple of (str, str, int, int, str), str)
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.scanNetworks()
+
         command = """
 def scan_networks():
     import network
@@ -928,6 +998,9 @@
                 "interface must be 'AP' or 'STA', got '{0}'".format(interface)
             )
 
+        if self.hasCircuitPython():
+            return self.__cpyDevice.deactivateInterface(interface)
+
         command = """
 def deactivate():
     import network
@@ -966,6 +1039,11 @@
         @return tuple containing a flag indicating success and an error message
         @rtype tuple of (bool, str)
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.startAccessPoint(
+                ssid, security=security, password=password, ifconfig=ifconfig
+            )
+
         if security is None or password is None:
             security = 0
             password = ""
@@ -1007,6 +1085,9 @@
         @return tuple containg a flag indicating success and an error message
         @rtype tuple of (bool, str)
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.stopAccessPoint()
+
         return self.deactivateInterface("AP")
 
     def getConnectedClients(self):
@@ -1017,6 +1098,9 @@
             and the RSSI (if supported and available) and an error message
         @rtype tuple of ([(bytes, int)], str)
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.getConnectedClients()
+
         command = """
 def get_stations():
     import network
@@ -1050,6 +1134,10 @@
         @rtype bool
         @exception OSError raised to indicate an issue with the device
         """
+        if self.hasCircuitPython():
+            self.__createCpyDevice()
+            return self.__cpyDevice.hasBluetooth()
+
         command = """
 def has_bt():
     try:
@@ -1080,6 +1168,9 @@
         @rtype list of tuples of (str, str)
         @exception OSError raised to indicate an issue with the device
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.getBluetoothStatus()
+
         command = """
 def ble_status():
     import bluetooth
@@ -1139,6 +1230,9 @@
         @rtype bool
         @exception OSError raised to indicate an issue with the device
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.activateBluetoothInterface()
+
         command = """
 def activate_ble():
     import bluetooth
@@ -1165,6 +1259,9 @@
         @rtype bool
         @exception OSError raised to indicate an issue with the device
         """
+        if self.hasCircuitPython():
+            return self.__cpyDevice.deactivateBluetoothInterface()
+
         command = """
 def deactivate_ble():
     import bluetooth
@@ -1196,6 +1293,9 @@
         """
         from ..BluetoothDialogs.BluetoothAdvertisement import BluetoothAdvertisement
 
+        if self.hasCircuitPython():
+            return self.__cpyDevice.getDeviceScan(timeout)
+
         command = """
 def ble_scan():
     import bluetooth

eric ide

mercurial