--- a/src/eric7/MicroPython/Devices/RP2040Devices.py Sun Jul 30 17:33:54 2023 +0200 +++ b/src/eric7/MicroPython/Devices/RP2040Devices.py Sun Jul 30 17:50:38 2023 +0200 @@ -714,8 +714,6 @@ except KeyError: error = str(result["status"]) - self._networkConnected = result["connected"] - return result["connected"], error def disconnectWifi(self): @@ -761,9 +759,81 @@ if err: return False, err - self._networkConnected = False + return out.decode("utf-8").strip() == "True", "" + + def isWifiClientConnected(self): + """ + Public method to check the WiFi connection status as client. + + @return flag indicating the WiFi connection status + @rtype bool + """ + if self._deviceData["wifi_type"] == "picow": + command = """ +def wifi_connected(): + import network + + wifi = network.WLAN(network.STA_IF) + print(wifi.isconnected()) + +wifi_connected() +del wifi_connected +""" + elif self._deviceData["wifi_type"] == "picowireless": + command = """ +def wifi_connected(): + import picowireless as pw + + print(pw.get_connection_status() == 3) + +wifi_connected() +del wifi_connected +""" + else: + return super().isWifiClientConnected() + + out, err = self.executeCommands(command, mode=self._submitMode) + if err: + return False - return out.decode("utf-8").strip() == "True", "" + return out.strip() == b"True" + + def isWifiApConnected(self): + """ + Public method to check the WiFi connection status as access point. + + @return flag indicating the WiFi connection status + @rtype bool + """ + if self._deviceData["wifi_type"] == "picow": + command = """ +def wifi_connected(): + import network + + wifi = network.WLAN(network.AP_IF) + print(wifi.isconnected()) + +wifi_connected() +del wifi_connected +""" + elif self._deviceData["wifi_type"] == "picowireless": + command = """ +def wifi_connected(): + import picowireless as pw + + print(pw.get_connection_status() == 8) + +wifi_connected() +del wifi_connected +""" + else: + return super().isWifiClientConnected() + + out, err = self.executeCommands(command, mode=self._submitMode) + if err: + return False + + return out.strip() == b"True" def writeCredentials(self, ssid, password): """ @@ -1613,8 +1683,6 @@ if err: return False, err - self._networkConnected = True - return out.strip() == b"True", "" def disconnectFromLan(self): @@ -1647,9 +1715,34 @@ if err: return False, err - self._networkConnected = False + return out.strip() == b"True", "" + + def isLanConnected(self): + """ + Public method to check the LAN connection status. + + @return flag indicating that the device is connected to the LAN + @rtype bool + """ + command = """{0} +def is_connected(): + import network - return out.strip() == b"True", "" + w5x00_init() + + print(nic.isconnected()) + +is_connected() +del is_connected, w5x00_init +""".format( + WiznetUtilities.mpyWiznetInit(), + ) + + out, err = self.executeCommands(command, mode=self._submitMode) + if err: + return False + + return out.strip() == b"True" def checkInternetViaLan(self): """