FIT JavaScript SDK - Custom message

Hi All, I wanted to ask a question about custom messages.

In previous versions of the SDK, using the FitGen.exe tool in combination with profile.xls, I was able to generate custom messages.

This allowed the C++ parser to correctly recognize my messages.

With the new Javascript SDK, how do I manage these custom messages?

Thanks for the help

  • Fitgen generates the source code for all eight SDKs, including the JavaScript SDK. You will need to add the generated source code to your project instead of using the package from npm. This is the same thing that needs to be done when using the C++ SDK, but since the C++ SDK is not in a package manager, adding the source to your project is the standard way of using it. 

    Another, but maybe hacky way, would be to modify the Profile before decoding. You would only need to include the custom generated profile.js in your project. The Profile is not frozen, so you can manipulate it before decoding a file.

    import { default as CustomProfile } from 'profile.js';

    import { Profile } from "@garmin/fitsdk-internal";

    Profile.messages = CustomProfile.messages;
    Profile.types = CustomProfile.types;
    Profile.MesgNum = CustomProfile.MesgNum;
  • Thanks for the fast reply. So, now the FitGen.exe is the one provided with the C SDK, right?

  • Fitgen is in the C SDK repo, since the C SDK requires configuration which is the primary purpose of FitGen.

    https://github.com/garmin/fit-c-sdk