diff --git a/src/lmic/oslmic.c b/src/lmic/oslmic.c index fa205f44..69520bd2 100644 --- a/src/lmic/oslmic.c +++ b/src/lmic/oslmic.c @@ -167,3 +167,10 @@ bit_t os_queryTimeCriticalJobs(ostime_t time) { else return 0; } + +ostime_t os_timeToNextTimeCriticalJob() { + if (OS.runnablejobs) return 0; + + if (!OS.scheduledjobs) return 0x7FFFFFFFl;//ostime_t_max; + return OS.scheduledjobs->deadline - os_getTime(); +} diff --git a/src/lmic/oslmic.h b/src/lmic/oslmic.h index 0aa49168..6be402ec 100644 --- a/src/lmic/oslmic.h +++ b/src/lmic/oslmic.h @@ -216,6 +216,10 @@ u1_t os_getBattLevel (void); //! Return non-zero if any jobs are scheduled between now and now+time. bit_t os_queryTimeCriticalJobs(ostime_t time); #endif +#ifndef os_timeToNextTimeCriticalJob +// return the time to the next scheduled job, or ostime_t_max if no job is scheduled +ostime_t os_timeToNextTimeCriticalJob(); +#endif #ifndef os_rlsbf4 //! Read 32-bit quantity from given pointer in little endian byte order.