소스 검색

getdtaa test

marek 1 개월 전
부모
커밋
ed73e62743
1개의 변경된 파일1개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 5
      apps/getData.py

+ 1 - 5
apps/getData.py

@@ -48,8 +48,6 @@ async def ble_task():
     global outdoorConnected
 
     while True:
-        disconnect_event = asyncio.Event()
-
         device = await BleakScanner.find_device_by_name(outdoorName)
 
         if device is None:
@@ -60,7 +58,7 @@ async def ble_task():
             continue
 
         try:
-            async with BleakClient(device, disconnected_callback=lambda c: disconnect_event.set()) as client:
+            async with BleakClient(device) as client:
                 outdoorConnected = 1
                 print(f"connected to {outdoorName}")
 
@@ -68,8 +66,6 @@ async def ble_task():
                 await client.start_notify(PRESSURE_UUID, notification_handler)
                 await client.start_notify(HUMIDITY_UUID, notification_handler)
                 await client.start_notify(ALTITUDE_UUID, notification_handler)
-
-                await disconnect_event.wait()
         except Exception:
             outdoorConnected = 0
             print("exception while connecting or getting data")