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
  • For context, here's the full example:

    using Toybox.Position;
    
    var options = {
        :acquisitionType => Position.LOCATION_CONTINUOUS
    };
    
    if (Position has :POSITIONING_MODE_AVIATION) {
        options[:mode] = Position.POSITIONING_MODE_AVIATION;
    }
    
    if (Position has :CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5) {
        options[:configuration] = :CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5;
    } else if (Position has :CONSTELLATION_GPS_GLONASS) {
        options[:constellations] = [ Position.CONSTELLATION_GPS, Position.CONSTELLATION_GLONASS ];
    } else {
        options = Position.LOCATION_CONTINUOUS;
    }
    
    // Continuous location updates using selected options
    Position.enableLocationEvents(options, method(:onPosition));
    
    function onPosition(info) {
        var myLocation = info.position.toDegrees();
    }

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

Comment
  • For context, here's the full example:

    using Toybox.Position;
    
    var options = {
        :acquisitionType => Position.LOCATION_CONTINUOUS
    };
    
    if (Position has :POSITIONING_MODE_AVIATION) {
        options[:mode] = Position.POSITIONING_MODE_AVIATION;
    }
    
    if (Position has :CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5) {
        options[:configuration] = :CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5;
    } else if (Position has :CONSTELLATION_GPS_GLONASS) {
        options[:constellations] = [ Position.CONSTELLATION_GPS, Position.CONSTELLATION_GLONASS ];
    } else {
        options = Position.LOCATION_CONTINUOUS;
    }
    
    // Continuous location updates using selected options
    Position.enableLocationEvents(options, method(:onPosition));
    
    function onPosition(info) {
        var myLocation = info.position.toDegrees();
    }

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

Children
No Data