<jupyter_start><jupyter_text>First lets find the bryk<jupyter_code>import nest_asyncio
import asyncio
import struct
from bleak import discover, BleakClient # BleakScanner
nest_asyncio.apply()

class PhysBryk(object):
    
    def __init__(self):
        self._device = None
    
    def setDevice(self, ble_device):
        self._device = ble_device
        
    def getAddress(self):
        return self._device.address
        
bryk = PhysBryk()
        
async def run():
    print('Searching...')
    devices = await discover()
    for d in devices:
        print(d.name, d.address, d.rssi, d.metadata)
        if d.name == 'PhysBryk':
            bryk.setDevice(d)
    print('Search completed')
    
    if bryk:
        print(f'PhysBryk found @ {bryk.getAddress()}')
    else:
        print('No PhysBryk found')
    
loop = asyncio.get_event_loop()
loop.run_until_complete(run())

print(bryk)<jupyter_output>Searching...
PhysBryk D8:95:3B:9E:D2:D6 -63 {'uuids': [], 'manufacturer_data': {}}
Unknown C8:69:CD:3B:5E:DC -61 {'uuids': [], 'manufacturer_data': {76: b'\t\x06\x03\x02\n\x86t\xc2'}}
Search completed
PhysBryk found @ D8:95:3B:9E:D2:D6
<__main__.PhysBryk object at 0x000002BFFFBAF3A0><jupyter_text>Now lets connect<jupyter_code>bryk_addr = bryk.getAddress()

INTENSITY_UUID = 'a0d11001-0eaa-5b52-bc84-818888dc7dc5'

async def print_services(mac_addr: str):
#     device = await BleakScanner.find_device_by_address(mac_addr)
    async with BleakClient(mac_addr) as client:
        svcs = await client.get_services()
        print("Services:", svcs)
#         for s in svcs:
#             print(s)
#             for c in s.characteristics: print(c)
        
        light_level = await client.read_gatt_char(INTENSITY_UUID)
        for reading in light_level: print(type(reading))
                

loop = asyncio.get_event_loop()
loop.run_until_complete(print_services(bryk_addr))

# a0d10301-0eaa-5b52-bc84-818888dc7dc5<jupyter_output>Services: <bleak.backends.service.BleakGATTServiceCollection object at 0x000002BFFFBD1B50>
<class 'int'>
<class 'int'>
<class 'int'>
<class 'int'>
{'fraction_non_alphanumeric': 0.12034383954154727, 'fraction_numerical': 0.044412607449856735, 'mean_word_length': 3.447983014861996, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '159996', 'license': 'CC0-1.0', 'n_tokens_mistral': 835, 'n_tokens_neox': 786, 'n_words': 145, 'path': '.ipynb_checkpoints/sandpit-checkpoint.ipynb', 'repo_name': 'Geoffysicist/PhysBryk', 'size': '2094'}