enable location bug after 24.10 update

Hello,

I have been developing a garmin watch app for a fenix 6 pro solar, where I use the enableLocation function to get gps coordinates.

After the 24.10 update I get the following error:

UnexpectedTypeException: Expected Number/Float/Boolean/Long/Double, given Symbol

My code is almost the same as the one in the documentation :

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;
}
  
try{
    Position.enableLocationEvents(options, method(:onPosition));
    System.println("Position enabled");
}
catch (ex){
    System.println(ex.getErrorMessage());
    System.println("Position not enabled");
}

Please let me know if you have any insight on this.

  • Try replacing

    options[:configuration] = :CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5;

    with

    options[:configuration] = Position.CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5;

    The documentation has a bug in the example you used for your code:

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

    I've opened a bug report:

    [https://forums.garmin.com/developer/connect-iq/i/bug-reports/position-enablelocations-documentation-has-a-bug-in-code-example-causes-device-to-crash]

    Please vote for it!

  • Hi,

    Thank you for the reply. I changed the code and it now returns 'Unsupported configuration option'  as an exception. Should I fall back to the default option Position.LOCATION_CONTINUOUS or change the configuration or maybe i missed something?

  • Yeah, CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5 is only supported on "System 6" (CIQ 4.2) devices like Fenix 7, as per the doc. Sorry, I should've mentioned that. (This is a second problem with the documentation lol.)

    I think you're supposed to use Position.hasConfigurationSupport() (new for CIQ 3.3.6 / 4.1.6) to determine support:

    So a more complete and correct example would look something like this:

    //...
    if (
      Position has :CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5 &&
      Position has :hasConfigurationSupport &&
      Position.hasConfigurationSupport(Position.CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5)
    ) {
        options[:configuration] = Position.CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5;
    }
    //...

    And people ask me why I don't update my apps for newer devices....

  • I think that all API level > 3.3.0 are off-limits for the 6 series. I decided to fallback to the default flag for now and see if there is any update in the future for the 6 series. Still the code you provided should be accepted as the correct answer here and probably the documentation should change.

  • The doc is a bit confusing (and wrong).  There are three different cases based on what the device supports.

    1) no support for Constellations.  The default mode will be what was last used by a native app

    This can be checked with something like

    Assume "var hasNewGPS1=false;" and "var hasNewGPS2=false;") 

    hasNewGPS1=(Position has :CONSTELLATION_GLONASS);

    if false, it's case #1

    2)  hasNewGPS1 is true (and NOT hasNewGPS2 - see below)

    the available choices are CONSTELLATION_GPS, CONTELLATION_GPS+CONSTELLATION_GLONASS ,CONSTELLATION_GPS+CONSTELLATION_GALILEO.  You don't want to use the CONFIGURATION_* stuff

    3)  has the CONFIGURATION_* stuff and can be checked with

    if(Position has :hasConfigurationSupport) {
    hasNewGPS2=Position.hasConfigurationSupport(Position.CONFIGURATION_GPS)=Position.hasConfigurationSupport(Position.CONFIGURATION_GPS);
    }

    so if this is true, you need to use this to check the specific configuration before trying to use it.

    For example a device might have CONFIGURATION_GLONASS but not CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1 or v/v.  In the 4.1.7 sim, devices with the L1/L5 configurations don't have that based on  Position.hasConfigurationSupport(), but they do on the real device (I'm using a fr255 in the sim and a real fr255 to test)

    if hasNewGPS2 is true, you don't want to use the CONSTEELATION_* stuff

    -------

    So you want to see which of the three cases you have. And as I said, with this, don't always trust the sim for what's available on a real device

    I'm thinking the f6 is case 2.Per the sim, that's the case.

  • Right now, with the 4.1.7 SDK, and a fr255 as the device, 

    in the sim I see CONFIGURATION_GPS, CONFIGURATION_GPS_GLONASS, and CONFIGURATION_GPS_GALILO are valid

    while on the real device, CONFIGURATION_GPS, CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1, and CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5 are valid