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

scan.py 726B

1234567891011121314151617181920212223
  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, name = "S&B VOLCANO H", timeout = 0.5):
  7. scanner = aioble.scan(int(timeout * 1000.0), interval_us=30000, window_us=30000, active=True)
  8. async with scanner as s:
  9. results = []
  10. async for d in s:
  11. if addr != None:
  12. if addr == d.device.addr_hex():
  13. return d
  14. elif name != None:
  15. if d.name() == name:
  16. return d
  17. else:
  18. results.append(d)
  19. return results
  20. return None