Acknowledged

Invalid value error when calling getBodyBatteryHistory with short duration

Calling Toybox.SensorHistory.getBodyBatteryHistory with short durations results in an app crash with the following error message:

Error: Invalid Value
Details: Failed invoking <symbol>

Short duration means e.g. 30 seconds.

The error can not be caught with a try-catch handler

Code example:

var duration = new Time.Duration(30);
var bodyBattHistory = Toybox.SensorHistory.getBodyBatteryHistory({:period => duration, :order => Toybox.SensorHistory.ORDER_NEWEST_FIRST});

Environment

  • SDK version 7.2.1 on Windows in VS Code
  • Device: Fenix 6 Sapphire, but also happens on other devices, e.g. fenix 7 Pro in simulator
  • Code is used in a watchface

Expected behavior

Instead of crashing I would expect to get a null iterator back or the next() call on the iterator returns null if there is no sample in this time period. Then the error could be handled.

Tried workaround

Tried calling the function without the period parameter to get all data and then filter by myself, but then I get an "out of memory" error from time to time when calling getBodyBatteryHistory.