Skip to content

Commit

Permalink
Merge pull request #199 from benquike/main
Browse files Browse the repository at this point in the history
Add support for legacy pairing over bt classic
  • Loading branch information
barbibulle authored Jun 12, 2023
2 parents 78581cc + 4d2e821 commit 50d1884
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions apps/pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,26 @@ async def display_number(self, number, digits):
self.print(f'### PIN: {number:0{digits}}')
self.print('###-----------------------------------')

async def get_string(self, max_length: int):
await self.update_peer_name()

# Prompt a PIN (for legacy pairing in classic)
self.print('###-----------------------------------')
self.print(f'### Pairing with {self.peer_name}')
self.print('###-----------------------------------')
count = 0
while True:
response = await self.prompt('>>> Enter PIN (1-6 chars):')
if len(response) == 0:
count += 1
if count > 3:
self.print('too many tries, stopping the pairing')
return None

self.print('no PIN was entered, try again')
continue
return response


# -----------------------------------------------------------------------------
async def get_peer_name(peer, mode):
Expand Down

0 comments on commit 50d1884

Please sign in to comment.