hap-java / HAP-Java

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

Lost callback after closing app. #4

Closed oberlon closed 8 years ago

oberlon commented 8 years ago

When I start HAP-Java and changed a value with my phone the HomekitCharacteristicChangeCallback is called. After restarting the iPhone app (Eve) the Callback method is not called again.

andylintner commented 8 years ago

I'll have to play with the demo implementation to see what should happen. My assumption was the subscription ends when the session does. The clients I've tried all re -subscribe if they need the realtime update.

andylintner commented 8 years ago

I've confirmed in a few clients, including the Eve client you referenced in your other issue. All of them appear to re-subscribe, which creates a new callback. Do you have any more details on your expected behavior?

Speedtriple86 commented 8 years ago

Hello, I have the following problem. After a few minutes the Siri commands no longer arrive.

Then helps only the server in iPhone to delete and re-create .

Mac , salt , private key and the iPhone user are stored in a file and are static.

Many Thanks for your help.

oberlon commented 8 years ago

Sry for late response. I wrote a minimal Server for testing. Only one switch and a Callback:

public void changed() {
    System.out.println("!!!!Callback!!!!");
}

If I close Eve(double press home and swipe up) and start again I cant see this output. Any ideas?

oberlon commented 8 years ago

19:56:09.153 [defaultEventExecutorGroup-4-1] INFO hapserver.hap.MySwitch - subscribeCallback: hapserver.hap.MyCallback@2364f116

restarting Eve:

19:56:26.390 [defaultEventExecutorGroup-4-1] INFO hapserver.hap.MySwitch - subscribeCallback: com.beowulfe.hap.impl.connections.SubscriptionManager$$Lambda$27/100028605@723a8940

Speedtriple86 commented 8 years ago

Hi,

The problem arises only after a few minutes. I also have the Standy the Mac disabled and also the APP Nap disabled . The HomeKit server responds to any command more . But if I remove the server from the iPhone ( HomeKit configuration ) then he gets this event - ( Remove User ).

After a few minutes when i would send a command then said Siri - sorry i don't´ could do this.

Many thanks for your help!

Server: InetAddress localAddress = InetAddress.getByName("192.168.5.111"); HomekitServer homekit = new HomekitServer(InetAddress.getLocalHost(), PORT); HomekitRoot bridge = homekit.createBridge(new MockAuthInfo(), "Test Bridge", "TestBridge, Inc.", "G6", "111abe234"); bridge.addAccessory(new MockSwitch()); bridge.start();

//MockAuthInfo mac, salt and private key are static mac = "ca:67:e3:b4:xx:xx"; salt = new BigInteger("55134030696782774808658991270789595512"); byte[] strs = {-112, -44, 112, -23, -3, 72, 86, 90, 53, -69, 96, -82, -125, 71, -107, -84, 45, 26, -44, 124, 79, 68, -108, -92, 63, -48, -6, 62, 3, -22, 83, -47}; pivateKey=new byte[strs.length]; for (int i=0; i<strs.length; i++) { privateKey[i]=strs[i]; }

The iphone user are aded on Server start in MockAuthInfo , also static too. byte[] publickey = {-35, 45, -64, 48, -63, -22, -20, 92, 73, -93, 39, 127, 56, 114, 40, 46, -24, 11, 82, 118, -50, -123, 80, 110, 111, 9, -68, 44, -4, -12, 22, -11}; String Username = "ca:67:e3:b4:xx:xx53D14168-390F-4524-9242-12A72CFXXXX"; createUser(Username , publickey);

Many Thanks for your help!

andylintner commented 8 years ago

@Speedtriple86 - your issue looks unrelated to the one @oberlon is reporting. Can you open a separate issue for it? Please enable info logging for the library and include the logs.

andylintner commented 8 years ago

@oberlon - the docs could be clearer on this - but the subscription is for the client. When the homekit client wants to be aware of any changes in the device, it creates a subscription. When it stops being interested, it closes the subscription.

If you want to be aware of changes on the server end, you do that in your HomekitAccessory implementation.

andylintner commented 8 years ago

@oberlon - did that resolve your issue?

andylintner commented 8 years ago

Closing this - no response.