Untitled
unknown
python
a year ago
1.6 kB
8
Indexable
import asyncio
from bleak import BleakClient, BleakScanner
async def scan_devices():
print("Scanning for Bluetooth devices...")
devices = await BleakScanner.discover()
for device in devices:
print(f"Found device: {device.name} - {device.address}")
async def uuid_info(device_address):
async with BleakClient(device_address) as client:
#update this function for future
services = await client.get_services()
for service in services:
#print(f"Service: {service.uuid}")
for characteristic in service.characteristics:
print(f" Characteristic: {characteristic.uuid} (Properties: {characteristic.properties})")
async def query_vlf_bt(device_address, write_uuid, read_uuid):
async with BleakClient(device_address) as client:
data_dict = {}
#Queries all ports
for x in range(0,32):
command = f'P{x+1:02d}'
await client.write_gatt_char(write_uuid, command.encode())
# Reads the data from the Controller
response = await client.read_gatt_char(read_uuid)
data = response.decode("utf-8").strip()
data_dict[command] = data
print(f"Response from {command}: {data}")
return data_dict
async def all_combined():
await scan_devices()
device_address = "34:85:18:8D:DB:A1"
await uuid_info(device_address)
write_uuid = "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
read_uuid = "beb5483e-36e1-4688-b7f5-ea07361b26a8"
await query_vlf_bt(device_address, write_uuid, read_uuid)
asyncio.run(all_combined())
Editor is loading...
Leave a Comment