apiotics 0.1.34 → 0.1.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/apiotics.rb +1 -0
- data/lib/apiotics/hardware.rb +85 -0
- data/lib/apiotics/portal.rb +12 -0
- data/lib/apiotics/version.rb +1 -1
- data/lib/generators/apiotics/script/script_generator.rb +1 -0
- data/lib/generators/apiotics/script/templates/install_firmware.rake +6 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1fbc55f9161178762ea1d70b7c32bab58b91e84
|
4
|
+
data.tar.gz: 84566e3f791346e875b10f236a75fcb7cfc775c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acf51c3ba54c7b8722ff5e33c925a5103712a6cde89f4879904f1b3d7c5dcff9edbcc7b59ef5a949ce8014935368f4ac3ef467d55b8956ab3e8641733f248b59
|
7
|
+
data.tar.gz: ccf16f11471035157f5ebc652aee454a58c4a81e09ea0e0a6ad4dc9549395c010eba5903d2ddedef104336cdfb3b3d642f5579970b08e8dd6eaf16fef9df116c
|
data/lib/apiotics.rb
CHANGED
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'os'
|
2
|
+
|
3
|
+
module Apiotics
|
4
|
+
class Hardware
|
5
|
+
def self.bits
|
6
|
+
OS.bits
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.linux
|
10
|
+
OS.linux?
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.mac
|
14
|
+
OS.mac?
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.save_openocd
|
18
|
+
os = nil
|
19
|
+
if self.linux == true
|
20
|
+
if self.bits == 64
|
21
|
+
os = "debian64"
|
22
|
+
elsif self.bits == 32
|
23
|
+
os = "debian32"
|
24
|
+
end
|
25
|
+
elsif self.mac == true
|
26
|
+
os = "mac"
|
27
|
+
end
|
28
|
+
unless os == nil
|
29
|
+
data = Apiotics::Portal.openocd(os)
|
30
|
+
directory = Rails.root.join('lib', 'openocd')
|
31
|
+
Dir.mkdir directory unless Dir.exist?(directory)
|
32
|
+
path = Rails.root.join('lib', 'openocd', 'openocd.tgz')
|
33
|
+
file = File.new(path, 'w')
|
34
|
+
file.write data.force_encoding(Encoding::UTF_8)
|
35
|
+
file.close
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.unpack_openocd
|
40
|
+
directory = Rails.root.join('lib', 'openocd')
|
41
|
+
Dir.chdir directory
|
42
|
+
path = Rails.root.join('lib', 'openocd', 'openocd.tgz')
|
43
|
+
msg = system("tar -xvzf #{path}")
|
44
|
+
if msg == true
|
45
|
+
#File.delete(path) if File.exist?(path)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.install_firmware(config_script, firmware_path, starting_address)
|
50
|
+
directory = Rails.root.join('lib', 'openocd', 'gnuarmeclipse', 'openocd')
|
51
|
+
Dir.chdir directory
|
52
|
+
version_folder = Dir['*/'].first[0..-2]
|
53
|
+
directory = Rails.root.join('lib', 'openocd', 'gnuarmeclipse', 'openocd', version_folder)
|
54
|
+
Dir.chdir directory
|
55
|
+
string = "bin/openocd -f \"scripts/board/" + config_script + "\"" + " -c \"program " + firmware_path.to_s + " exit " + starting_address.to_s + "\""
|
56
|
+
msg = system(string)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.openocd(worker_name)
|
60
|
+
download_directory = Rails.root.join('lib', 'openocd')
|
61
|
+
Dir.mkdir download_directory unless Dir.exist?(download_directory)
|
62
|
+
download_directory = Rails.root.join('lib', 'openocd', 'downloads')
|
63
|
+
Dir.mkdir download_directory unless Dir.exist?(download_directory)
|
64
|
+
Dir.chdir download_directory
|
65
|
+
config = Apiotics::Portal.openocd_worker_config(worker_name)
|
66
|
+
config = JSON.parse(config)
|
67
|
+
unless config["openocd_config_file_name"] == nil || config["openocd_config_file_name"] == ""
|
68
|
+
path = Rails.root.join('lib', 'openocd', 'downloads', config["openocd_config_file_name"])
|
69
|
+
if File.exist?(path)
|
70
|
+
file = File.open(path)
|
71
|
+
firmware_data = file.read
|
72
|
+
file.close
|
73
|
+
else
|
74
|
+
firmware_data = Apiotics::Portal.download_firmware(worker_name)
|
75
|
+
file = File.new(path, 'w')
|
76
|
+
file.write firmware_data.force_encoding(Encoding::UTF_8)
|
77
|
+
file.close
|
78
|
+
end
|
79
|
+
msg = self.install_firmware(config["openocd_config_file_name"], path, config["openocd_start_address"])
|
80
|
+
end
|
81
|
+
return msg
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
data/lib/apiotics/portal.rb
CHANGED
@@ -155,5 +155,17 @@ module Apiotics
|
|
155
155
|
return hash["ca_certificate"]
|
156
156
|
end
|
157
157
|
|
158
|
+
def self.openocd(system)
|
159
|
+
response = HTTParty.post("#{Apiotics.configuration.portal}api/openocd", :query => {:public_key => Apiotics.configuration.public_key, :private_key => Apiotics.configuration.private_key, :system => system}).body
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.openocd_worker_config(worker_name)
|
163
|
+
response = HTTParty.post("#{Apiotics.configuration.portal}api/openocd_details", :query => {:public_key => Apiotics.configuration.public_key, :private_key => Apiotics.configuration.private_key, :worker => worker_name}).body
|
164
|
+
end
|
165
|
+
|
166
|
+
def self.download_firmware(worker_name)
|
167
|
+
response = HTTParty.post("#{Apiotics.configuration.portal}api/download", :query => {:public_key => Apiotics.configuration.public_key, :private_key => Apiotics.configuration.private_key, :worker => worker_name}).body
|
168
|
+
end
|
169
|
+
|
158
170
|
end
|
159
171
|
end
|
data/lib/apiotics/version.rb
CHANGED
@@ -19,6 +19,7 @@ module Apiotics
|
|
19
19
|
copy_file "test_comm_server.rake", "lib/tasks/test_comm_server.rake"
|
20
20
|
copy_file "dev_comm_server.rake", "lib/tasks/dev_comm_server.rake"
|
21
21
|
copy_file "publish_script.rake", "lib/tasks/publish_script.rake"
|
22
|
+
copy_file "install_firmware.rake", "lib/tasks/install_firmware.rake"
|
22
23
|
FileUtils.chmod 0775, "lib/scripts/server_control.rb"
|
23
24
|
end
|
24
25
|
|
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.35
|
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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: os
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: pg
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,6 +163,7 @@ files:
|
|
149
163
|
- lib/apiotics/client.rb
|
150
164
|
- lib/apiotics/configuration.rb
|
151
165
|
- lib/apiotics/extract.rb
|
166
|
+
- lib/apiotics/hardware.rb
|
152
167
|
- lib/apiotics/insert.rb
|
153
168
|
- lib/apiotics/parse.rb
|
154
169
|
- lib/apiotics/portal.rb
|
@@ -197,6 +212,7 @@ files:
|
|
197
212
|
- lib/generators/apiotics/script/templates/dev_comm_server.rake
|
198
213
|
- lib/generators/apiotics/script/templates/dev_server.rb
|
199
214
|
- lib/generators/apiotics/script/templates/dev_server_control.rb
|
215
|
+
- lib/generators/apiotics/script/templates/install_firmware.rake
|
200
216
|
- lib/generators/apiotics/script/templates/publish_script.rake
|
201
217
|
- lib/generators/apiotics/script/templates/script.rb.erb
|
202
218
|
- lib/generators/apiotics/script/templates/server.rb
|
@@ -232,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
248
|
version: '0'
|
233
249
|
requirements: []
|
234
250
|
rubyforge_project:
|
235
|
-
rubygems_version: 2.
|
251
|
+
rubygems_version: 2.6.10
|
236
252
|
signing_key:
|
237
253
|
specification_version: 4
|
238
254
|
summary: IoT For Everybody.
|