--- a/src/eric7/MicroPython/Devices/DeviceBase.py Sun Jul 30 17:33:54 2023 +0200 +++ b/src/eric7/MicroPython/Devices/DeviceBase.py Sun Jul 30 17:50:38 2023 +0200 @@ -70,6 +70,8 @@ <li>getWifiData: get WiFi status data</li> <li>connectWifi: connect to a WiFi network</li> <li>disconnectWifi: disconnect from a WiFi network</li> + <li>isWifiClientConnected: check the WiFi connection status as client</li> + <li>isWifiApConnected: check the WiFi connection status as access point</li> <li>writeCredentials: save the WiFi credentials to the board and create functionality to auto-connect at boot time</li> <li>removeCredentials: remove the saved credentials</li> @@ -92,15 +94,16 @@ Supported Ethernet commands are: <ul> - <li>hasEthernet: check, if the board has Ethernet functionality - <li>getEthernetStatus: get Ethernet status data - <li>connectToLan: connect to an Ethernet network - <li>disconnectFromLan: disconnect from an Ethernet network - <li>checkInternetViaLan: check, if internet access via LAN is possible - <li>deactivateEthernet: deactivate the Ethernet interface + <li>hasEthernet: check, if the board has Ethernet functionality</li> + <li>getEthernetStatus: get Ethernet status data</li> + <li>connectToLan: connect to an Ethernet network</li> + <li>disconnectFromLan: disconnect from an Ethernet network</li> + <li>isLanConnected: check the LAN connection status</li> + <li>checkInternetViaLan: check, if internet access via LAN is possible</li> + <li>deactivateEthernet: deactivate the Ethernet interface</li> <li>writeLanAutoConnect: save IPv4 parameters to the board and create a script - to connect the board to the LAN - <li>removeLanAutoConnect: remove the IPv4 parameters and script from the board + to connect the board to the LAN</li> + <li>removeLanAutoConnect: remove the IPv4 parameters and script from the board</li> </ul> """ @@ -121,7 +124,6 @@ self._interface = None self.microPython = microPythonWidget self._deviceData = {} # dictionary with essential device data - self._networkConnected = False # trace the network connection status self._submitMode = "raw" # default is 'raw' mode to submit commands @@ -228,16 +230,6 @@ and self._deviceData["mpy_name"].lower() == "circuitpython" ) - def isNetworkConnected(self): - """ - Public method to check, if the network interface (WiFi or Ethernet) is - connected. - - @return flag indicating the network connection state - @rtype bool - """ - return self._networkConnected - def submitMode(self): """ Public method to get the submit mode of the device. @@ -1455,6 +1447,26 @@ return ast.literal_eval(out.decode("utf-8")) ################################################################## + ## Methods below general network related methods + ################################################################## + + def isNetworkConnected(self): + """ + Public method to check, if the network interface (WiFi or Ethernet) is + connected. + + @return flag indicating the network connection state + @rtype bool + """ + # Ask the device if that is true. + if self.hasEthernet()[0]: + return self.isLanConnected() + elif self.hasWifi(): + return self.isWifiClientConnected() + else: + return False + + ################################################################## ## Methods below implement WiFi related methods ################################################################## @@ -1509,6 +1521,24 @@ """ return True, "" + def isWifiClientConnected(self): + """ + Public method to check the WiFi connection status as client. + + @return flag indicating the WiFi connection status + @rtype bool + """ + return False + + def isWifiApConnected(self): + """ + Public method to check the WiFi connection status as access point. + + @return flag indicating the WiFi connection status + @rtype bool + """ + return False + def writeCredentials(self, ssid, password): # noqa: U100 """ Public method to write the given credentials to the connected device and modify @@ -1678,6 +1708,15 @@ """ return 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 + """ + return False + def checkInternetViaLan(self): """ Public method to check, if the internet can be reached (LAN variant).