Refactoring code from original POC phase - integers have been decoded roughly successfully so its time to start building a huge library for this bad boy

This commit is contained in:
Lucas Oskorep
2019-11-08 12:58:37 -06:00
parent 48866f6af2
commit 564eed46d5
14 changed files with 223 additions and 246 deletions
@@ -0,0 +1,56 @@
import asyncio
from bleak import discover, BleakClient
from pprint import pprint
async def run():
devices = await discover()
for d in devices:
print(d)
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
address = "D8:9B:12:D1:08:80"
MODEL_NBR_UUID = "64a7000f-f691-4b93-a6f4-0968f5b648f8"
async def run(address, loop):
async with BleakClient(address, loop=loop) as client:
# await client.connect()
print(await client.is_connected())
print(await client.get_services())
services = await client.get_services()
pprint(services.descriptors)
pprint(services.characteristics)
pprint(services.services)
# print(services.descriptors)
# for key, val in services.descriptors.items():
# print(f"{key} + {val}")
#
# print(services.characteristics)
# for key, val in services.characteristics.items():
# print(f"{key} + {val}")
print(services)
for x in services:
print(x)
for characteristic in x.characteristics:
print("")
print(characteristic)
print(characteristic.properties)
for descriptor in characteristic.descriptors:
print(descriptor)
print(x.description)
# for i in range(10):
# x = await client.read_gatt_descriptor(i)
# print(x)
# model_number = await client.read_gatt_char()
# print(model_number)
# print("Model Number: {0}".format("".join(map(chr, model_number))))
loop = asyncio.get_event_loop()
loop.run_until_complete(run(address, loop))