summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--spec/spec_helper.rb4
-rw-r--r--tasks/gem.rake3
6 files changed, 40 insertions, 22 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
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 2d93e12..b79fc8c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -80,6 +80,10 @@ def create_fit_activity(config)
ts = Time.parse(config[:t])
serial = config[:serial] || 12345890
a = Fit4Ruby::Activity.new({ :timestamp => ts })
+ a.new_file_id({ :manufacturer => 'garmin',
+ :time_created => ts,
+ :garmin_product => 'fr920xt',
+ :serial_number => serial })
a.total_timer_time = (config[:duration] || 10) * 60
a.new_user_profile({ :timestamp => ts,
:age => 33, :height => 1.78, :weight => 73.0,
diff --git a/tasks/gem.rake b/tasks/gem.rake
index 57a914d..57e0d7d 100644
--- a/tasks/gem.rake
+++ b/tasks/gem.rake
@@ -28,8 +28,7 @@ task :permissions do
# Find the bin and test directories relative to this file.
baseDir = File.expand_path('..', File.dirname(__FILE__))
- execs = Dir.glob("#{baseDir}/bin/*") +
- Dir.glob("#{baseDir}/test/**/genrefs")
+ execs = Dir.glob("#{baseDir}/bin/*")
Find.find(baseDir) do |f|
# Ignore the whoke pkg directory as it may contain links to the other