write a decoding / encoding software

What the best way to start writing an decoding / encoding software ?

I would like to write something like a "filter" for FIT file, so need to decode the re-encode FIT data.

but documentation is a bit lacking/unclear, and from sample I've just found how to read/decode to csv but with loss, sams for encoding

would prefer golang but java would be OK.

  • In the Java SDK look at the ActivityRepairFilter and ActivityRepairTool classes for an example. The Tool creates a decoder, filter, and encoder and ties them together. The filter implements the BufferedMesgListener and MesgSource interfaces, you could also use the MesgListener interface.

    The decoder is a message source and the encoder is a message listener. The two can be joined together by their interfaces to rewrite a file.

    FileEncoder fileEncoder = new FileEncoder(outputStream, Fit.ProtocolVersion.V2_0);
    Decode decoder = new Decode();

    decoder.addListener(fileEncoder);
    decoder.read(inputStream);

    A filter implements both the message source and message listener interfaces and sits between the decoder and encoder. There could be multiple filters chained together too.

    FileEncoder fileEncoder = new FileEncoder(outputStream);
    Decode decoder = new Decode();
    SomeFilter someFilter = new SomeFilter()

    decoder.addListener(someFilter);
    someFilter.addListener(fileEncoder);

    decoder.read(inputStream);


    See the ActivityRepairTool class for a complete example. The repair tool assumes that it will be used on bad files, so there is extra error handling that separates the decoding from the encoding incase there is an error during decoding.