Ticket Created
over 5 years ago

WERETECH-7824

Fit Contributor fails to write developer fields to MESG_TYPE_SESSION or MSG_TYPE_LAP messages.

Connect IQ Fit Contributor creates  'developer_data_id' and 'field_description' messages for  MESG_TYPE_RECORD messages in the Activity FIT file, but it fails to create them with MESG_TYPE_SESSION or MESG_TYPE_LAP .

Code - adapted from Module: Toybox::FitContributor


 if ($.session == null)
        	{
            $.session = Record.createSession({ :name => "raceQs", :sport => Record.SPORT_GENERIC});
             $.session.start();
	bananasEarnedField  = $.session.createField(
	"bananas_earned",
	   5,
	   Toybox.FitContributor.DATA_TYPE_UINT16,
	     {:mesgType=>Toybox.FitContributor.MESG_TYPE_SESSION, :units=>"B"}
	        ); 
        }
        totalBananas = 100;
        bananasEarnedField.setData(totalBananas);
    


Procedure.

Compile and run an app containing the code in the SDK simulator or a physical device (I used a Fenix5)

Save the Activity to a local file.

Run FitCSVTool.jar from the Fit SDK package on the resulting fit file

Expected result:

To find In the Fit File contains 

Definition 9 developer_data_id
Data 9 developer_data_id
Definition 10 field_description
Data 10 field_description

Actual result

No developer_data_id or field_description Definition or Data messages in the output.

Further info

  1. When I modify the code to generate a MSG_TYPE_RECORD, the expected fields are generated and the developer data is found in the 'record' messages
  2. when I run with MSG_TYPE_LAP no developer_data_id or field_description Definition or Data messages in the output.
  3. I have built a Fit file decoding program in PHP to examine session, lap and record messages and to decode developer data by interpreting the developer_data_id and field_description messages. This confirms what I'm finding from FitCSVTool.


[UPDATE]

I have since discovered that when writing a developer field to a MSG_TYPE_LAP message, the data is  in fact written to the message, but there are no developer_data_id or field_description messages which explains why FitCSVTool fails to detect the value.

Parents
  • Former Member

    I have returned to this issue and think I have resolved the inconsistency between your working code and my failing implementation for creating a developer field in the session message.

    If, in your example, you define the bananasEarnedSession variable inside the onSelect() function (instead in the class definition), like

     function onSelect(){
    		var bananasEarnedSession = null;
    		var boatName = "Harlequin";
            if ($.session == null){
                $.session = ActivityRecording.createSession({ :name => "raceQs", :sport => ActivityRecording.SPORT_GENERIC});
                $.session.start();
    	        bananasEarnedSession  = $.session.createField(
                    "bananaSessionName",
    	            5,
    	            Toybox.FitContributor.DATA_TYPE_UINT16,
    	            {:mesgType=>Toybox.FitContributor.MESG_TYPE_SESSION, :units=>"SessionUnit"}
    	        );
    
                bananasEarnedLap  = $.session.createField(
                    "bananaLapName",
    	            6,
    	            Toybox.FitContributor.DATA_TYPE_UINT16,
    	            {:mesgType=>Toybox.FitContributor.MESG_TYPE_LAP, :units=>"SessionUnit"}
    	        );
            }
            var totalBananas = 100;
            bananasEarnedSession.setData(totalBananas);
           	var lapValue = 999;
            bananasEarnedLap.setData(lapValue);
    
        }

    the code runs, but the  bananasEarnedSession field is not created. 

    It seems to me that the field variable has to be defined in the class scope, like in your code, even though, it's only referenced in the onSelect() function.

    Phew!

Comment
  • Former Member

    I have returned to this issue and think I have resolved the inconsistency between your working code and my failing implementation for creating a developer field in the session message.

    If, in your example, you define the bananasEarnedSession variable inside the onSelect() function (instead in the class definition), like

     function onSelect(){
    		var bananasEarnedSession = null;
    		var boatName = "Harlequin";
            if ($.session == null){
                $.session = ActivityRecording.createSession({ :name => "raceQs", :sport => ActivityRecording.SPORT_GENERIC});
                $.session.start();
    	        bananasEarnedSession  = $.session.createField(
                    "bananaSessionName",
    	            5,
    	            Toybox.FitContributor.DATA_TYPE_UINT16,
    	            {:mesgType=>Toybox.FitContributor.MESG_TYPE_SESSION, :units=>"SessionUnit"}
    	        );
    
                bananasEarnedLap  = $.session.createField(
                    "bananaLapName",
    	            6,
    	            Toybox.FitContributor.DATA_TYPE_UINT16,
    	            {:mesgType=>Toybox.FitContributor.MESG_TYPE_LAP, :units=>"SessionUnit"}
    	        );
            }
            var totalBananas = 100;
            bananasEarnedSession.setData(totalBananas);
           	var lapValue = 999;
            bananasEarnedLap.setData(lapValue);
    
        }

    the code runs, but the  bananasEarnedSession field is not created. 

    It seems to me that the field variable has to be defined in the class scope, like in your code, even though, it's only referenced in the onSelect() function.

    Phew!

Children
No Data