@@ -37,20 +37,8 @@ async def main():
37
37
# Inspect the device details
38
38
inspect (device )
39
39
40
- def heartrate_callback (data : HRData ):
41
- console .print (f"[bold green]Received Data:[/bold green] { data } " )
42
-
43
- def data_callback (data : Union [ECGData , ACCData ]):
44
- """
45
- Callback function to handle incoming data from the Polar device.
46
-
47
- Args:
48
- data (Union[ECGData, ACCData]): The data received from the Polar device.
49
- """
50
- console .print (f"[bold green]Received Data:[/bold green] { data } " )
51
-
52
40
# Establish connection to the Polar device
53
- async with PolarDevice (device , data_callback , heartrate_callback ) as polar_device :
41
+ async with PolarDevice (device ) as polar_device :
54
42
# Query available features
55
43
available_features = await polar_device .available_features ()
56
44
inspect (available_features )
@@ -79,6 +67,20 @@ def data_callback(data: Union[ECGData, ACCData]):
79
67
],
80
68
)
81
69
70
+ def heartrate_callback (data : HRData ):
71
+ console .print (f"[bold green]Received Data:[/bold green] { data } " )
72
+
73
+ def data_callback (data : Union [ECGData , ACCData ]):
74
+ """
75
+ Callback function to handle incoming data from the Polar device.
76
+
77
+ Args:
78
+ data (Union[ECGData, ACCData]): The data received from the Polar device.
79
+ """
80
+ console .print (f"[bold green]Received Data:[/bold green] { data } " )
81
+
82
+ polar_device .set_callback (data_callback , heartrate_callback )
83
+
82
84
# Start data streams for ECG and ACC
83
85
await polar_device .start_stream (ecg_settings )
84
86
await polar_device .start_stream (acc_settings )
0 commit comments