Acknowledged
over 1 year ago

getStressHistory crashing

Hi, good day to all.
I'm running the code below to get today's stress data:
var clockTime = Time.Gregorian.info(Time.now(), Time.FORMAT_MEDIUM);
var midnight = new Time.Duration(clockTime.hour*3600 + clockTime.min*60 + clockTime.sec);
var stressIterator = SensorHistory.getStressHistory({ :period => midnight, :order => Sen.ORDER_OLDEST_FIRST});
It works fine and give me what I want almost always, however, when it's shortly after midnight (00:00, 00:01, etc) it crashes. The crash is at the third line of the above snippet, it says only:
Error: Invalid Value
Details: Failed invoking <symbol>
Notice that I'm simply requesting stress history and saving the return to a variable. At this point I'm not trying to access a property of "can be null" entity. This happens both in the simulator and physical device (Venu 2). To reproduce this error, I set the computer clock to 00:00:00 and run it.
Thanks in advance.
Parents
  • Sounds like the error is that parameters used to make the call.  For example, you are using the oldest first order, but only a duration of 10 seconds and history is saved far less often than every 10 seconds. If you change that 10 to 1000, does it crash?

    Your crash only happens right after midnight could be similar where the duration is too short.

    The way I'd do this is to use newest first and let the period be everything, and then use "when" in the sample to see when you've gotten what you want.

Comment
  • Sounds like the error is that parameters used to make the call.  For example, you are using the oldest first order, but only a duration of 10 seconds and history is saved far less often than every 10 seconds. If you change that 10 to 1000, does it crash?

    Your crash only happens right after midnight could be similar where the duration is too short.

    The way I'd do this is to use newest first and let the period be everything, and then use "when" in the sample to see when you've gotten what you want.

Children