I am trying to check out the functionality of system events. I tried the example sketch but i do not get any publish on pressing the button or from calling System.reset() from the cloud.
I guess because a publish is a task that's too long for such an event.
The Particle.publish() only queues the event, but the sending will happen (actually not) after the handler will be finished.
Try to blink D7 instead or hang around in the handler for some seconds to get the event published to the cloud.
I did this and tried to run the method by itself. It blinked the LED on for 5 seconds and then off.
void reset_handler() {
unsigned long startMillis = millis();
digitalWrite(D7, HIGH);
while ((millis() - startMillis) < 5000)
{
//HANG IN HERE
}
digitalWrite(D7, LOW);
}
When the system resets after a firmware update the code executes but if i call System.reset() from a particle function nothing happens nor does pressing the reset button do anything.
I’m not sure about System.reset() but for the RESET button I’m not surprised as the code hasn’t got any say in preventing the reset once the µC is going down, which is the inevitable, hard wired effect of pulling the RST pin down.
The behaviour with the System.reset() command might be something for @BDub to clarify.
Actually i wanted the touchscreen to display system is resetting or updating when a call is made to system reset or OTA update is triggered. I am not using system threading. Is that a pre req for using System events?
Ahh, ok that makes sense. If the device wants to reset, you need to delay that so you have time to display your message as per my above example shows. If you want to know you are receiving an update, you can use the system events. Multi-threaded is not required for system events to work.