Developer data fields of type String not supported?

I'm playing with the Javascript encoder, and I am having trouble making custom data fields with the type string. Writing to the fields (in this case in the Session message) crashes the script with the following message:

Could not convert "sample Description" to "undefined"

To reproduce, in the encode-activity-recipe.test.js, I have added the following:

const HEART_RATE_KEY = 1;
...
    const descFieldDescMesg = {
        mesgNum: Profile.MesgNum.FIELD_DESCRIPTION,
        developerDataIndex: 0,
        fieldDefinitionNumber: 2,
        fitBaseTypeId: Utils.FitBaseType.STRING,
        fieldName: "Description",
        units: "",
        nativeMesgNum: Profile.MesgNum.SESSION,
    };
    mesgs.push(descFieldDescMesg);
...
        [DESC_KEY]: {
            developerDataIdMesg: developerDataIdMesg,
            fieldDescriptionMesg: descFieldDescMesg,
        },
...
        developerFields: {
            [DOUGHNUTS_EARNED_KEY]: (timestamp - startTime) / 1200.0, // Three per hour
            [DESC_KEY]: "sample Description",
        },

Is this expected behaviour? And what am I doing wrong in this case?

  • The issue is with how the developer field description is being created. 
    https://github.com/garmin/fit-javascript-sdk/blob/main/src/mesg-definition.js#L78

    Adding type, scale, offset, and component to the developer field description fixes the issue. 

    this.developerFieldDefinitions.push({
        key,
        baseType: fieldDescriptionMesg.fitBaseTypeId,
        fieldDefinitionNumber: fieldDescriptionMesg.fieldDefinitionNumber,
        size: this.#fieldSize(mesg.developerFields[key], baseTypeDef),
        developerDataIndex: developerDataIdMesg.developerDataIndex,
        type: FIT.BaseTypeToFieldType[baseTypeDef.type],
        scale: 1,
        offset: 0,
        components:[],
    });

    After adding those values and converting the FIT file to CSV, I can see the developer data Description field in the Session mesg.

    Data,9,session,message_index,"0",,timestamp,"1136933305",s,start_time,"1136929704",,total_elapsed_time,"3601.0",s,total_timer_time,"3601.0",s,sport,"STAND_UP_PADDLEBOARDING",,sub_sport,"GENERIC",,first_lap_index,"0",,num_laps,"1",,Doughnuts Earned,"3.0008333",doughnuts,Description,"sample Description",null,

    We need to validate the change still, but we should be able to update the SDK before the end of the month. 

    I also noticed that the there is not check to make sure that the size of a developer field, in bytes, is not greater than 255. So if you hack in the fix locally, keep the strings under 255 bytes (bytes not characters).