--- a/src/eric7/MicroPython/Devices/DeviceBase.py Tue Feb 21 10:53:46 2023 +0100 +++ b/src/eric7/MicroPython/Devices/DeviceBase.py Wed Feb 22 07:45:54 2023 +0100 @@ -33,19 +33,19 @@ the time on the board and getting board related data. Supported file system commands are: <ul> - <li>ls: directory listing</li> + <li>cd: change directory</li> + <li>fileSystemInfo: get information about the file system + <li>get: get a file from the connected device</li> + <li>getData: read data of a file of the connected device</li> <li>lls: directory listing with meta data</li> - <li>cd: change directory</li> - <li>pwd: get the current directory</li> + <li>ls: directory listing</li> + <li>mkdir: create a new directory</li> <li>put: copy a file to the connected device</li> <li>putData: write data to a file of the connected device</li> - <li>get: get a file from the connected device</li> - <li>getData: read data of a file of the connected device</li> + <li>pwd: get the current directory</li> <li>rm: remove a file from the connected device</li> + <li>rmdir: remove an empty directory</li> <li>rmrf: remove a file/directory recursively (like 'rm -rf' in bash) - <li>mkdir: create a new directory</li> - <li>rmdir: remove an empty directory</li> - <li>fileSystemInfo: get information about the file system </ul> Supported non file system commands are: @@ -55,10 +55,15 @@ information</li> <li>getModules: get a list of built-in modules</li> <li>getTime: get the current time</li> + <li>showTime: show the current time of the connected device</li> <li>syncTime: synchronize the time of the connected device</li> - <li>showTime: show the current time of the connected device</li> + </ul> + + Supported WiFi commands are: + <ul> </ul> """ + # TODO: complete the list of supported commands def __init__(self, microPythonWidget, deviceType, parent=None): """ @@ -417,25 +422,6 @@ """ return [] - def _showError(self, method, error): - """ - Protected method to show some error message. - - @param method name of the method the error occured in - @type str - @param error error message - @type str - """ - EricMessageBox.warning( - self, - self.tr("Error handling device"), - self.tr( - "<p>There was an error communicating with the" - " connected device.</p><p>Method: {0}</p>" - "<p>Message: {1}</p>" - ).format(method, error), - ) - def _shortError(self, error): """ Protected method to create a shortened error message. @@ -588,7 +574,11 @@ if filename: command = """ import os as __os_ -__os_.remove('{0}') +try: + __os_.remove('{0}') +except OSError as err: + if err.errno != 2: + raise err del __os_ """.format( filename @@ -1189,6 +1179,15 @@ """ return False, "" + def addDeviceWifiEntries(self, menu): + """ + Public method to add device specific entries to the given menu. + + @param menu reference to the context menu + @type QMenu + """ + pass + def getWifiData(self): """ Public method to get data related to the current WiFi status @@ -1221,6 +1220,29 @@ """ return True, "" + def writeCredentials(self, ssid, password): + """ + Public method to write the given credentials to the connected device and modify + the start script to connect automatically. + + @param ssid SSID of the network to connect to + @type str + @param password password needed to authenticate + @type str + @return tuple containing a flag indicating success and an error message + @rtype tuple of (bool, str) + """ + return False, "" + + def removeCredentials(self): + """ + Public method to remove the saved credentials from the connected device. + + @return tuple containing a flag indicating success and an error message + @rtype tuple of (bool, str) + """ + return False, "" + def checkInternet(self): """ Public method to check, if the internet can be reached. @@ -1252,13 +1274,20 @@ """ return True, "" - def startAccessPoint(self): + def startAccessPoint(self, ssid, security=None, password=None): """ Public method to start the access point interface. + @param ssid SSID of the access point + @type str + @param security security method (defaults to None) + @type int (optional) + @param password password (defaults to None) + @type str (optional) @return tuple containing a flag indicating success and an error message @rtype tuple of (bool, str) """ + return False, "" def stopAccessPoint(self): """ @@ -1269,14 +1298,15 @@ """ return True, "" - def addDeviceWifiEntries(self, menu): + def getConnectedClients(self): """ - Public method to add device specific entries to the given menu. + Public method to get a list of connected clients. - @param menu reference to the context menu - @type QMenu + @return a tuple containing a list of tuples containing the client MAC-Address + and the RSSI (if supported and available) and an error message + @rtype tuple of ([(bytes, int)], str) """ - pass + return [], "" ################################################################## ## Methods below implement Ethernet related methods