Sat, 29 Jul 2023 19:27:18 +0200
MicroPython
- Optimized the MicroPython super menu handling a little bit.
--- a/src/eric7/APIs/Python3/eric7.api Sat Jul 29 16:45:57 2023 +0200 +++ b/src/eric7/APIs/Python3/eric7.api Sat Jul 29 19:27:18 2023 +0200 @@ -2729,6 +2729,7 @@ eric7.MicroPython.Devices.DeviceBase.BaseDevice.hasNetworkTime?4() eric7.MicroPython.Devices.DeviceBase.BaseDevice.hasTimeCommands?4() eric7.MicroPython.Devices.DeviceBase.BaseDevice.hasWifi?4() +eric7.MicroPython.Devices.DeviceBase.BaseDevice.isNetworkConnected?4() eric7.MicroPython.Devices.DeviceBase.BaseDevice.lls?4(dirname="", fullstat=False, showHidden=False) eric7.MicroPython.Devices.DeviceBase.BaseDevice.ls?4(dirname="") eric7.MicroPython.Devices.DeviceBase.BaseDevice.mipInstall?4(package, index=None, target=None, version=None, mpy=True)
--- a/src/eric7/Documentation/Help/source.qhp Sat Jul 29 16:45:57 2023 +0200 +++ b/src/eric7/Documentation/Help/source.qhp Sat Jul 29 19:27:18 2023 +0200 @@ -2198,6 +2198,7 @@ <keyword name="BaseDevice.hasNetworkTime" id="BaseDevice.hasNetworkTime" ref="eric7.MicroPython.Devices.DeviceBase.html#BaseDevice.hasNetworkTime" /> <keyword name="BaseDevice.hasTimeCommands" id="BaseDevice.hasTimeCommands" ref="eric7.MicroPython.Devices.DeviceBase.html#BaseDevice.hasTimeCommands" /> <keyword name="BaseDevice.hasWifi" id="BaseDevice.hasWifi" ref="eric7.MicroPython.Devices.DeviceBase.html#BaseDevice.hasWifi" /> + <keyword name="BaseDevice.isNetworkConnected" id="BaseDevice.isNetworkConnected" ref="eric7.MicroPython.Devices.DeviceBase.html#BaseDevice.isNetworkConnected" /> <keyword name="BaseDevice.lls" id="BaseDevice.lls" ref="eric7.MicroPython.Devices.DeviceBase.html#BaseDevice.lls" /> <keyword name="BaseDevice.ls" id="BaseDevice.ls" ref="eric7.MicroPython.Devices.DeviceBase.html#BaseDevice.ls" /> <keyword name="BaseDevice.mipInstall" id="BaseDevice.mipInstall" ref="eric7.MicroPython.Devices.DeviceBase.html#BaseDevice.mipInstall" />
--- a/src/eric7/Documentation/Source/eric7.MicroPython.Devices.DeviceBase.html Sat Jul 29 16:45:57 2023 +0200 +++ b/src/eric7/Documentation/Source/eric7.MicroPython.Devices.DeviceBase.html Sat Jul 29 19:27:18 2023 +0200 @@ -383,6 +383,10 @@ <td>Public method to check the availability of WiFi.</td> </tr> <tr> +<td><a href="#BaseDevice.isNetworkConnected">isNetworkConnected</a></td> +<td>Public method to check, if the network interface (WiFi or Ethernet) is connected.</td> +</tr> +<tr> <td><a href="#BaseDevice.lls">lls</a></td> <td>Public method to get a long directory listing of the connected device including meta data.</td> </tr> @@ -1721,6 +1725,26 @@ tuple of (bool, str) </dd> </dl> +<a NAME="BaseDevice.isNetworkConnected" ID="BaseDevice.isNetworkConnected"></a> +<h4>BaseDevice.isNetworkConnected</h4> +<b>isNetworkConnected</b>(<i></i>) + +<p> + Public method to check, if the network interface (WiFi or Ethernet) is + connected. +</p> +<dl> +<dt>Return:</dt> +<dd> +flag indicating the network connection state +</dd> +</dl> +<dl> +<dt>Return Type:</dt> +<dd> +bool +</dd> +</dl> <a NAME="BaseDevice.lls" ID="BaseDevice.lls"></a> <h4>BaseDevice.lls</h4> <b>lls</b>(<i>dirname="", fullstat=False, showHidden=False</i>)
--- a/src/eric7/MicroPython/Devices/CircuitPythonDevices.py Sat Jul 29 16:45:57 2023 +0200 +++ b/src/eric7/MicroPython/Devices/CircuitPythonDevices.py Sat Jul 29 19:27:18 2023 +0200 @@ -911,6 +911,8 @@ result = json.loads(out.decode("utf-8").strip()) error = "" if result["connected"] else result["status"] + self._networkConnected = result["connected"] + return result["connected"], error def disconnectWifi(self): @@ -942,6 +944,8 @@ if err: return False, err + self._networkConnected = False + result = json.loads(out.decode("utf-8").strip()) return result["success"], result["status"] @@ -1394,6 +1398,8 @@ if err: return False, err + self._networkConnected = True + return out.strip() == b"True", "" def disconnectFromLan(self): @@ -1426,6 +1432,8 @@ if err: return False, err + self._networkConnected = False + return out.strip() == b"True", "" def checkInternetViaLan(self):
--- a/src/eric7/MicroPython/Devices/DeviceBase.py Sat Jul 29 16:45:57 2023 +0200 +++ b/src/eric7/MicroPython/Devices/DeviceBase.py Sat Jul 29 19:27:18 2023 +0200 @@ -121,6 +121,7 @@ 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 @@ -227,6 +228,16 @@ 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.
--- a/src/eric7/MicroPython/Devices/EspDevices.py Sat Jul 29 16:45:57 2023 +0200 +++ b/src/eric7/MicroPython/Devices/EspDevices.py Sat Jul 29 19:27:18 2023 +0200 @@ -760,6 +760,8 @@ except KeyError: error = str(result["status"]) + self._networkConnected = result["connected"] + return result["connected"], error def disconnectWifi(self): @@ -791,6 +793,8 @@ if err: return False, err + self._networkConnected = False + return out.decode("utf-8").strip() == "True", "" def writeCredentials(self, ssid, password):
--- a/src/eric7/MicroPython/Devices/RP2040Devices.py Sat Jul 29 16:45:57 2023 +0200 +++ b/src/eric7/MicroPython/Devices/RP2040Devices.py Sat Jul 29 19:27:18 2023 +0200 @@ -599,7 +599,7 @@ ][station["status"]] except KeyError: station["status"] = str(station["status"]) - if "status" in station: + if "status" in ap: # translate the numerical status to a string try: ap["status"] = self.__statusTranslations[self._deviceData["wifi_type"]][ @@ -714,6 +714,8 @@ except KeyError: error = str(result["status"]) + self._networkConnected = result["connected"] + return result["connected"], error def disconnectWifi(self): @@ -759,6 +761,8 @@ if err: return False, err + self._networkConnected = False + return out.decode("utf-8").strip() == "True", "" def writeCredentials(self, ssid, password): @@ -1609,6 +1613,8 @@ if err: return False, err + self._networkConnected = True + return out.strip() == b"True", "" def disconnectFromLan(self): @@ -1641,6 +1647,8 @@ if err: return False, err + self._networkConnected = False + return out.strip() == b"True", "" def checkInternetViaLan(self):
--- a/src/eric7/MicroPython/MicroPythonWidget.py Sat Jul 29 16:45:57 2023 +0200 +++ b/src/eric7/MicroPython/MicroPythonWidget.py Sat Jul 29 19:27:18 2023 +0200 @@ -970,9 +970,15 @@ self.__superMenu.clear() if self.__device: - hasMip = self.__device.getDeviceData("mip") - hasUPip = self.__device.getDeviceData("upip") - useLocalMip = self.__device.getDeviceData("local_mip") + networkConnected = self.__device.isNetworkConnected() + useLocalMip = ( + ( + self.__device.getDeviceData("mip") + or self.__device.getDeviceData("upip") + ) and not networkConnected + ) or self.__device.getDeviceData("local_mip") + hasMip = self.__device.getDeviceData("mip") and networkConnected + hasUPip = self.__device.getDeviceData("upip") and networkConnected else: hasMip = False hasUPip = False