31 in the board specific subclass. Commands are provided to perform operations |
31 in the board specific subclass. Commands are provided to perform operations |
32 on the file system of a connected MicroPython device, for getting and setting |
32 on the file system of a connected MicroPython device, for getting and setting |
33 the time on the board and getting board related data. Supported file system |
33 the time on the board and getting board related data. Supported file system |
34 commands are: |
34 commands are: |
35 <ul> |
35 <ul> |
|
36 <li>cd: change directory</li> |
|
37 <li>fileSystemInfo: get information about the file system |
|
38 <li>get: get a file from the connected device</li> |
|
39 <li>getData: read data of a file of the connected device</li> |
|
40 <li>lls: directory listing with meta data</li> |
36 <li>ls: directory listing</li> |
41 <li>ls: directory listing</li> |
37 <li>lls: directory listing with meta data</li> |
42 <li>mkdir: create a new directory</li> |
38 <li>cd: change directory</li> |
|
39 <li>pwd: get the current directory</li> |
|
40 <li>put: copy a file to the connected device</li> |
43 <li>put: copy a file to the connected device</li> |
41 <li>putData: write data to a file of the connected device</li> |
44 <li>putData: write data to a file of the connected device</li> |
42 <li>get: get a file from the connected device</li> |
45 <li>pwd: get the current directory</li> |
43 <li>getData: read data of a file of the connected device</li> |
|
44 <li>rm: remove a file from the connected device</li> |
46 <li>rm: remove a file from the connected device</li> |
|
47 <li>rmdir: remove an empty directory</li> |
45 <li>rmrf: remove a file/directory recursively (like 'rm -rf' in bash) |
48 <li>rmrf: remove a file/directory recursively (like 'rm -rf' in bash) |
46 <li>mkdir: create a new directory</li> |
|
47 <li>rmdir: remove an empty directory</li> |
|
48 <li>fileSystemInfo: get information about the file system |
|
49 </ul> |
49 </ul> |
50 |
50 |
51 Supported non file system commands are: |
51 Supported non file system commands are: |
52 <ul> |
52 <ul> |
53 <li>getBoardData: get information about the connected board</li> |
53 <li>getBoardData: get information about the connected board</li> |
54 <li>getDeviceData: get version info about MicroPython and some implementation |
54 <li>getDeviceData: get version info about MicroPython and some implementation |
55 information</li> |
55 information</li> |
56 <li>getModules: get a list of built-in modules</li> |
56 <li>getModules: get a list of built-in modules</li> |
57 <li>getTime: get the current time</li> |
57 <li>getTime: get the current time</li> |
|
58 <li>showTime: show the current time of the connected device</li> |
58 <li>syncTime: synchronize the time of the connected device</li> |
59 <li>syncTime: synchronize the time of the connected device</li> |
59 <li>showTime: show the current time of the connected device</li> |
60 </ul> |
|
61 |
|
62 Supported WiFi commands are: |
|
63 <ul> |
60 </ul> |
64 </ul> |
61 """ |
65 """ |
|
66 # TODO: complete the list of supported commands |
62 |
67 |
63 def __init__(self, microPythonWidget, deviceType, parent=None): |
68 def __init__(self, microPythonWidget, deviceType, parent=None): |
64 """ |
69 """ |
65 Constructor |
70 Constructor |
66 |
71 |
414 @return list of tuples with menu text and URL to be opened for each |
419 @return list of tuples with menu text and URL to be opened for each |
415 entry |
420 entry |
416 @rtype list of tuple of (str, str) |
421 @rtype list of tuple of (str, str) |
417 """ |
422 """ |
418 return [] |
423 return [] |
419 |
|
420 def _showError(self, method, error): |
|
421 """ |
|
422 Protected method to show some error message. |
|
423 |
|
424 @param method name of the method the error occured in |
|
425 @type str |
|
426 @param error error message |
|
427 @type str |
|
428 """ |
|
429 EricMessageBox.warning( |
|
430 self, |
|
431 self.tr("Error handling device"), |
|
432 self.tr( |
|
433 "<p>There was an error communicating with the" |
|
434 " connected device.</p><p>Method: {0}</p>" |
|
435 "<p>Message: {1}</p>" |
|
436 ).format(method, error), |
|
437 ) |
|
438 |
424 |
439 def _shortError(self, error): |
425 def _shortError(self, error): |
440 """ |
426 """ |
441 Protected method to create a shortened error message. |
427 Protected method to create a shortened error message. |
442 |
428 |
1187 @rtype tuple of (bool, str) |
1177 @rtype tuple of (bool, str) |
1188 @exception OSError raised to indicate an issue with the device |
1178 @exception OSError raised to indicate an issue with the device |
1189 """ |
1179 """ |
1190 return False, "" |
1180 return False, "" |
1191 |
1181 |
|
1182 def addDeviceWifiEntries(self, menu): |
|
1183 """ |
|
1184 Public method to add device specific entries to the given menu. |
|
1185 |
|
1186 @param menu reference to the context menu |
|
1187 @type QMenu |
|
1188 """ |
|
1189 pass |
|
1190 |
1192 def getWifiData(self): |
1191 def getWifiData(self): |
1193 """ |
1192 """ |
1194 Public method to get data related to the current WiFi status |
1193 Public method to get data related to the current WiFi status |
1195 |
1194 |
1196 @return tuple of two dictionaries containing the WiFi status data |
1195 @return tuple of two dictionaries containing the WiFi status data |
1219 @return tuple containing a flag indicating success and an error string |
1218 @return tuple containing a flag indicating success and an error string |
1220 @rtype tuple of (bool, str) |
1219 @rtype tuple of (bool, str) |
1221 """ |
1220 """ |
1222 return True, "" |
1221 return True, "" |
1223 |
1222 |
|
1223 def writeCredentials(self, ssid, password): |
|
1224 """ |
|
1225 Public method to write the given credentials to the connected device and modify |
|
1226 the start script to connect automatically. |
|
1227 |
|
1228 @param ssid SSID of the network to connect to |
|
1229 @type str |
|
1230 @param password password needed to authenticate |
|
1231 @type str |
|
1232 @return tuple containing a flag indicating success and an error message |
|
1233 @rtype tuple of (bool, str) |
|
1234 """ |
|
1235 return False, "" |
|
1236 |
|
1237 def removeCredentials(self): |
|
1238 """ |
|
1239 Public method to remove the saved credentials from the connected device. |
|
1240 |
|
1241 @return tuple containing a flag indicating success and an error message |
|
1242 @rtype tuple of (bool, str) |
|
1243 """ |
|
1244 return False, "" |
|
1245 |
1224 def checkInternet(self): |
1246 def checkInternet(self): |
1225 """ |
1247 """ |
1226 Public method to check, if the internet can be reached. |
1248 Public method to check, if the internet can be reached. |
1227 |
1249 |
1228 @return tuple containing a flag indicating reachability and an error string |
1250 @return tuple containing a flag indicating reachability and an error string |
1250 @return tuple containg a flag indicating success and an error message |
1272 @return tuple containg a flag indicating success and an error message |
1251 @rtype tuple of (bool, str) |
1273 @rtype tuple of (bool, str) |
1252 """ |
1274 """ |
1253 return True, "" |
1275 return True, "" |
1254 |
1276 |
1255 def startAccessPoint(self): |
1277 def startAccessPoint(self, ssid, security=None, password=None): |
1256 """ |
1278 """ |
1257 Public method to start the access point interface. |
1279 Public method to start the access point interface. |
1258 |
1280 |
|
1281 @param ssid SSID of the access point |
|
1282 @type str |
|
1283 @param security security method (defaults to None) |
|
1284 @type int (optional) |
|
1285 @param password password (defaults to None) |
|
1286 @type str (optional) |
1259 @return tuple containing a flag indicating success and an error message |
1287 @return tuple containing a flag indicating success and an error message |
1260 @rtype tuple of (bool, str) |
1288 @rtype tuple of (bool, str) |
1261 """ |
1289 """ |
|
1290 return False, "" |
1262 |
1291 |
1263 def stopAccessPoint(self): |
1292 def stopAccessPoint(self): |
1264 """ |
1293 """ |
1265 Public method to stop the access point interface. |
1294 Public method to stop the access point interface. |
1266 |
1295 |
1267 @return tuple containg a flag indicating success and an error message |
1296 @return tuple containg a flag indicating success and an error message |
1268 @rtype tuple of (bool, str) |
1297 @rtype tuple of (bool, str) |
1269 """ |
1298 """ |
1270 return True, "" |
1299 return True, "" |
1271 |
1300 |
1272 def addDeviceWifiEntries(self, menu): |
1301 def getConnectedClients(self): |
1273 """ |
1302 """ |
1274 Public method to add device specific entries to the given menu. |
1303 Public method to get a list of connected clients. |
1275 |
1304 |
1276 @param menu reference to the context menu |
1305 @return a tuple containing a list of tuples containing the client MAC-Address |
1277 @type QMenu |
1306 and the RSSI (if supported and available) and an error message |
1278 """ |
1307 @rtype tuple of ([(bytes, int)], str) |
1279 pass |
1308 """ |
|
1309 return [], "" |
1280 |
1310 |
1281 ################################################################## |
1311 ################################################################## |
1282 ## Methods below implement Ethernet related methods |
1312 ## Methods below implement Ethernet related methods |
1283 ################################################################## |
1313 ################################################################## |
1284 |
1314 |