Ticket Created
over 3 years ago

CIQQA-496

Venu SQ error on getOxygenSaturationHistory

Hi, Im using this code to retrieve and use oxygen saturation history, it works on all devices except Venu SQ, why????

if ((Toybox has :SensorHistory) && (Toybox.SensorHistory has :getOxygenSaturationHistory)) {
sample = SensorHistory.getOxygenSaturationHistory({ :period => 1, :order => SensorHistory.ORDER_NEWEST_FIRST })
.next();
if ((sample != null) && (sample.data != null)) {
values[:current] = sample.data.toNumber();

}
}else{
values[:current]="N.A";
}

This is the trace in simulator and the problem is in this line:

sample = SensorHistory.getOxygenSaturationHistory({ :period => 1, :order => SensorHistory.ORDER_NEWEST_FIRST }).next();

Error: Invalid Value
Details: Failed invoking <symbol>
Stack:
- getValuesForType() at G:\tooNew\NewTooSimply\source\NewTooSimplyView.mc:2074 0x10005dd0
- pintarProgresoDato() at G:\tooNew\NewTooSimply\source\NewTooSimplyView.mc:439 0x100023b9
- onUpdate() at G:\tooNew\NewTooSimply\source\NewTooSimplyView.mc:243 0x10001b4f

Thanks.

Parents
  • This is why you want to do the null check - on this and other things.  Things can differ by device and in the sim, and with things like just turning on the device, and in this case if PulseOX is off on the watch.

    Consider this:

    Weather.getCurrentConditions().temperature

    would cause a crash if the watch doesn't have the current weather.  And even if you null check getCurrentConditions(), temperature could be null, so you want to null check that too.

Comment
  • This is why you want to do the null check - on this and other things.  Things can differ by device and in the sim, and with things like just turning on the device, and in this case if PulseOX is off on the watch.

    Consider this:

    Weather.getCurrentConditions().temperature

    would cause a crash if the watch doesn't have the current weather.  And even if you null check getCurrentConditions(), temperature could be null, so you want to null check that too.

Children