started writing api for desktop app
This commit is contained in:
18
desktop_app/api/node.py
Normal file
18
desktop_app/api/node.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
from enum import Enum
|
||||||
|
from bleak import BLEDevice, BleakScanner
|
||||||
|
|
||||||
|
NODE_BLUETOOTH_SERVICE_UUID = "E1898FF7-5063-4441-a6eb-526073B00001"
|
||||||
|
|
||||||
|
|
||||||
|
class MeshNode:
|
||||||
|
def __init__(self, ble_device: BLEDevice):
|
||||||
|
self.ble_device = ble_device
|
||||||
|
|
||||||
|
async def discover():
|
||||||
|
"""Find a mesh node via Bluetooth
|
||||||
|
"""
|
||||||
|
devices = await BleakScanner(service_uuids=[NODE_BLUETOOTH_SERVICE_UUID], scanning_mode="pasive")
|
||||||
|
|
||||||
|
# no device was found
|
||||||
|
if len(devices) == 0:
|
||||||
|
return None
|
||||||
4
desktop_app/main.py
Normal file
4
desktop_app/main.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
from api.node import MeshNode
|
||||||
|
|
||||||
|
|
||||||
|
print(MeshNode.discover())
|
||||||
2
test.py
2
test.py
@@ -18,6 +18,8 @@ async def main():
|
|||||||
print(f'\tDevice address:{device.address}')
|
print(f'\tDevice address:{device.address}')
|
||||||
print(f'\tDevice name:{device.name}')
|
print(f'\tDevice name:{device.name}')
|
||||||
|
|
||||||
|
client.write_gatt_char()
|
||||||
|
|
||||||
print('\tServices:')
|
print('\tServices:')
|
||||||
for service in client.services:
|
for service in client.services:
|
||||||
print()
|
print()
|
||||||
|
|||||||
Reference in New Issue
Block a user