mirror of
https://github.com/esphome/esphome.git
synced 2025-10-27 05:03:48 +00:00
[nrf52] support BLE --device for logging (#9861)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
@@ -277,3 +278,19 @@ def upload_program(config: ConfigType, args, host: str) -> bool:
|
||||
raise EsphomeError(f"Upload failed with result: {result}")
|
||||
|
||||
return handled
|
||||
|
||||
|
||||
def show_logs(config: ConfigType, args, devices: list[str]) -> bool:
|
||||
address = devices[0]
|
||||
from .ble_logger import is_mac_address, logger_connect, logger_scan
|
||||
|
||||
if devices[0] == "BLE":
|
||||
ble_device = asyncio.run(logger_scan(CORE.config["esphome"]["name"]))
|
||||
if ble_device:
|
||||
address = ble_device.address
|
||||
else:
|
||||
return True
|
||||
if is_mac_address(address):
|
||||
asyncio.run(logger_connect(address))
|
||||
return True
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user