Skip to content

Commit

Permalink
Fix 194 broken ble pairing (#196)
Browse files Browse the repository at this point in the history
* Force minimum version for tlv8 library

Fix #194 via an
updated version of the tlv8 lib.
  • Loading branch information
jlusiardi committed May 14, 2020
1 parent 31175b9 commit d9bddae
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions homekit/controller/ble_impl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,17 @@ def write(request, expected):
tlv8.Entry(AdditionalParameterTypes.Value, body)
])
transaction_id = random.randrange(0, 255)
# construct a hap characteristic write request following chapter 7.3.4.4 page 94 spec R2
data = bytearray([0x00, HapBleOpCodes.CHAR_WRITE, transaction_id])
data.extend(characteristic_id.to_bytes(length=2, byteorder='little'))
data.extend(len(request_tlv).to_bytes(length=2, byteorder='little'))
data.extend(request_tlv)
logger.debug('sent %s', bytes(data).hex())

# write the request to the characteristic
characteristic.write_value(value=data)

# reading hap characteristic write response following chapter 7.3.4.5 page 95 spec R2
data = []
while len(data) == 0:
time.sleep(1)
Expand Down
3 changes: 1 addition & 2 deletions homekit/prepare_add_remote_pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ def setup_args_parser():

text = 'Please add this to homekit.add_additional_pairing:\n' \
' -i {id} -k {pk}' \
.format(a=args.alias,
id=additional_controller_pairing_identifier,
.format(id=additional_controller_pairing_identifier,
pk=public_key
)
print(text)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ PyGObject
gatt
cryptography>=2.5
coverage
flake8
flake8>=0.9.0
pytest
tlv8
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'hkdf',
'ed25519',
'cryptography>=2.5',
'tlv8',
'tlv8>=0.9.0',
],
extras_require={
'IP': ['zeroconf'],
Expand Down

0 comments on commit d9bddae

Please sign in to comment.