|
|
@@ -20,7 +20,7 @@ calibration_params = bme280.load_calibration_params(bus, address)
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
|
-outdoorName = os.getenv("BLE_PERIPHERAL_NAME")
|
|
|
+outdoorMac = os.getenv("BLE_PERIPHERAL_MAC")
|
|
|
outdoorConnected = 0
|
|
|
|
|
|
TEMP_UUID = "2A6E"
|
|
|
@@ -47,21 +47,10 @@ async def ble_task():
|
|
|
global outdoorConnected
|
|
|
|
|
|
while True:
|
|
|
- device = await BleakScanner.find_device_by_name(outdoorName)
|
|
|
-
|
|
|
- if device is None:
|
|
|
- outdoorConnected = 0
|
|
|
-
|
|
|
- print("no device found, wait then scan again")
|
|
|
- await asyncio.sleep(10)
|
|
|
- continue
|
|
|
-
|
|
|
- await asyncio.sleep(2)
|
|
|
-
|
|
|
try:
|
|
|
- async with BleakClient(device) as client:
|
|
|
+ async with BleakClient(outdoorMac) as client:
|
|
|
outdoorConnected = 1
|
|
|
- print(f"connected to {outdoorName}")
|
|
|
+ print(f"connected")
|
|
|
|
|
|
await client.start_notify(TEMP_UUID, notification_handler)
|
|
|
await asyncio.sleep(0.5)
|