ewilken / hap-rs

Rust implementation of the Apple HomeKit Accessory Protocol (HAP)
Apache License 2.0
196 stars 33 forks source link

Multiple instances with same service #72

Open soundprojects opened 2 years ago

soundprojects commented 2 years ago

When trying to run the same code on two different clients, they both fight over the same name Shouldn't hap-rs rename the service to 'service (1)' and so on?

And should this also mean that the c# number should be incremented when adding the second service? Now they have the same id's?

ewilken commented 2 years ago

When trying to run the same code on two different clients, they both fight over the same name Shouldn't hap-rs rename the service to 'service (1)' and so on?

You mean running the program with the exact same parameters on different network clients at the same time? Good question, I don't know what the expected name collision behavior for mDNS clients is there. Do you? And is this a use case?

And should this also mean that the c# number should be incremented when adding the second service? Now they have the same id's?

Interesting. The HAP specification says

Must update when an accessory, service, or characteristic is added or removed on the accessory server.

about it. We're updating the number on accessory additions and removals. Since we don't have methods for dynamic addition and removal of services to accessories or characteristics to services, I'd say as of right now it's up to the crate user to bump the number whenever they change services or characteristics.

soundprojects commented 2 years ago

I read into this with the (great) Oreilly book on zeroconf networking and the renaming behavior 'service (1)' should happen but when running two clients with the exact same configuration this doesn't happen. The second service simply replaces the DNS records. I think this is incorrect behavior.

I ran into this also because in the examples of your crate, you pass an example Mac Adress as the ID. This causes identical ID's to be generated when running the same code in different clients in the network. (My dev mac and the raspberry production device)