S&B Volcano vaporizer remote control with Pi Pico W
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

scan.py 911B

123456789101112131415161718192021222324252627
  1. # https://github.com/micropython/micropython-lib/blob/master/micropython/bluetooth/aioble/examples/temp_client.py
  2. import uasyncio as asyncio
  3. import aioble
  4. import bluetooth
  5. import sys
  6. async def ble_scan(addr = None, timeout = 0.1):
  7. print("Scanning for '{}' for {}s...".format(addr, timeout))
  8. scanner = aioble.scan(int(timeout * 1000.0), interval_us=30000, window_us=30000, active=True)
  9. async with scanner as s:
  10. async for d in s:
  11. print("Scan: '{}' [{}]".format(d.name(), d.device.addr_hex()))
  12. if addr != None:
  13. if addr == d.device.addr_hex():
  14. return d.device
  15. else:
  16. if d.name() == "S&B VOLCANO H":
  17. return d.device
  18. print("No device found")
  19. return None
  20. if __name__ == "__main__":
  21. dev = asyncio.run(ble_scan())
  22. if dev != None:
  23. print("{}".format(dev.addr_hex()))