Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions garmin_fit_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand All @@ -23,4 +23,4 @@
from garmin_fit_sdk.stream import Stream
from garmin_fit_sdk.util import FIT_EPOCH_S, convert_datetime_to_timestamp, convert_timestamp_to_datetime, BASE_TYPE_TO_FIELD_TYPE, FIELD_TYPE_TO_BASE_TYPE

__version__ = '21.217.0'
__version__ = '21.218.0'
4 changes: 2 additions & 2 deletions garmin_fit_sdk/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/accumulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/accumulator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/bitstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/bitstream.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/crc_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/crc_calculator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/decoder.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
66 changes: 27 additions & 39 deletions garmin_fit_sdk/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down Expand Up @@ -90,7 +90,14 @@ def on_mesg(self, mesg_num, mesg):
"""
try:
mesg_definition = self._create_mesg_definition(mesg_num, mesg)
self._write_mesg_definition_if_not_active(mesg_definition)
local_mesg_definition = self._find_local_mesg_definition(mesg_definition)

if local_mesg_definition is not None:
mesg_definition = local_mesg_definition
else:
mesg_definition.local_mesg_num = self._next_local_mesg_num & FIT.LOCAL_MESG_NUM_MASK
self._next_local_mesg_num += 1
self._write_mesg_definition(mesg_definition)

# Write message header
self._output_stream.write_uint8(mesg_definition.local_mesg_num)
Expand Down Expand Up @@ -190,22 +197,18 @@ def _transform_value(self, value, field_definition):
invalid = FIT.BASE_TYPE_DEFINITIONS[base_type]['invalid']

try:
# None/null => invalid
if FIT.is_none(value):
return invalid

# Not a number, string, date, or bool => invalid
if FIT.is_not_number_string_date_or_boolean(value):
raise ValueError()
raise ValueError("Value is not a number, string, date, or boolean")

# Numeric field
if field_type in FIT.NUMERIC_FIELD_TYPES:
if FIT.is_string(value):
value = float(value) if '.' in value else int(value)
elif FIT.is_boolean(value):
raise ValueError()
raise ValueError("Boolean value not allowed for numeric field")
elif not FIT.is_numeric(value):
raise ValueError()
raise ValueError("Value is not numeric for numeric field")

has_scale_or_offset = (
field_definition['scale'] != FIT.FIELD_DEFAULT_SCALE
Expand All @@ -225,13 +228,13 @@ def _transform_value(self, value, field_definition):
if FIT.is_date(value):
return convert_datetime_to_timestamp(value)
if not FIT.is_numeric(value):
raise ValueError()
raise ValueError("Value is not numeric or date for date_time field")
return value

# String field
if field_type == 'string':
if not FIT.is_string(value):
raise ValueError()
raise ValueError("Value is not a string for string field")
return value

# Profile type field - try numeric passthrough first
Expand All @@ -244,10 +247,10 @@ def _transform_value(self, value, field_definition):
if type_value == value:
return type_key

raise ValueError()
raise ValueError(f'Value "{value}" could not be mapped to profile type "{field_type}"')

except Exception:
raise ValueError(f'Could not convert "{value}" to "{field_type}"')
except Exception as exception:
raise ValueError(f'Could not convert "{value}" to "{field_type}": {exception}')

@staticmethod
def _unapply_scale_and_offset(value, scale, offset):
Expand All @@ -263,36 +266,21 @@ def _create_mesg_definition(self, mesg_num, mesg):
Returns:
_MesgDefinition: The created message definition.
"""
mesg_definition = _MesgDefinition(mesg_num, mesg, field_descriptions=self._field_descriptions)
mesg_definition.local_mesg_num = self._lookup_local_mesg_num(mesg_definition)
return mesg_definition
return _MesgDefinition(mesg_num, mesg, field_descriptions=self._field_descriptions)

def _lookup_local_mesg_num(self, mesg_definition):
"""Searches the local mesg definitions for a matching mesg_definition.
def _find_local_mesg_definition(self, mesg_definition):
"""Returns the active local mesg definition equivalent to mesg_definition, if any.

Args:
mesg_definition: The mesg definition to match.
mesg_definition: The candidate message definition to match.

Returns:
int: The local_mesg_num to be used with mesg_definition.
_MesgDefinition | None: The matching active local mesg definition, if present.
"""
for i, local_def in enumerate(self._local_mesg_definitions):
for local_def in self._local_mesg_definitions:
if local_def is not None and local_def.equals(mesg_definition):
return i
result = self._next_local_mesg_num
self._next_local_mesg_num += 1
return result & FIT.LOCAL_MESG_NUM_MASK

def _write_mesg_definition_if_not_active(self, mesg_definition):
"""Writes the mesg_definition to the output stream if it is not one of the currently active 16.

Args:
mesg_definition: The mesg definition to match.
"""
local_num = mesg_definition.local_mesg_num
existing = self._local_mesg_definitions[local_num]
if existing is None or not existing.equals(mesg_definition):
self._write_mesg_definition(mesg_definition)
return local_def
return None

def _write_mesg_definition(self, mesg_definition):
"""Writes the mesg_definition to the output stream.
Expand All @@ -301,4 +289,4 @@ def _write_mesg_definition(self, mesg_definition):
mesg_definition: The mesg definition to write.
"""
mesg_definition.write(self._output_stream)
self._local_mesg_definitions[mesg_definition.local_mesg_num] = mesg_definition
self._local_mesg_definitions[mesg_definition.local_mesg_num] = mesg_definition
4 changes: 2 additions & 2 deletions garmin_fit_sdk/encoder.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/fit.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/hr_mesg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/hr_mesg_utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/mesg_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/mesg_definition.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/mesgs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/output_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
9 changes: 6 additions & 3 deletions garmin_fit_sdk/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Profile = {
'version': {
'major': 21,
'minor': 217,
'minor': 218,
'patch': 0,
'type': "Release"
},
Expand Down Expand Up @@ -28464,6 +28464,8 @@
4814: 'fr170_music',
4815: 'fr170',
4825: 'approach_j1',
4874: 'approach_s72_43mm',
4875: 'approach_s72_47mm',
4879: 'd2_mach2',
4916: 'fr70_2026',
4952: 'fenix9_pro_43mm',
Expand All @@ -28477,6 +28479,7 @@
4944: 'd2_air_x15',
5019: 'cirqa_smart_band',
5056: 'd2_mach2_pro',
5169: 'enduro4',
10007: 'sdm4', # SDM4 footpod
10014: 'edge_remote',
20533: 'tacx_training_app_win',
Expand Down
4 changes: 2 additions & 2 deletions garmin_fit_sdk/profile.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Transfer (FIT) Protocol License.
###########################################################################################
# ****WARNING**** This file is auto-generated! Do NOT edit this file.
# Profile Version = 21.217.0Release
# Tag = production/release/21.217.0-0-g248b1c46
# Profile Version = 21.218.0Release
# Tag = production/release/21.218.0-0-g96fee6d7
############################################################################################


Expand Down
Loading
Loading