apiotics 0.2.17 → 0.2.18
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 +27 -5
- data/lib/apiotics/version.rb +1 -1
- data/lib/generators/apiotics/script/templates/set_cellular.rake +11 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2f43e23f801f7fd9a12d4b00943f2d59187fa81
|
4
|
+
data.tar.gz: c45d244b79996a9b58ce7d23b249cea04f68e2d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8be30ae215a4d55d0034111979eb08678e60fee5053994b1d9475ac3b5e087cfb3284b75278fb02847b5da1ffcd2828b05f33daa4756e8760ed605f34510d099
|
7
|
+
data.tar.gz: f795386b8fa7baa1cb605666d84d4f596295ad29f2d27320d73c6c76f75810d65b70a6995a43c051ecd0e6113b366d137121672048d6e905263e2f51a22315a5
|
data/lib/apiotics/hardware.rb
CHANGED
@@ -251,6 +251,22 @@ module Apiotics
|
|
251
251
|
File.delete(path)
|
252
252
|
end
|
253
253
|
|
254
|
+
def self.cellular(state)
|
255
|
+
current_state = ApioticsSetting.find_by(key: "cellular")
|
256
|
+
if current_state == nil
|
257
|
+
current_state = ApioticsSetting.new
|
258
|
+
current_state.key = "cellular"
|
259
|
+
end
|
260
|
+
if state == "on"
|
261
|
+
state = 1
|
262
|
+
else
|
263
|
+
state = 0
|
264
|
+
end
|
265
|
+
|
266
|
+
current_state.value = state
|
267
|
+
current_state.save
|
268
|
+
end
|
269
|
+
|
254
270
|
def self.write_uniflash_image(uniflash_path, config)
|
255
271
|
puts "Writing uniflash firmware image...\n"
|
256
272
|
string = "#{uniflash_path} --mode #{config["openocd_config_file_name"]} image program --file #{config['firmware_file_name'].split(".")[0]}.sli"
|
@@ -386,7 +402,7 @@ module Apiotics
|
|
386
402
|
config_file_path
|
387
403
|
end
|
388
404
|
|
389
|
-
def self.brand_and_burn_sd_image(download_directory, image_path, wifi_settings, config_file_path)
|
405
|
+
def self.brand_and_burn_sd_image(download_directory, image_path, wifi_settings, cellular, config_file_path)
|
390
406
|
status = false
|
391
407
|
Dir.chdir download_directory
|
392
408
|
script_path = nil
|
@@ -397,8 +413,8 @@ module Apiotics
|
|
397
413
|
end
|
398
414
|
if script_path != nil
|
399
415
|
#puts "Please wait..."
|
400
|
-
puts "Running sudo -S #{script_path} brand_and_burn #{image_path} no_disk #{wifi_settings["ssid"]} #{wifi_settings["password"]} #{wifi_settings["security_mode"]} #{config_file_path} 0 dhcp"
|
401
|
-
IO.popen("sudo -S #{script_path} brand_and_burn #{image_path} no_disk #{wifi_settings["ssid"]} #{wifi_settings["password"]} #{wifi_settings["security_mode"]} #{config_file_path} 0 dhcp") do |io|
|
416
|
+
puts "Running sudo -S #{script_path} brand_and_burn #{image_path} no_disk #{wifi_settings["ssid"]} #{wifi_settings["password"]} #{wifi_settings["security_mode"]} #{config_file_path} 0 #{cellular.to_s} dhcp"
|
417
|
+
IO.popen("sudo -S #{script_path} brand_and_burn #{image_path} no_disk #{wifi_settings["ssid"]} #{wifi_settings["password"]} #{wifi_settings["security_mode"]} #{config_file_path} 0 #{cellular.to_s} dhcp") do |io|
|
402
418
|
while (line = io.gets) do
|
403
419
|
puts line
|
404
420
|
end
|
@@ -442,9 +458,15 @@ module Apiotics
|
|
442
458
|
wifi_settings = Apiotics::Hardware.fetch_wifi
|
443
459
|
if wifi_settings != nil
|
444
460
|
config_file_path = Apiotics::Hardware.sd_config_file(worker_name, name, download_directory)
|
445
|
-
|
461
|
+
cellular = ApioticsSettings.find_by(key: "cellular")
|
462
|
+
if cellular == nil
|
463
|
+
cellular = 0
|
464
|
+
else
|
465
|
+
cellular = cellular.value
|
466
|
+
end
|
467
|
+
Apiotics::Hardware.brand_and_burn_sd_image(download_directory, image_path, wifi_settings, cellular, config_file_path)
|
446
468
|
else
|
447
|
-
puts "No WiFi settings found. Please run rake firmware:wifi[ssid,password,security_mode] to set your default wifi settings"
|
469
|
+
puts "No WiFi settings found. Please run rake firmware:wifi[ssid,password,security_mode] to set your default wifi settings. If you do not intend to use WiFi, set all arguments to NONE."
|
448
470
|
end
|
449
471
|
else
|
450
472
|
puts "SD card installation scripts not available. Exiting."
|
data/lib/apiotics/version.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
namespace :firmware do
|
2
|
+
desc "Turn cellular connectivity on or off for a device. Turning cellular on is rake firmware:cellular[on]. Turning it off is rake firmware:cellular[off]."
|
3
|
+
task :cellular, [:state] => [:environment] do |task, args|
|
4
|
+
states = ["on", "off"]
|
5
|
+
unless states.include?(args[:state])
|
6
|
+
puts "#{args[:state]} is not a supported option. The supported options are: #{states.to_s}"
|
7
|
+
else
|
8
|
+
Apiotics::Hardware.cellular(args[:state])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MicroArx Corporation
|
@@ -235,6 +235,7 @@ files:
|
|
235
235
|
- lib/generators/apiotics/script/templates/script.rb.erb
|
236
236
|
- lib/generators/apiotics/script/templates/server.rb
|
237
237
|
- lib/generators/apiotics/script/templates/server_control.rb
|
238
|
+
- lib/generators/apiotics/script/templates/set_cellular.rake
|
238
239
|
- lib/generators/apiotics/script/templates/set_wifi.rake
|
239
240
|
- lib/generators/apiotics/script/templates/test_comm_server.rake
|
240
241
|
- lib/generators/apiotics/script/templates/test_server.rb
|