Open bfaliszek opened 4 years ago
Same issue here - i get it somehow into reset by a combination of buttons and opening homekit app on idevice. But now with the multiple sensor i fisrt deleted it in home app and couldn't pair after some mods in .ino :( a little scratch how to use this homekit_storage_reset() as reset will be great for those who not so deep digged in coding as myself ;)
I have the same issue.
My solution to this problem is to delete homekit_pair.dat from spiffs instead of use homekit_storage_reset().
SPIFFS.remove(/homekit_pair.dat);
My solution to this problem is to delete homekit_pair.dat from spiffs instead of use homekit_storage_reset().
SPIFFS.remove(/homekit_pair.dat);
@bfaliszek, can you please share your code with us: I have trouble with the SPIFFS library...
@Layochi
SPIFFS.remove(/homekit_pair.dat);
That's all my code. You can use an example and add the above line to it. This code deletes the keys of the device with which the ESP is connected. This puts the ESP back into pairing mode.
@bfaliszek Sadly, I got an error :
SPIFFS_Test:11:17: error: expected primary-expression before '/' token SPIFFS_Test:11:18: error: 'homekit_pair' was not declared in this scope exit status 1 expected primary-expression before '/' token
With this code :
#include "FS.h"
#include "SPIFFS.h"
void setup() {
Serial.begin(115200);
if (!SPIFFS.begin()) {
Serial.println("SPIFFS Mount Failed");
return;
}
SPIFFS.remove(/homekit_pair.dat);
Serial.println( "Test complete" );
}
void loop() {
}
I also get this error.
Can somebody help me?
Hi, not sure what causes the crash. IMHO you can work around if you go into storage.c (...\documents\Arduino\libraries\HomeKit-ESP8266\src\storage.c) and change parameter ACCESSORY_ID_OFFSET (was 4 on my side). After changing it will be recognised as a new device.
Can somebody help me?
I figured out that the issue was the missing of "
between the parentheses. So the code should be SPIFFS.remove("/homekit_pair.dat");
but it's not working, I still cannot detect my device...
change parameter ACCESSORY_ID_OFFSET (was 4 on my side). After changing it will be recognised as a new device.
I also tried to change ACCESSORY_ID_OFFSET
from 4 to 5 or 3 but it's not working either... @Surleika what's the value that you set for ACCESSORY_ID_OFFSET
?
@C-r-e-d-o and @Surleika Did you find a solution ?
So, I finally find two solutions.
Use esptool to erase the flash memory of your ESP (need usb cable to connect the ESP to the computer)
You have to change the ACCESSORY_ID_OFFSET
to another value like 5
. Try to reconnect to your device in Home. If you can, that's perfect, but for me, it was not working. If it's your case, change the ACCESSORY_ID_OFFSET
back to 4
and it should now be working (works with OTA).
I worked arround as you did by changing from 4 to 5, flash, change back from 5 to 4 again. Since then it worked stable.
@Layochi: any chance to see your OTA implementation via PM?
Glad it works for you too! It's sad that this library is not updated anymore...
Here is my implementation :
OTA to handle uploading of new sketches (Library : ArduinoOTA.h
)
Telnet to handle remote debugging with debug()
and debugln()
functions (Library : TelnetStream.h
)
#include <ArduinoOTA.h>
#include <TelnetStream.h>
const char* hostName = "Name that is visible in arduino IDE";
void setupOTA() {
ArduinoOTA.setHostname(hostName);
ArduinoOTA.begin();
ArduinoOTA.onStart([]() {
//NOTE: make .detach() here for all functions called by Ticker.h library - not to interrupt transfer process in any way.
String type;
if (ArduinoOTA.getCommand() == U_FLASH)
type = "sketch";
else // U_SPIFFS
type = "filesystem";
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Start updating " + type);
});
ArduinoOTA.onEnd([]() {
Serial.println("\nEnd");
ESP.restart();
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("\nAuth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("\nBegin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("\nConnect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("\nReceive Failed");
else if (error == OTA_END_ERROR) Serial.println("\nEnd Failed");
});
Serial.println("OTA Initialized!");
Serial.println("Starting Telnet Communication...");
TelnetStream.begin();
Serial.println("Telnet Initialized!");
Serial.println("You can open a new terminal and write the command:\n$ telnet " + WiFi.localIP().toString());
}
void debug(const char* string) {
Serial.print(string);
TelnetStream.print(String(string));
}
void debugln(const char* string) {
Serial.println(string);
TelnetStream.println(String(string));
}
void handleOTA() {
ArduinoOTA.handle();
switch (TelnetStream.read()) {
case 'C':
TelnetStream.println("\nClosing the Telnet Communication...");
TelnetStream.flush();
TelnetStream.stop();
break;
case 'R':
debugln("\nRebooting...");
ESP.restart();
break;
}
}
I added "homekit_storage_reset ()" right before "Init Button" in the example. ESP32 started rebooting constantly because of this. When I delete "homekit_storage_reset ()", the device works but still remembers the old keys.
I added "homekit_storage_reset ()" because I wanted to delete the saved keys from the previous iPhone.