Apollon77 / hap-controller-node

Node.js library to implement a HAP (HomeKit) controller
Mozilla Public License 2.0
55 stars 15 forks source link

Pairing issue "Empty TLV" #140

Closed minamoanes closed 2 years ago

minamoanes commented 2 years ago

Describe the bug
Every time I try paring a device, I get the following error:

/homebridge/node_modules/homebridge-homekit-control/node_modules/hap-controller/lib/protocol/pairing-protocol.js:272
            throw new Error('M4: Empty TLV');
                  ^

Error: M4: Empty TLV
    at PairingProtocol.parsePairSetupM4 (/homebridge/node_modules/homebridge-homekit-control/node_modules/hap-controller/lib/protocol/pairing-protocol.js:272:19)
    at HttpClient.finishPairing (/homebridge/node_modules/homebridge-homekit-control/node_modules/hap-controller/lib/transport/ip/http-client.js:128:36)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async HttpClient.pairSetup (/homebridge/node_modules/homebridge-homekit-control/node_modules/hap-controller/lib/transport/ip/http-client.js:150:9)
    at async /homebridge/node_modules/homebridge-homekit-control/cli.js:134:17

To Reproduce
I'm using this Homebridge Plugin: homebridge-homekit-control Which uses hap-controller-node to get the device information as a JSON, When I try getting the device information for some specific devices, I get the error above, while others work totally fine...

Expected behavior
Get the device Pairing information JSON

Additional context
#32

Any one has an idea what should I do? as you might notice, I forked the repo, and updated to the latest hap-controller-node in an attempt to fix it, but it didn't work out.

Apollon77 commented 2 years ago

How your code looks like? Like in the examples? So do you get the pairMethod and use that when calling the pairing? If not please add that.

Additionally please tell which device types (manufactorer and such) it happens.

Additionally please follow the infos in readme to get an enhanced log and post it here. Thank you

Apollon77 commented 2 years ago

Ok, I looked at your code and you do not get teh pairmethod and use it ... https://github.com/minamoanes/homebridge-homekit-control/blob/master/cli.js#L134

Please adjust it to be like https://github.com/Apollon77/hap-controller-node/blob/main/examples/ip/pair-setup.js#L12-L15

minamoanes commented 2 years ago

Worked like charm! Thanks a lot @Apollon77, I appreciate it!

Fixed here: https://github.com/minamoanes/homebridge-homekit-control/releases/tag/0.1.21

Apollon77 commented 2 years ago

Glad to help