Open rafifajar22 opened 6 years ago
This is a good question.
Hello, please see #28
Thank you, but this refers to KeyboardInterrupts. How can you stop()
the manager via python code some seconds after calling manager.run()
?
I've added a function for a timeout.
how to stop main loop, because there is blocking, and and I can't call stop function, this my code
import gatt
manager = gatt.DeviceManager(adapter_name='hci0')
class AnyDevice(gatt.Device): def services_resolved(self): super().services_resolved()
psp.write_value(bytearray(b'\x0a')) tes="\x1D\x5A\x02" best=tes.encode() psp.write_value(best) kay="\x1B\x5A\x00\x4C\x08\x11\x00\x43\x44\x3A\x42\x30\x3A\x32\x31\x3A\x32\x31\x3A\x34\x30\x3A\x42\x33" best=kay.encode() psp.write_value(best)
class Manager(gatt.DeviceManager): def run(self): print("Running Manager") super().run() def quit(self): print("Stopping Manager") super().stop()
manager = Manager(adapter_name = 'hci0') device = AnyDevice(mac_address='CD:B0:21:21:40:B3', manager=manager) device.connect()
manager.run() time.sleep(2) manager.quit()