Skip to content

Instantly share code, notes, and snippets.

@TakehikoShimojima
Created June 23, 2018 02:10
Show Gist options
  • Select an option

  • Save TakehikoShimojima/d322821fa34afbbee30972a9897d9094 to your computer and use it in GitHub Desktop.

Select an option

Save TakehikoShimojima/d322821fa34afbbee30972a9897d9094 to your computer and use it in GitHub Desktop.
class ScanDelegate(DefaultDelegate):
def __init__(self):
DefaultDelegate.__init__(self)
def handleDiscovery(self, dev, isNewDev, isNewData): # スキャンハンドラー
if isNewDev: # 新しいデバイスが見つかったら
print('found dev (%s)' % dev.addr)
scanner = Scanner().withDelegate(ScanDelegate())
while True:
scanner.scan(10.0) # スキャンする。デバイスを見つけた後の処理はScanDelegateに任せる
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment