diff -r 3112f77f722b -r 67414f28db68 src/eric7/MicroPython/Devices/RP2040Devices.py --- a/src/eric7/MicroPython/Devices/RP2040Devices.py Mon Feb 20 11:42:45 2023 +0100 +++ b/src/eric7/MicroPython/Devices/RP2040Devices.py Mon Feb 20 16:02:02 2023 +0100 @@ -661,7 +661,7 @@ # TODO: not yet implemented pass else: - return super().checkInternet() + return super().scanNetworks() out, err = self._interface.execute(command, timeout=15000) if err: @@ -683,6 +683,71 @@ return networks, "" + def deactivateInterface(self, interface): + """ + Public method to deactivate a given WiFi interface of the connected device. + + @param interface designation of the interface to be deactivated (one of 'AP' + or 'STA') + @type str + @return tuple containg a flag indicating success and an error message + @rtype tuple of (bool, str) + @exception ValueError raised to indicate a wrong value for the interface type + """ + if interface not in ("STA", "AP"): + raise ValueError( + "interface must be 'AP' or 'STA', got '{0}'".format(interface) + ) + + if self._deviceData["wifi_type"] == "picow": + command = """ +def deactivate(): + import network + from time import sleep + + wifi = network.WLAN(network.{0}_IF) + wifi.active(False) + sleep(0.1) + print(not wifi.active()) + +deactivate() +del deactivate +""".format(interface) + elif self._deviceData["wifi_type"] == "pimoroni": + # TODO: not yet implemented + pass + else: + return super().deactivateInterface(interface) + + out, err = self._interface.execute(command, timeout=15000) + if err: + return False, err + else: + return out.decode("utf-8").strip() == "True", "" + + def startAccessPoint(self): + """ + Public method to start the access point interface. + + @return tuple containing a flag indicating success and an error message + @rtype tuple of (bool, str) + """ + + def stopAccessPoint(self): + """ + Public method to stop the access point interface. + + @return tuple containg a flag indicating success and an error message + @rtype tuple of (bool, str) + """ + if self._deviceData["wifi_type"] == "picow": + return self.deactivateInterface("AP") + elif self._deviceData["wifi_type"] == "pimoroni": + # TODO: not yet implemented + pass + else: + return super().stopAccessPoint() + ############################################################################ ## RP2 only methods below ############################################################################