Hi, Thanks, I didn't think of starting a Timer during an iphb wake-up. It still gets a bit difficult though having to juggle both Insomniac and a Timer at the same time, especially as I need to chain a bunch of timers, some with intervals as short as five seconds, and I need to make sure that they're all triggered at the right time reliably. Some abstraction should take away most of the pain though.
While testing I did have some trouble with the timer not triggering reliably though, possible due to Insomniac triggering a bit late (since as you said, libiphb isn't guaranteed to be accurate), or perhaps due to the device entering suspend too early. My test works roughly like so: 1. Set timer & insomniac to repeat: false 2. Set triggerTime to ~5 s from now (Math.round((Date.now() + 5000) / 1000)) 3. Set insomniac.interval to run three seconds earlier (triggerTime - 3), with timerWindow set to 2 -- which, unless I'm sorely mistaken on what iphb_wait's mintime and maxtime actually do, should tell Insomniac to trigger sometime between 1 and 3 seconds from now. 5. Start insomniac 4. When insomniac triggers, set timer.interval to triggerTime*1000 - Date.now() 5. Start timer 6. When timer triggers, go to 2 I'm thinking about trying my luck with nemo-keepalive's KeepAlive, and setting its enabled property to true when insomniac triggers to guarantee that timer also triggers. I'm also considering not using Insomniac at all whenever the next timer has an interval of less than 10 seconds or so, and instead just having KeepAlive.enabled set to true for the whole duration of the interval. Or is disabling suspend for 10 seconds a bit too long for the Powers That Be to be pleased? Regards, Arvid On Thursday 13 March 2014 21:33:53 Thomas Tanghus wrote: > On Thursday 13 March 2014 20:45 Arvid Fahlström Myrman wrote: > > Hi, > > > > Does anyone know if it is possible to schedule code for execution at x > > seconds since epoch, with guaranteed execution even when in sleep mode? > > Currently I am using libiphb (through tanghus's Insomniac QML plugin), but > > libiphb only seems to support waiting for a specified number of seconds, > > meaning that if iphb_wait is called when the time is 1394730709733 > > milliseconds since epoch and is instructed to wait for 5 seconds, the code > > will be executed sometime around 1394730714733 milliseconds since epoch. I > > want to be able to schedule code to be run at e.g. 1394730715000 (±50 ms > > or > > some such small margin), i.e. whole seconds since epoch, no matter the > > current time. That way for example WallClock from org.nemomobile.time > > would > > be in sync with my timer, and I could accurately reflect the remaining > > time > > in the GUI by updating on onTimeChanged without having to update the GUI > > unnecessarily often, in addition to other simplifications I would be able > > to make. > > > > Using the standard QtQuick Timer type would work, since it supports > > specifying the interval in milliseconds, so you could do something like > > timer.interval = 1394730715000 - Date.now(), however Timer doesn't work > > when in sleep mode. > > As libiphb is not guaranteed to be accurate, I set the Insomniac to wake up > a few seconds before I need the alarm to trigger, then start a Timer. You > could do the same: Wake up, check time and start a normal Timer. > Or am I missing something? _______________________________________________ SailfishOS.org Devel mailing list