arduino-lmic
arduino-lmic copied to clipboard
Added method to retrieve time to next time critical job
In the context of the discussion here https://github.com/mcci-catena/arduino-lmic/discussions/640 I thought it's useful to get the time to the next critical job to help determine idle/sleep time on the node without having to guess using os_queryTimeCriticalJobs()
Awesome idea!
I think it would make sense to also query OS.runnablejobs
, making the function look like this:
ostime_t os_timeToNextTimeCriticalJob() {
if(OS.runnablejobs) return 0;
if (!OS.scheduledjobs) return 0x7FFFFFFFl; //ostime_t_max;
return OS.scheduledjobs->deadline - os_getTime();
}
See the OS loop function, it checks OS.runnablejobs
as well: https://github.com/mcci-catena/arduino-lmic/blob/master/src/lmic/oslmic.c#L146-L154