Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not exit after pairing is finished #330

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions apps/pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ async def pair(
mitm,
bond,
ctkd,
linger,
io,
oob,
prompt,
Expand Down Expand Up @@ -395,17 +396,20 @@ async def pair(
address_or_name,
transport=BT_LE_TRANSPORT if mode == 'le' else BT_BR_EDR_TRANSPORT,
)
pairing_failure = False

if not request:
try:
if mode == 'le':
await connection.pair()
else:
await connection.authenticate()
return
benquike marked this conversation as resolved.
Show resolved Hide resolved
except ProtocolError as error:
pairing_failure = True
print(color(f'Pairing failed: {error}', 'red'))
return
benquike marked this conversation as resolved.
Show resolved Hide resolved

if not linger or pairing_failure:
return
else:
if mode == 'le':
# Advertise so that peers can find us and connect
Expand Down Expand Up @@ -455,6 +459,7 @@ def emit(self, record):
help='Enable CTKD',
show_default=True,
)
@click.option('--linger', default=True, is_flag=True, help='Linger after pairing')
@click.option(
'--io',
type=click.Choice(
Expand Down Expand Up @@ -490,6 +495,7 @@ def main(
mitm,
bond,
ctkd,
linger,
io,
oob,
prompt,
Expand All @@ -514,6 +520,7 @@ def main(
mitm,
bond,
ctkd,
linger,
io,
oob,
prompt,
Expand Down