src/eric7/MicroPython/Devices/DeviceBase.py

branch
mpy_network
changeset 9775
c6806d24468b
parent 9773
6fcfe4f25988
child 9776
210bf87ae5c7
equal deleted inserted replaced
9774:c7b712056146 9775:c6806d24468b
91 self._deviceData = {} 91 self._deviceData = {}
92 92
93 if connected: 93 if connected:
94 with contextlib.suppress(OSError): 94 with contextlib.suppress(OSError):
95 self._deviceData = self.__getDeviceData() 95 self._deviceData = self.__getDeviceData()
96 self._deviceData["wifi"], self._deviceData["wifi_type"] = self.hasWifi()
97 self._deviceData["bluetooth"] = self.hasBluetooth()
98 self._deviceData["ethernet"] = self.hasEthernet()
96 99
97 def getDeviceType(self): 100 def getDeviceType(self):
98 """ 101 """
99 Public method to get the device type. 102 Public method to get the device type.
100 103
101 @return type of the device 104 @return type of the device
102 @rtype str 105 @rtype str
103 """ 106 """
104 return self._deviceType 107 return self._deviceType
105 108
106 def getDeviceData(self): 109 def getDeviceData(self, key=None):
107 """ 110 """
108 Public method to get a copy of the determined device data. 111 Public method to get a copy of the determined device data.
109 112
113 @param key name of the data to get (None to get all data) (defaults to None)
114 @type str (optional)
110 @return dictionary containing the essential device data 115 @return dictionary containing the essential device data
111 @rtype dict 116 @rtype dict
112 """ 117 """
113 return copy.deepcopy(self._deviceData) 118 if key is None:
119 return copy.deepcopy(self._deviceData)
120 else:
121 return self._deviceData[key]
114 122
115 def checkDeviceData(self): 123 def checkDeviceData(self):
116 """ 124 """
117 Public method to check the validity of the device data determined during 125 Public method to check the validity of the device data determined during
118 connecting the device. 126 connecting the device.
1145 ) 1153 )
1146 out, err = self._interface.execute(command) 1154 out, err = self._interface.execute(command)
1147 if err: 1155 if err:
1148 raise OSError(self._shortError(err)) 1156 raise OSError(self._shortError(err))
1149 1157
1158 ##################################################################
1159 ## Methods below implement WiFi related methods
1160 ##################################################################
1161
1162 def hasWifi(self):
1163 """
1164 Public method to check the availability of WiFi.
1165
1166 @return tuple containing a flag indicating the availability of WiFi
1167 and the WiFi type (picow or pimoroni)
1168 @rtype tuple of (bool, str)
1169 @exception OSError raised to indicate an issue with the device
1170 """
1171 return False, ""
1172
1173 def getWifiData(self):
1174 """
1175 Public method to get data related to the current WiFi status
1176
1177 @return tuple of two dictionaries containing the WiFi status data
1178 for the WiFi client and access point
1179 @rtype tuple of (dict, dict)
1180 """
1181 return {}, {}
1182
1183 def addDeviceWifiEntries(self, menu):
1184 """
1185 Public method to add device specific entries to the given menu.
1186
1187 @param menu reference to the context menu
1188 @type QMenu
1189 """
1190 pass
1191
1192 ##################################################################
1193 ## Methods below implement Ethernet related methods
1194 ##################################################################
1195
1196 def hasEthernet(self):
1197 """
1198 Public method to check the availability of Ethernet.
1199
1200 @return flag indicating the availability of Ethernet
1201 @rtype bool
1202 """
1203 return False
1204
1205 ##################################################################
1206 ## Methods below implement Bluetooth related methods
1207 ##################################################################
1208
1209 def hasBluetooth(self):
1210 """
1211 Public method to check the availability of Bluetooth.
1212
1213 @return flag indicating the availability of Bluetooth
1214 @rtype bool
1215 """
1216 return False
1150 1217
1151 # 1218 #
1152 # eflag: noqa = M613 1219 # eflag: noqa = M613

eric ide

mercurial