work on ui

This commit is contained in:
2026-03-07 14:22:06 +11:00
parent 3aed2e5412
commit fe410f6444
7 changed files with 103 additions and 7 deletions

View File

@@ -1,18 +1,21 @@
from enum import Enum
from bleak import BLEDevice, BleakScanner
from bleak import BLEDevice, BleakScanner, BleakClient
NODE_BLUETOOTH_SERVICE_UUID = "E1898FF7-5063-4441-a6eb-526073B00001"
class MeshNode:
def __init__(self, ble_device: BLEDevice):
self.ble_device = ble_device
def __init__(self, client: BleakClient):
self.client = client
async def discover():
"""Find a mesh node via Bluetooth
"""
devices = await BleakScanner(service_uuids=[NODE_BLUETOOTH_SERVICE_UUID], scanning_mode="pasive")
devices = await BleakScanner.discover(service_uuids=[NODE_BLUETOOTH_SERVICE_UUID], timeout=5)
# no device was found
if len(devices) == 0:
return None
return None
device = await BleakScanner.find_device_by_address(devices[0].address, timeout=5)
return MeshNode(BleakClient(device))