System.on(cloud_status_disconnected, cloudEventHandler)

Hey, I just want to double check, I've been getting some occasional cloud disconnects and I want to save them on EEPROM with timestamp when they occur and then retrieve with simple function. Can you check my code for any issues? Thank you

#include "Particle.h"

time_t EEPROM_Value;
const int EEPROM_ADDRESS_cloud_event = 10;
int controlPnl(String command);

SYSTEM_THREAD(ENABLED);

void cloudEventHandler() {
    time_t timestamp = Time.now();
    EEPROM.put(EEPROM_ADDRESS_cloud_event, timestamp);
}

void setup() {
    Particle.connect();
    waitUntil(Particle.connected);
    Particle.function("controlPnl", controlPnl);
    System.on(cloud_status_disconnected, cloudEventHandler);
}

void loop() {

}

int controlPnl(String command) {
    if (command == "check_last_disconnect") {
        EEPROM.get(EEPROM_ADDRESS_cloud_event, EEPROM_Value);
        delay(250);
        Particle.publish("Timestamp", String((long)EEPROM_Value), PRIVATE);
        return 1;
    }
    return -1;
}

That looks correct.

Note that you will always get a cloud disconnect every 3 days because that's the lifetime of the DTLS session encryption key. After the session key expires, the cloud connection is reestablished by reauthenticating, which causes a cloud disconnect and reconnect.