Closed jonasborneland closed 4 years ago
There is a mistake in "void init_hap_storage" and "storage_changed", use this ones:
void init_hap_storage(){ //Not touch!
Serial.print("init_hap_storage");
File fsDAT=SPIFFS.open(pair_file_name, "r");
if(!fsDAT){
Serial.println("Failed to read pair.dat");
return;
}
int size = hap_get_storage_size_ex();
char* buf=new char[size];
memset(buf,0xff,size);
int readed=fsDAT.readBytes(buf,size);
Serial.print("Readed bytes ->");
Serial.println(readed);
hap_init_storage_ex(buf,size);
fsDAT.close();
delete []buf;
}
void storage_changed(char * szstorage,int size){ //Not touch!
SPIFFS.remove(pair_file_name);
File fsDAT=SPIFFS.open(pair_file_name, "w+");
if(!fsDAT){
Serial.println("Failed to open pair.dat");
return;
}
fsDAT.write((uint8_t*)szstorage,size);
fsDAT.close();
}
@oxbown Thanks! I'll try it
@oxbown Works perfect! Thanks! @Yurik72 Will you update the example and close this issue? 🙌
Updated, thanks for found that
Every time I reboot I have to re-add a new led? And the old parring is still there, just with a "offline" text.
Here is my log after rebooting the NodeMCU Board: