Agent code for device being offline longer than expected?

Hi,

Currently I’m using “imp.wakeup(30, waitingloop)” with a counter to determine how long a device has been offline, then react if a device has been offline longer then expected.

I’m wondering if there’s an easier way to trigger an event if a device has been offline for X seconds longer than expected.

More broadly my question could be; is there a way to generate an event in the future without sleeping?

Thanks.

I should add that I’m talking agent code and agent events.

imp.wakeup is the only way, really, but the best way would be to start the timer in the ondisconnect() handler in the agent, and set it to X seconds.

Then, use the handle for the timer to cancel this in the onconnect() handler, so if it reconnects the timer is cancelled and the timeout will not fire.

Yep, that’s what I’m doing, thanks Hugo.