11050:f0b91a949398 | 11051:e8a7be10b76c |
---|---|
449 command = """ | 449 command = """ |
450 def has_wifi(): | 450 def has_wifi(): |
451 try: | 451 try: |
452 import network | 452 import network |
453 if hasattr(network, 'WLAN'): | 453 if hasattr(network, 'WLAN'): |
454 wifi = network.WLAN(network.STA_IF) | |
455 if not wifi.active(): | |
456 wifi.active(True) | |
457 wifi.active(False) | |
454 return True, 'picow' | 458 return True, 'picow' |
455 except ImportError: | 459 except ImportError: |
456 try: | 460 try: |
457 import picowireless as pw | 461 import picowireless as pw |
458 try: | 462 try: |
474 if not err.startswith(b"Timeout "): | 478 if not err.startswith(b"Timeout "): |
475 raise OSError(self._shortError(err)) | 479 raise OSError(self._shortError(err)) |
476 else: | 480 else: |
477 # pimoroni firmware loaded but no pico wireless present | 481 # pimoroni firmware loaded but no pico wireless present |
478 return False, "" | 482 return False, "" |
483 if b"Failed to start CYW43" in out: | |
484 # network module present but no CYW43 chip | |
485 # (pimoroni firmware has everything) | |
486 return False, "" | |
479 return ast.literal_eval(out.decode("utf-8")) | 487 return ast.literal_eval(out.decode("utf-8")) |
480 | 488 |
481 def hasWifiCountry(self): | 489 def hasWifiCountry(self): |
482 """ | 490 """ |
483 Public method to check, if the device has support to set the WiFi country. | 491 Public method to check, if the device has support to set the WiFi country. |
1465 command = """ | 1473 command = """ |
1466 def has_bt(): | 1474 def has_bt(): |
1467 try: | 1475 try: |
1468 import bluetooth | 1476 import bluetooth |
1469 if hasattr(bluetooth, 'BLE'): | 1477 if hasattr(bluetooth, 'BLE'): |
1478 ble = bluetooth.BLE() | |
1479 if not ble.active(): | |
1480 ble.active(True) | |
1481 ble.active(False) | |
1470 return True | 1482 return True |
1471 except ImportError: | 1483 except (ImportError, OSError): |
1472 pass | 1484 pass |
1473 | 1485 |
1474 return False | 1486 return False |
1475 | 1487 |
1476 print(has_bt()) | 1488 print(has_bt()) |