mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-15 06:45:59 +00:00
chore(python): update ble to session-based
This commit is contained in:
parent
e4088ad90e
commit
648cf93c0a
@ -1,19 +1,17 @@
|
||||
import typing as t
|
||||
|
||||
from . import messages
|
||||
from .tools import session
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
from ..client import TrezorClient
|
||||
from .transport.session import Session
|
||||
|
||||
|
||||
@session
|
||||
def unpair(
|
||||
client: "TrezorClient",
|
||||
session: "Session",
|
||||
all: bool,
|
||||
):
|
||||
|
||||
resp = client.call(messages.BleUnpair(all=all))
|
||||
resp = session.call(messages.BleUnpair(all=all))
|
||||
|
||||
if isinstance(resp, messages.Success):
|
||||
return
|
||||
|
@ -20,10 +20,10 @@ from typing import TYPE_CHECKING
|
||||
import click
|
||||
|
||||
from .. import ble, exceptions
|
||||
from . import with_client
|
||||
from . import with_session
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client import TrezorClient
|
||||
from ..transport.session import Session
|
||||
|
||||
|
||||
@click.group(name="ble")
|
||||
@ -38,15 +38,15 @@ def cli() -> None:
|
||||
help="Erase all bonds.",
|
||||
is_flag=True,
|
||||
)
|
||||
@with_client
|
||||
@with_session(seedless=True)
|
||||
def unpair(
|
||||
client: "TrezorClient",
|
||||
session: "Session",
|
||||
all: bool,
|
||||
) -> None:
|
||||
"""Erase bond of currently connected device, or all devices (on device side)"""
|
||||
|
||||
try:
|
||||
ble.unpair(client, all)
|
||||
ble.unpair(session, all)
|
||||
click.echo("Unpair successful.")
|
||||
except exceptions.Cancelled:
|
||||
click.echo("Unpair cancelled on device.")
|
||||
|
Loading…
Reference in New Issue
Block a user