From 1850be4cffbbe10363e4421649d97ea7f3f1326e Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Fri, 8 Nov 2019 00:13:55 -0600 Subject: [PATCH] Adding back the device discovery --- ConnectToKano.py | 1 + DiscoverBLEDevices.py | 9 ------ byteDecodingPlayground.py | 6 ++-- test2.py | 58 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 12 deletions(-) delete mode 100644 DiscoverBLEDevices.py create mode 100644 test2.py diff --git a/ConnectToKano.py b/ConnectToKano.py index e69de29..449b4e0 100644 --- a/ConnectToKano.py +++ b/ConnectToKano.py @@ -0,0 +1 @@ +etwy \ No newline at end of file diff --git a/DiscoverBLEDevices.py b/DiscoverBLEDevices.py deleted file mode 100644 index c5be575..0000000 --- a/DiscoverBLEDevices.py +++ /dev/null @@ -1,9 +0,0 @@ -import gatt - -class AnyDeviceManager(gatt.DeviceManager): - def device_discovered(self, device): - print("Discovered [%s] %s" % (device.mac_address, device.alias())) - -manager = AnyDeviceManager(adapter_name='hci0') -manager.start_discovery() -manager.run() \ No newline at end of file diff --git a/byteDecodingPlayground.py b/byteDecodingPlayground.py index 0e23cec..e3586fb 100644 --- a/byteDecodingPlayground.py +++ b/byteDecodingPlayground.py @@ -60,10 +60,10 @@ def convert_row_to_bytes(row): data = pd.read_csv("accelerometer.data") -# test_bin_float_converstion() -# test_bin_int_converstion() - for index, row in data.iterrows(): convert_row_to_bytes(row) + +test_bin_float_converstion() +test_bin_int_converstion() diff --git a/test2.py b/test2.py new file mode 100644 index 0000000..2c3655c --- /dev/null +++ b/test2.py @@ -0,0 +1,58 @@ +import asyncio +from bleak import discover + +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()) + +# import asyncio +# from bleak import BleakClient +# +# address = "e3:ae:cd:af:28:e2" +# 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)) \ No newline at end of file