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 Comment Children
  • That error means you have a local variable that's not used.  You define it and set it but never use it

    var a=3;
    if(some condition) {
        a=5;
    }
    System.println("a="+a);

    In the above, you'll get the warning if you comment out line 5

    in the code you posted, you'll get it on line 171 and 173  as you set variables but then never use them.  It's a warning you can probably ignore when you are testing/debugging