754 def has_wifi(): |
754 def has_wifi(): |
755 try: |
755 try: |
756 import wifi |
756 import wifi |
757 if hasattr(wifi, 'radio'): |
757 if hasattr(wifi, 'radio'): |
758 return True, 'circuitpython' |
758 return True, 'circuitpython' |
759 except ImportError: |
759 except (ImportError, MemoryError): |
760 pass |
760 pass |
761 |
761 |
762 return False, '' |
762 return False, '' |
763 |
763 |
764 print(has_wifi()) |
764 print(has_wifi()) |
765 del has_wifi |
765 del has_wifi |
766 """ |
766 """ |
767 out, err = self.executeCommands(command, mode=self._submitMode) |
767 try: |
768 if err: |
768 return self._deviceData["wifi"], self._deviceData["wifi_type"] |
769 raise OSError(self._shortError(err)) |
769 except KeyError: |
770 return ast.literal_eval(out.decode("utf-8")) |
770 out, err = self.executeCommands(command, mode=self._submitMode) |
|
771 if err: |
|
772 raise OSError(self._shortError(err)) |
|
773 return ast.literal_eval(out.decode("utf-8")) |
771 |
774 |
772 def getWifiData(self): |
775 def getWifiData(self): |
773 """ |
776 """ |
774 Public method to get data related to the current WiFi status. |
777 Public method to get data related to the current WiFi status. |
775 |
778 |
1350 return False, '' |
1353 return False, '' |
1351 |
1354 |
1352 print(has_eth()) |
1355 print(has_eth()) |
1353 del has_eth |
1356 del has_eth |
1354 """ |
1357 """ |
1355 |
1358 try: |
1356 out, err = self.executeCommands(command, mode=self._submitMode, timeout=10000) |
1359 return self._deviceData["ethernet"], self._deviceData["ethernet_type"] |
1357 if err: |
1360 except KeyError: |
1358 raise OSError(self._shortError(err)) |
1361 out, err = self.executeCommands( |
1359 |
1362 command, mode=self._submitMode, timeout=10000 |
1360 return ast.literal_eval(out.decode("utf-8")) |
1363 ) |
|
1364 if err: |
|
1365 raise OSError(self._shortError(err)) |
|
1366 |
|
1367 return ast.literal_eval(out.decode("utf-8")) |
1361 |
1368 |
1362 def getEthernetStatus(self): |
1369 def getEthernetStatus(self): |
1363 """ |
1370 """ |
1364 Public method to get Ethernet status data of the connected board. |
1371 Public method to get Ethernet status data of the connected board. |
1365 |
1372 |
1705 return False |
1712 return False |
1706 |
1713 |
1707 print(has_bt()) |
1714 print(has_bt()) |
1708 del has_bt |
1715 del has_bt |
1709 """ |
1716 """ |
1710 out, err = self.executeCommands(command, mode=self._submitMode, timeout=10000) |
1717 try: |
1711 if err: |
1718 return self._deviceData["bluetooth"] |
1712 raise OSError(self._shortError(err)) |
1719 except KeyError: |
1713 return out.strip() == b"True" |
1720 out, err = self.executeCommands( |
|
1721 command, mode=self._submitMode, timeout=10000 |
|
1722 ) |
|
1723 if err: |
|
1724 raise OSError(self._shortError(err)) |
|
1725 return out.strip() == b"True" |
1714 |
1726 |
1715 def getBluetoothStatus(self): |
1727 def getBluetoothStatus(self): |
1716 """ |
1728 """ |
1717 Public method to get Bluetooth status data of the connected board. |
1729 Public method to get Bluetooth status data of the connected board. |
1718 |
1730 |