summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/postrunner/FFS_Activity.rb4
-rw-r--r--lib/postrunner/FFS_Device.rb6
-rw-r--r--lib/postrunner/FitFileStore.rb40
-rw-r--r--lib/postrunner/Main.rb5
4 files changed, 35 insertions, 20 deletions
diff --git a/lib/postrunner/FFS_Activity.rb b/lib/postrunner/FFS_Activity.rb
index 27efea0..46ea2bf 100644
--- a/lib/postrunner/FFS_Activity.rb
+++ b/lib/postrunner/FFS_Activity.rb
@@ -157,10 +157,6 @@ module PostRunner
load_fit_file(filter)
end
- def dump(filter)
- load_fit_file(filter)
- end
-
def query(key)
unless @@Schemata.include?(key)
raise ArgumentError, "Unknown key '#{key}' requested in query"
diff --git a/lib/postrunner/FFS_Device.rb b/lib/postrunner/FFS_Device.rb
index b7483c1..98f5c87 100644
--- a/lib/postrunner/FFS_Device.rb
+++ b/lib/postrunner/FFS_Device.rb
@@ -12,6 +12,7 @@
require 'perobs'
require 'postrunner/FFS_Activity'
+require 'postrunner/FFS_Monitoring'
module PostRunner
@@ -50,13 +51,12 @@ module PostRunner
# @return [FFS_Activity or FFS_Monitoring] Corresponding entry in the
# FitFileStore or nil if file could not be added.
def add_fit_file(fit_file_name, fit_entity, overwrite)
- case fit_entity.class
- when Fit4Ruby::Activity.class
+ if fit_entity.is_a?(Fit4Ruby::Activity)
entity = activity_by_file_name(File.basename(fit_file_name))
entities = @activities
type = 'activity'
new_entity_class = FFS_Activity
- when Fit4Ruby::Monitoring.class
+ elsif fit_entity.is_a?(Fit4Ruby::Monitoring_B)
entity = monitoring_by_file_name(File.basename(fit_file_name))
entities = @monitorings
type = 'monitoring'
diff --git a/lib/postrunner/FitFileStore.rb b/lib/postrunner/FitFileStore.rb
index b85cdfa..89c8e81 100644
--- a/lib/postrunner/FitFileStore.rb
+++ b/lib/postrunner/FitFileStore.rb
@@ -81,8 +81,8 @@ module PostRunner
end
unless [ Fit4Ruby::Activity,
- Fit4Ruby::Monitoring ].include?(fit_entity.class)
- Log.critical "Unsupported FIT file type #{fit_entity.class}"
+ Fit4Ruby::Monitoring_B ].include?(fit_entity.class)
+ Log.fatal "Unsupported FIT file type #{fit_entity.class}"
end
# Generate a String that uniquely identifies the device that generated
@@ -330,16 +330,36 @@ module PostRunner
end
def extract_fit_file_id(fit_entity)
- fit_entity.device_infos.each do |di|
- if di.device_index == 0
- return {
- :manufacturer => di.manufacturer,
- :product => di.garmin_product || di.product,
- :serial_number => di.serial_number
- }
+ unless (fid = fit_entity.file_id)
+ Log.fatal 'FIT file has no file_id section'
+ end
+
+ if fid.manufacturer == 'garmin' &&
+ fid.garmin_product == 'fr920xt'
+ # Garmin Fenix3 with firmware before 6.80 is reporting 'fr920xt' in
+ # the file_id section but 'fenix3' in the first device_info section.
+ # To tell the Fenix3 apart from the FR920XT we need to look into the
+ # device_info section for all devices with a garmin_product of
+ # 'fr920xt'.
+ fit_entity.device_infos.each do |di|
+ if di.device_index == 0
+ return {
+ :manufacturer => di.manufacturer,
+ :product => di.garmin_product || di.product,
+ :serial_number => di.serial_number
+ }
+ end
end
+ Log.fatal "Fit entity has no device info for 0"
+ else
+ # And for all properly developed devices we can just look at the
+ # file_id section.
+ return {
+ :manufacturer => fid.manufacturer,
+ :product => fid.garmin_product || fid.product,
+ :serial_number => fid.serial_number
+ }
end
- Log.fatal "Fit entity has no device info for 0"
end
def register_device(long_uid)
diff --git a/lib/postrunner/Main.rb b/lib/postrunner/Main.rb
index bb40df2..e835507 100644
--- a/lib/postrunner/Main.rb
+++ b/lib/postrunner/Main.rb
@@ -430,10 +430,9 @@ EOT
return false
end
- if fit_entity.is_a?(Fit4Ruby::Activity)
+ if fit_entity.is_a?(Fit4Ruby::Activity) ||
+ fit_entity.is_a?(Fit4Ruby::Monitoring_B)
return @ffs.add_fit_file(fit_file_name, fit_entity, @force)
- #elsif fit_entity.is_a?(Fit4Ruby::Monitoring_B)
- # return @monitoring.add(fit_file_name, fit_entity)
else
Log.error "#{fit_file_name} is not a recognized FIT file"
return false