2020-08-12 18:44:23 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
|
|
|
|
from bluepy import btle
|
|
|
|
|
|
|
|
|
|
|
|
class ZeiDiscovery(btle.Scanner):
|
|
|
|
def __init__(self, periph=None, **kwargs):
|
|
|
|
self.zei = periph
|
|
|
|
btle.Scanner.__init__(self, **kwargs)
|
2020-08-16 00:00:08 +02:00
|
|
|
# self.withDelegate(ZeiDiscoveryDelegate(self, self.zei))
|
|
|
|
# self.stop_scanning = False
|
2020-08-12 18:44:23 +02:00
|
|
|
|
|
|
|
def reconnect(self):
|
2020-08-16 00:00:08 +02:00
|
|
|
self.iface = self.zei.iface
|
2020-08-12 18:44:23 +02:00
|
|
|
self.clear()
|
|
|
|
self.start()
|
|
|
|
while self.zei.addr not in self.scanned:
|
|
|
|
self.process(timeout=2)
|
|
|
|
self.stop()
|
2020-08-16 00:00:08 +02:00
|
|
|
self.zei.connect(self.scanned[self.zei.addr])
|