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?