I started to get some ERA errors like this:
Error Name: Invalid Value Devices: Venu® Sq: 5.10 Forerunner® 965: 21.22 Backtrace: MyView.compute:303
As far as I understand from the docs ActivityInfo.currentLocationAccuracy is supposed to be Position.Quality or Null, meaning only values: Null, 0,1,2,3,4 will ever be there. How come the below code produces Invalid Value error?
The relevant code is:
class MyView {
var gpsAccuracy as Number or Position.Quality = 0;
var gpsAccuracyField as Field?;
initialize() {
if (isGpsEnabledByUser) {
gpsAccuracyField = session.createField("gpsAccuracy", 8, Fit.DATA_TYPE_UINT8, { :mesgType => Fit.MESG_TYPE_RECORD, :units => "" });
}
}
function compute(info as Activity.Info) as Void {
var gpsAccuracy = ifNullThenZero(info.currentLocationAccuracy) as Number;
if (gpsAccuracy != self.gpsAccuracy) {
self.gpsAccuracy = gpsAccuracy;
if (gpsAccuracyField != null) {
gpsAccuracyField.setData(gpsAccuracy); // line 303
}
}
}
function onTimer() as Void {
var info = Activity.getActivityInfo();
if (info != null) {
compute(info as Activity.Info);
}
}
function ifNullThenZero(val as Number or Float or Null) as Number or Float {
return val != null ? val : 0;
}
}