Skip to content

Commit

Permalink
Merge pull request #603 from google/gbg/fix-pair-oob
Browse files Browse the repository at this point in the history
fix oob support in pair.py
  • Loading branch information
barbibulle authored Dec 1, 2024
2 parents 0a12b2b + b9f91f6 commit 37c7f3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
21 changes: 13 additions & 8 deletions apps/pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,24 +373,29 @@ async def pair(
shared_data = (
None
if oob == '-'
else OobData.from_ad(AdvertisingData.from_bytes(bytes.fromhex(oob)))
else OobData.from_ad(
AdvertisingData.from_bytes(bytes.fromhex(oob))
).shared_data
)
legacy_context = OobLegacyContext()
oob_contexts = PairingConfig.OobConfig(
our_context=our_oob_context,
peer_data=shared_data,
legacy_context=legacy_context,
)
oob_data = OobData(
address=device.random_address,
shared_data=shared_data,
legacy_context=legacy_context,
)
print(color('@@@-----------------------------------', 'yellow'))
print(color('@@@ OOB Data:', 'yellow'))
print(color(f'@@@ {our_oob_context.share()}', 'yellow'))
if shared_data is None:
oob_data = OobData(
address=device.random_address, shared_data=our_oob_context.share()
)
print(
color(
f'@@@ SHARE: {bytes(oob_data.to_ad()).hex()}',
'yellow',
)
)
print(color(f'@@@ TK={legacy_context.tk.hex()}', 'yellow'))
print(color(f'@@@ HEX: ({bytes(oob_data.to_ad()).hex()})', 'yellow'))
print(color('@@@-----------------------------------', 'yellow'))
else:
oob_contexts = None
Expand Down
1 change: 1 addition & 0 deletions bumble/att.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
# pylint: disable=line-too-long

ATT_CID = 0x04
ATT_PSM = 0x001F

ATT_ERROR_RESPONSE = 0x01
ATT_EXCHANGE_MTU_REQUEST = 0x02
Expand Down

0 comments on commit 37c7f3a

Please sign in to comment.