Bouke / HAP

Swift implementation of the Homekit Accessory Protocol
https://boukehaarsma.nl/HAP/
MIT License
366 stars 50 forks source link

Persist Serial numbers #89

Closed gbrooker closed 5 years ago

gbrooker commented 5 years ago

When removing accessories from a Bridge, the current implementation also removes the serial number to AID mapping. If the accessory is added back, a new AID is generated, which is not in line with the HAP spec.

This PR adds an optional parameter andForgetSerialNumbers: to Device.removeAccessories() to persist the serial number to AID mapping after removing accessories.

A default value is provided to ensure any existing code operates as before. However I would suggest it may be better to make persistence the default, and only remove the serial number mapping if specifically requested to do so. (i.e making the default value true). What do you think ?

A host application can permanently forget all serial number to AID mappings by removing the Storage.

Bouke commented 5 years ago

This would also fix #49 I think?

gbrooker commented 5 years ago

OK, I changed the default behaviour to not remove the mapping of serial number to AID.

It seems that the linux configuration in the Travis builds has an issue with dependancies.

Bouke commented 5 years ago

I’m not sure what’s up with the Linux build. Looks like some dependency is broken. I’ll have a look some other time, as it is unrelated to this PR. Thanks!