40 lines
902 B
Python
40 lines
902 B
Python
# %% imports
|
|
import asyncio
|
|
import time
|
|
|
|
import numpy as np
|
|
from bleak import BleakClient, BleakScanner
|
|
from matplotlib import pyplot as plt
|
|
|
|
# %%
|
|
devices = await BleakScanner.discover()
|
|
for d in devices:
|
|
print(d)
|
|
|
|
|
|
# %%
|
|
address = "D7:FC:DA:4B:02:D7"
|
|
MODEL_NBR_UUID = "2A24"
|
|
SENSORS_UUID = "99b594745570464bbe3764465aa050fd"
|
|
|
|
|
|
timeseries = list()
|
|
async with BleakClient(address) as client:
|
|
# model_number = await client.read_gatt_char(MODEL_NBR_UUID)
|
|
# print("Model Number: {0}".format("".join(map(chr, model_number))))
|
|
start_time = time.time()
|
|
print("Starting capture...")
|
|
while time.time() < start_time + 20:
|
|
buffer = await client.read_gatt_char(SENSORS_UUID)
|
|
sensor_values = np.frombuffer(bytes(buffer), dtype=np.double)
|
|
timeseries.append(sensor_values)
|
|
print("DONE")
|
|
|
|
timeseries = np.array(timeseries)
|
|
|
|
# %%
|
|
plt.plot(timeseries)
|
|
plt.show()
|
|
|
|
# %%
|