apiotics 0.1.36 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/apiotics/hardware.rb +10 -5
- data/lib/apiotics/portal.rb +6 -5
- data/lib/apiotics/version.rb +1 -1
- data/lib/generators/apiotics/create_model/templates/create_module_model_table.rb.erb +1 -0
- data/lib/generators/apiotics/script/templates/install_firmware.rake +7 -3
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d3f9c7b4169da3b3e7774bb0310cdb56f9b6307
|
|
4
|
+
data.tar.gz: af686841990496ddfc778cc0f15ba8f99f721566
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c01ebd06d73be068c04fae9c1f33c1058ba37973eaf278e72e90260d0440d950d171de085044d1be3475aed2dfd25141b314bb33a12c0c17654da923d3eaacba
|
|
7
|
+
data.tar.gz: d6e8d04870e1d44b76d2fd8ca710e05510780b020c195b776f27cc3e12a8803f5470fcb4d046d2e1d9a976606fefcc2e49f83dda7fb6f67904106e0661ae6536
|
data/lib/apiotics/hardware.rb
CHANGED
|
@@ -56,7 +56,7 @@ module Apiotics
|
|
|
56
56
|
msg = system(string)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
def self.openocd(worker_name)
|
|
59
|
+
def self.openocd(worker_name, name)
|
|
60
60
|
download_directory = Rails.root.join('lib', 'openocd')
|
|
61
61
|
Dir.mkdir download_directory unless Dir.exist?(download_directory)
|
|
62
62
|
download_directory = Rails.root.join('lib', 'openocd', 'downloads')
|
|
@@ -65,17 +65,22 @@ module Apiotics
|
|
|
65
65
|
config = Apiotics::Portal.openocd_worker_config(worker_name)
|
|
66
66
|
config = JSON.parse(config)
|
|
67
67
|
unless config["openocd_config_file_name"] == nil || config["openocd_config_file_name"] == ""
|
|
68
|
-
path = Rails.root.join('lib', 'openocd', 'downloads', config["
|
|
68
|
+
path = Rails.root.join('lib', 'openocd', 'downloads', config["firmware_file_name"])
|
|
69
69
|
if File.exist?(path)
|
|
70
|
-
file = File.open(path)
|
|
71
|
-
firmware_data = file.read
|
|
72
|
-
file.close
|
|
73
70
|
else
|
|
74
71
|
firmware_data = Apiotics::Portal.download_firmware(worker_name)
|
|
75
72
|
file = File.new(path, 'w')
|
|
76
73
|
file.write firmware_data.force_encoding(Encoding::UTF_8)
|
|
77
74
|
file.close
|
|
78
75
|
end
|
|
76
|
+
if name != nil
|
|
77
|
+
data = File.open(path, 'r+')
|
|
78
|
+
version_offset = 2048
|
|
79
|
+
offset = version_offset + 4 + 68 + 68 + 68
|
|
80
|
+
name = name + "\0"
|
|
81
|
+
IO.write(data, name, offset)
|
|
82
|
+
data.close
|
|
83
|
+
end
|
|
79
84
|
msg = self.install_firmware(config["openocd_config_file_name"], path, config["openocd_start_address"])
|
|
80
85
|
end
|
|
81
86
|
return msg
|
data/lib/apiotics/portal.rb
CHANGED
|
@@ -91,19 +91,20 @@ module Apiotics
|
|
|
91
91
|
instance_hash = JSON.parse(HTTParty.post("#{Apiotics.configuration.portal}api/workers", :query => {:public_key => Apiotics.configuration.public_key, :private_key => Apiotics.configuration.private_key}).body)
|
|
92
92
|
klass = (worker_name.to_s + "::" + worker_name.to_s).constantize rescue nil
|
|
93
93
|
unless klass == nil
|
|
94
|
-
instance_ids =
|
|
95
|
-
instance_hash[worker_name].each do |instance_id,
|
|
96
|
-
if status == "Active"
|
|
97
|
-
instance_ids
|
|
94
|
+
instance_ids = Hash.new
|
|
95
|
+
instance_hash[worker_name].each do |instance_id,status_hash|
|
|
96
|
+
if status_hash["status"] == "Active"
|
|
97
|
+
instance_ids[instance_id] = status_hash
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
stale_instances = klass.where.not(apiotics_instance: instance_ids)
|
|
101
101
|
stale_instances.destroy_all
|
|
102
|
-
instance_ids.each do |instance_id|
|
|
102
|
+
instance_ids.each do |instance_id, status_hash|
|
|
103
103
|
i = klass.find_by(apiotics_instance: instance_id)
|
|
104
104
|
if i == nil
|
|
105
105
|
i = klass.new
|
|
106
106
|
i.apiotics_instance = instance_id
|
|
107
|
+
i.name = status_hash["name"]
|
|
107
108
|
i.save(:validate => false)
|
|
108
109
|
Apiotics.configuration.targets[worker_name].keys.each do |key|
|
|
109
110
|
subklass = (worker_name + "::" + key).constantize rescue nil
|
data/lib/apiotics/version.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
namespace :firmware do
|
|
2
|
-
desc "Install firmware on devices"
|
|
3
|
-
task :install, [:worker] => [:environment] do |task, args|
|
|
4
|
-
|
|
2
|
+
desc "Install firmware on devices. Use rake firmware:install {worker_name} to install firmware on a device. Use rake firmware:install {worker_name} {instance_name} to install firmware and set a name for the device."
|
|
3
|
+
task :install, [:worker, :name] => [:environment] do |task, args|
|
|
4
|
+
if args[:name] == nil
|
|
5
|
+
Apiotics::Hardware.openocd(args[:worker], nil)
|
|
6
|
+
else
|
|
7
|
+
Apiotics::Hardware.openocd(args[:worker] args[:name])
|
|
8
|
+
end
|
|
5
9
|
end
|
|
6
10
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: apiotics
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.37
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- MicroArx Corporation
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-08-
|
|
11
|
+
date: 2017-08-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
248
248
|
version: '0'
|
|
249
249
|
requirements: []
|
|
250
250
|
rubyforge_project:
|
|
251
|
-
rubygems_version: 2.
|
|
251
|
+
rubygems_version: 2.2.2
|
|
252
252
|
signing_key:
|
|
253
253
|
specification_version: 4
|
|
254
254
|
summary: IoT For Everybody.
|