From 4d2e821e503bb8714dc78d6df4036523895dd961 Mon Sep 17 00:00:00 2001 From: Hui Peng Date: Wed, 7 Jun 2023 09:53:34 -0700 Subject: [PATCH] Add support for legacy pairing over bt classic --- apps/pair.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/pair.py b/apps/pair.py index 162442a9..2cc8188c 100644 --- a/apps/pair.py +++ b/apps/pair.py @@ -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):