hap-java / HAP-Java

Java implementation of the HomeKit Accessory Protocol
MIT License
153 stars 82 forks source link

#93 Fix discoverability & pairing with ios13 #95

Closed yfre closed 4 years ago

yfre commented 4 years ago

ios13 evaluate sdiscoverability (sf flag) differently than older ios and stop pairing process if this flag changes (see issue #93). this PR fix it by keeping discoverability true

ccutrer commented 4 years ago

so does discoverable never get set to false now?

yfre commented 4 years ago

so does discoverable never get set to false now? yes, it get to false only after restart. i have not found any good place to make it to false.

if we do it before response ("return response"), ios stop the pairing. after "return response" java hap not active anymore.

probably we need to attach to event like "response" delivered and connection is closed. not sure though how to catch this even.. maybe "channelInactive".

jan4roth commented 4 years ago

@ccutrer Can you please accept this fix, or instead fix it otherwise? No one can discover the openhab bridge anymore... this is very annoying...

J-N-K commented 4 years ago

Openhab uses a customized build which includes this fix.

sobeos commented 4 years ago

I'm facing pairing problems with ios13 as well. And I can confirm that the pull request is fixing the problem. At least in my environment. So why is the pull request not merged to master? Currently pairing is not possible at all. The fix is really fundamental.

andylintner commented 4 years ago

@ccutrer - any objection to me merging this?

ccutrer commented 4 years ago

I have no objections. @yfre added two new commits since my last comment that should turn off discoverability (hopefully properly), and I was just waiting for more confirmation that that worked.

scothi commented 4 years ago

It is working, but only partially. Now the bridge does appear in the Home app every time, but after I enter the pairing code it’s just loading and after a little while it throws back a message that it cannot be added. Is this a new issue or is it related to this same issue?

sobeos commented 4 years ago

@scothi: Are you sure, it is the same problem? Does your code/setup work with older ios versions? What is the output of the device?

scothi commented 4 years ago

Unfortunatelly I cannot test with an older ios version, I don’t have another device. I’m trying with 13.3 ios and the sample project (https://github.com/hap-java/HAP-Java/tree/sample).

obartelt commented 4 years ago

Same problem here, iOS 13.3.1. After third pairing phase, createUser is called and then it fails. It seems the the accessories request is received before the service gets recreated, is that good? I would imageine it's not... Isn't there maybe a way to update the service instead of re-creating it? Or re-create it immediately after sending the response to the third pairing phase (and not when receiving the next request)?

yfre commented 4 years ago

you should see on the log when the accessories request is received and what is the response to it.

obartelt commented 4 years ago

Yes, I do. And it looks ok (at least the same as in the log someone posted in the issue). It just doesn't work. As I wrote in the issue, if I remove the MockSwitch light bulb and just advertise the bridge, I can add it successfully. Any idea what might be causing that?