-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_basic.py
More file actions
25 lines (18 loc) · 838 Bytes
/
example_basic.py
File metadata and controls
25 lines (18 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import asyncio
from aidlab import AidlabManager, DataType, Device, DeviceDelegate, DisconnectReason
class MainManager(DeviceDelegate):
async def run(self):
devices = await AidlabManager().scan()
if len(devices) > 0:
print("Connecting to:", devices[0].address)
await devices[0].connect(self)
while True:
await asyncio.sleep(1)
def did_connect(self, device: Device):
print("Connected to:", device.address)
asyncio.create_task(device.collect([DataType.RESPIRATION], []))
def did_disconnect(self, device: Device, reason: DisconnectReason):
print("Disconnected from:", device.address, reason)
def did_receive_respiration(self, device: Device, timestamp: int, value: float):
print(value)
asyncio.run(MainManager().run())