Under Review
over 1 year ago

WERETECH-13396

Position.enableLocations documentation has a bug in code example (causes device to crash)

(See: https://forums.garmin.com/developer/connect-iq/f/discussion/319709/enable-location-bug-after-24-10-update)

The documentation at the following URL has a bug which causes a crash:

[https://developer.garmin.com/connect-iq/api-docs/Toybox/Position.html#enableLocationEvents-instance_function]

Original code:

if (Position has :CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5) {
    options[:configuration] = :CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5;

Correct code:

if (Position has :CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5) {
    options[:configuration] = Position.CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5;


Parents
  • Yes, the reference to CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5 did need to be prefixed with the Position module. We fixed this a while back along with adding a call to check for hasConfiguration. Unfortunately, on older devices that would still generate a compiler warning/error for the hasConfiguration symbol not being has checked.

    I've updated the snippet a bit to try to get L1_L5, or fall back to L1 or just GPS.

    This post indicates a device crash, but I believe the original code would have given an UnexpectedTypeException (expected Number, got Symbol). If you applied the first fix to just update the reference to get the Number, you'd have got an InvalidValueException on some devices because the requested configuration is not supported. Correct?

Comment
  • Yes, the reference to CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5 did need to be prefixed with the Position module. We fixed this a while back along with adding a call to check for hasConfiguration. Unfortunately, on older devices that would still generate a compiler warning/error for the hasConfiguration symbol not being has checked.

    I've updated the snippet a bit to try to get L1_L5, or fall back to L1 or just GPS.

    This post indicates a device crash, but I believe the original code would have given an UnexpectedTypeException (expected Number, got Symbol). If you applied the first fix to just update the reference to get the Number, you'd have got an InvalidValueException on some devices because the requested configuration is not supported. Correct?

Children
No Data