apiotics 0.2.20 → 0.2.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/apiotics/hardware.rb +27 -13
- data/lib/apiotics/portal.rb +10 -0
- data/lib/apiotics/version.rb +1 -1
- data/lib/generators/apiotics/initializer/initializer_generator.rb +4 -1
- 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: a6739f4800b9a3cc9495c5dabbd0d7a7dee83aee
|
4
|
+
data.tar.gz: 83883b8338894312e846f2e0ead3498c4db42be6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4a3af056017df304504f1fdabbad96a5a64b35db88a4fd2a5e986c5b80e3db51e659152ca600824db652d17e1fd82346a1a9a7a16e658fb7412b7e84d395dec
|
7
|
+
data.tar.gz: bf14e1e6de3402d513f5ac5f000809440ebcda4ff3fcb7b8a6aa0899c3dd9fa7e5a1da1624eca60deed8ceeea341bd60f114f0902d5abb67a41767803918bb6b
|
data/lib/apiotics/hardware.rb
CHANGED
@@ -455,35 +455,49 @@ module Apiotics
|
|
455
455
|
download_directory = Apiotics::Hardware.check_sd_card_scripts
|
456
456
|
if download_directory != nil
|
457
457
|
image_path = Apiotics::Hardware.get_sd_image(download_directory, worker_name, config)
|
458
|
-
|
459
|
-
if
|
458
|
+
image_size = Apiotics::Portal.get_image_size(worker_name)
|
459
|
+
if File.size(image_path) == image_size.to_i
|
460
|
+
wifi_settings = Apiotics::Hardware.fetch_wifi
|
461
|
+
if wifi_settings == nil
|
462
|
+
wifi_settings = {
|
463
|
+
"ssid" => "NONE",
|
464
|
+
"password" => "NONE",
|
465
|
+
"security_mode" => "NONE"
|
466
|
+
}
|
467
|
+
end
|
460
468
|
config_file_path = Apiotics::Hardware.sd_config_file(worker_name, name, download_directory)
|
461
469
|
cellular = ApioticsSetting.find_by(key: "cellular")
|
462
470
|
if cellular == nil
|
463
471
|
cellular = 0
|
464
472
|
else
|
465
473
|
cellular = cellular.value
|
466
|
-
end
|
474
|
+
end
|
467
475
|
Apiotics::Hardware.brand_and_burn_sd_image(download_directory, image_path, wifi_settings, cellular, config_file_path)
|
468
476
|
else
|
469
|
-
puts "
|
477
|
+
puts "Error in download, file downloaded does not match file size on server. Please try running this command again."
|
478
|
+
File.delete(image_path)
|
470
479
|
end
|
471
480
|
else
|
472
481
|
puts "SD card installation scripts not available. Exiting."
|
473
482
|
end
|
483
|
+
|
474
484
|
end
|
475
485
|
|
476
486
|
def self.install(worker_name, name)
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
487
|
+
if ActiveRecord::Base.connection.table_exists? 'apiotics_settings'
|
488
|
+
config = Apiotics::Portal.openocd_worker_config(worker_name)
|
489
|
+
config = JSON.parse(config)
|
490
|
+
if config["installer"] == "Open OCD 0.10"
|
491
|
+
Hardware.openocd(worker_name, name, config)
|
492
|
+
elsif config["installer"] == "Uniflash 4.3.0"
|
493
|
+
Hardware.uniflash(worker_name, name, config)
|
494
|
+
elsif config["installer"] == "SD Card"
|
495
|
+
Hardware.sd_card(worker_name, name, config)
|
496
|
+
else
|
497
|
+
puts "Unknown installer for #{worker_name}. Please check the installer settings for the #{worker_name} device on the Apiotics portal.\n"
|
498
|
+
end
|
485
499
|
else
|
486
|
-
puts "
|
500
|
+
puts "Please run rails g apiotics:install before running this command."
|
487
501
|
end
|
488
502
|
end
|
489
503
|
|
data/lib/apiotics/portal.rb
CHANGED
@@ -296,6 +296,16 @@ module Apiotics
|
|
296
296
|
print "[#{fin}]\n"
|
297
297
|
end
|
298
298
|
|
299
|
+
def self.get_image_size(worker_name)
|
300
|
+
response = HTTParty.post("#{Apiotics.configuration.portal}api/image_size", :query => {:public_key => Apiotics.configuration.public_key, :private_key => Apiotics.configuration.private_key, :worker => worker_name}).body
|
301
|
+
response = JSON.parse(response)
|
302
|
+
if response["size"] != nil
|
303
|
+
response["size"]
|
304
|
+
else
|
305
|
+
nil
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
299
309
|
def self.register_client
|
300
310
|
response = HTTParty.post("#{Apiotics.configuration.portal}api/register_client", :query => {:public_key => Apiotics.configuration.public_key, :private_key => Apiotics.configuration.private_key}).body
|
301
311
|
hash = JSON.parse(response)
|
data/lib/apiotics/version.rb
CHANGED
@@ -11,8 +11,11 @@ module Apiotics
|
|
11
11
|
template "apiotics_parents.rb.erb", "config/initializers/apiotics_parents.rb"
|
12
12
|
else
|
13
13
|
template "apiotics.rb.erb", "config/initializers/apiotics.rb"
|
14
|
-
template "apiotics_settings.rb.erb", "db/migrate/#{date_string}_create_apiotics_settings.rb"
|
15
14
|
template "setting.rb.erb", "app/models/apiotics_setting.rb"
|
15
|
+
unless ActiveRecord::Base.connection.table_exists? 'apiotics_settings'
|
16
|
+
template "apiotics_settings.rb.erb", "db/migrate/#{date_string}_create_apiotics_settings.rb"
|
17
|
+
rake 'db:migrate'
|
18
|
+
end
|
16
19
|
#template "apiotics_module.rb.erb", "app/models/apiotics.rb"
|
17
20
|
end
|
18
21
|
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.2.
|
4
|
+
version: 0.2.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MicroArx Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
268
|
version: '0'
|
269
269
|
requirements: []
|
270
270
|
rubyforge_project:
|
271
|
-
rubygems_version: 2.
|
271
|
+
rubygems_version: 2.6.10
|
272
272
|
signing_key:
|
273
273
|
specification_version: 4
|
274
274
|
summary: IoT For Everybody.
|