Mixiaoxiao / Arduino-HomeKit-ESP8266

Native Apple HomeKit accessory implementation for the ESP8266 Arduino core.
MIT License
1.48k stars 278 forks source link

Storage alignment issues aka. "max number of pairings" #231

Open cfurter opened 11 months ago

cfurter commented 11 months ago

I've taken the work of @thiti-y and @paullj1 and added my own fixes to the storage issues.

TLDR; the alignment issues and read write protection of the ESP flash issues are now resolved.

With ESP8266 flash, you can only write data in 4 byte alignments to addresses that have been erased. Once you've written data to an address, you cannot write to the address again until the sector is erased. I've corrected the logic in storage.c based on this and all seems to work well now.

I am now able to added and remove pairing without the "max number of pairings" issues. You may need to do a homekit_storage_reset() or erase the "EEPROM" sector before it will work well.

I have also added a bunch of changes to remove Platform.io warnings.