imperituroard 1.1.8 → 1.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/runConfigurations/dabrab_proced.xml +21 -0
- data/.idea/runConfigurations/test9_dab.xml +21 -0
- data/imperituroard.gemspec +1 -1
- data/lib/.DS_Store +0 -0
- data/lib/imperituroard.rb +32 -5
- data/lib/imperituroard/.DS_Store +0 -0
- data/lib/imperituroard/add_functions/logger/any_functions.rb +4 -2
- data/lib/imperituroard/platforms/iwag/get_iwag_data.rb +90 -0
- data/lib/imperituroard/platforms/iwag/iwag_database_worker.rb +24 -0
- data/lib/imperituroard/platforms/iwag/iwag_telnet_connector.rb +112 -0
- data/lib/imperituroard/projects/iot.rb +1 -1
- data/lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb +25 -24
- data/lib/imperituroard/projects/iot/internal_functions.rb +5 -4
- data/lib/imperituroard/projects/mhub.rb +68 -14
- data/lib/imperituroard/projects/mhub/gms.rb +96 -0
- data/lib/imperituroard/projects/mhub/sk.rb +26 -18
- data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_platform.rb +5 -4
- data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb +141 -77
- data/lib/imperituroard/projects/mhub/subs/evrotorg/gms_connector.rb +69 -0
- data/lib/imperituroard/projects/wttx/updatepostcps.rb +7 -7
- data/lib/imperituroard/version.rb +1 -1
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f18b3b415b4abd99d7278bc85a36e106b4c7cd06
|
4
|
+
data.tar.gz: 1836cbde25b99638c57951d554e162177593bc6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d295fb8baa99e0c2a69009432af9bd7ce079826d335e1dbec712eaa997d27b86ac8bfbf5d9d625a78bc5ac5b4bc83a9b866076039dba45b9791f1a3a739e411
|
7
|
+
data.tar.gz: 6f849cca851ed66cf4fe2c63bc3fd724066f086aef44a6fd744868b3431dccbc78ee67542eac4ced9189f23fe750b76bf120dd8f558d97a7cd83777070031a70
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
2
|
+
<configuration default="false" name="dabrab_proced" type="RubyRunConfigurationType" factoryName="Ruby">
|
3
|
+
<module name="imperituroard" />
|
4
|
+
<RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
5
|
+
<RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/lib/imperituroard/projects/mhub/subs/dabrab" />
|
6
|
+
<RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
|
7
|
+
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
|
8
|
+
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
|
9
|
+
<envs />
|
10
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
11
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
12
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
13
|
+
<COVERAGE_PATTERN ENABLED="true">
|
14
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
15
|
+
</COVERAGE_PATTERN>
|
16
|
+
</EXTENSION>
|
17
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb" />
|
18
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
|
19
|
+
<method />
|
20
|
+
</configuration>
|
21
|
+
</component>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
2
|
+
<configuration default="false" name="test9_dab" type="RubyRunConfigurationType" factoryName="Ruby">
|
3
|
+
<module name="imperituroard" />
|
4
|
+
<RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
5
|
+
<RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/test" />
|
6
|
+
<RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
|
7
|
+
<RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
|
8
|
+
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
|
9
|
+
<envs />
|
10
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
11
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
12
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
13
|
+
<COVERAGE_PATTERN ENABLED="true">
|
14
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
15
|
+
</COVERAGE_PATTERN>
|
16
|
+
</EXTENSION>
|
17
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/test/test9_dab.rb" />
|
18
|
+
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
|
19
|
+
<method />
|
20
|
+
</configuration>
|
21
|
+
</component>
|
data/imperituroard.gemspec
CHANGED
data/lib/.DS_Store
CHANGED
Binary file
|
data/lib/imperituroard.rb
CHANGED
@@ -25,6 +25,7 @@ require 'imperituroard/projects/dns'
|
|
25
25
|
require 'imperituroard/platforms/cps/qps_connector'
|
26
26
|
require 'imperituroard/platforms/public/telegram'
|
27
27
|
require 'imperituroard/projects/ukaz60'
|
28
|
+
require 'imperituroard/projects/mhub/gms'
|
28
29
|
|
29
30
|
require 'json'
|
30
31
|
require 'ipaddr'
|
@@ -310,19 +311,21 @@ class Mhub_2
|
|
310
311
|
:internal_func,
|
311
312
|
:dabrab_connecter,
|
312
313
|
:static_callback,
|
313
|
-
:crm_connector
|
314
|
+
:crm_connector,
|
315
|
+
:log_level
|
314
316
|
|
315
|
-
def initialize(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password, sms_alphaname)
|
317
|
+
def initialize(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password, sms_alphaname, log_level="error")
|
316
318
|
@sk_url = sk_url_simple
|
317
319
|
@sk_login = sk_login
|
318
320
|
@sk_password = sk_password
|
321
|
+
@log_level = log_level
|
319
322
|
@internal_func = InternalFunc.new
|
320
|
-
@mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id)
|
323
|
+
@mhub_connector = Sksk_2.new(sk_url_simple, sk_login, sk_password, sk_url_broadcast, telegram_api_url, telegram_chat_id, log_level)
|
321
324
|
@internal_func = InternalFunc.new
|
322
325
|
@dabrab_connecter = Dabrab.new
|
323
326
|
@static_callback = static_callback
|
324
|
-
@crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id)
|
325
|
-
@mhub_connector = MhubFunctions_2.new(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password, sms_alphaname)
|
327
|
+
@crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id, log_level)
|
328
|
+
@mhub_connector = MhubFunctions_2.new(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password, sms_alphaname, log_level)
|
326
329
|
end
|
327
330
|
|
328
331
|
#{"destinations"=>[{"to"=>{"phoneNumber"=>"375297116638", "emailAddress"=>nil}}],
|
@@ -338,6 +341,10 @@ class Mhub_2
|
|
338
341
|
mhub_connector.get_send_message_2(params, ip_src, ip_real, ip_vip)
|
339
342
|
end
|
340
343
|
|
344
|
+
def get_send_message_mass(params, ip_src, ip_real, ip_vip, slice_number=100, time_pause_minutes=5)
|
345
|
+
mhub_connector.get_send_message_mass_2(params, ip_src, ip_real, ip_vip, slice_number, time_pause_minutes)
|
346
|
+
end
|
347
|
+
|
341
348
|
def recieve_delivery_report(params, ip_src, ip_real, ip_vip)
|
342
349
|
mhub_connector.rec_deliv_report_2(params, ip_src, ip_real, ip_vip)
|
343
350
|
end
|
@@ -345,6 +352,26 @@ class Mhub_2
|
|
345
352
|
end
|
346
353
|
|
347
354
|
|
355
|
+
#2020.09.02 function for some procedure for get message status
|
356
|
+
class GmsFunctions_2
|
357
|
+
|
358
|
+
attr_accessor :gms_func
|
359
|
+
|
360
|
+
def initialize(gms_t_login, gms_t_password, gms_r_login, gms_r_password, telegram_api_url, telegram_chat_id)
|
361
|
+
@gms_func = Gmsgms_2.new(gms_t_login, gms_t_password, gms_r_login, gms_r_password, telegram_api_url, telegram_chat_id)
|
362
|
+
end
|
363
|
+
|
364
|
+
def get_t_status_external(external_id)
|
365
|
+
gms_func.get_t_status_external_2(external_id)
|
366
|
+
end
|
367
|
+
|
368
|
+
def get_r_status_external(external_id)
|
369
|
+
gms_func.get_r_status_external_2(external_id)
|
370
|
+
end
|
371
|
+
|
372
|
+
end
|
373
|
+
|
374
|
+
|
348
375
|
class CpsFunctions_2
|
349
376
|
|
350
377
|
attr_accessor :qps_connector
|
data/lib/imperituroard/.DS_Store
CHANGED
Binary file
|
@@ -14,8 +14,10 @@ class LogAddFunctions_2
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def printer_texter(text, log_level)
|
17
|
-
|
18
|
-
|
17
|
+
if log_level == debug
|
18
|
+
mess = {:datetime => datetimenow, :sdk => "imperituroard", :sdk_version => Imperituroard::VERSION, :message => text}
|
19
|
+
p mess
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
23
|
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'net/ssh'
|
2
|
+
|
3
|
+
class IwagRequester
|
4
|
+
|
5
|
+
attr_accessor :iwag_host, :iwag_login, :iwag_password
|
6
|
+
|
7
|
+
def initialize(iwag_host, iwag_login, iwag_password)
|
8
|
+
@iwag_host = iwag_host
|
9
|
+
@iwag_login = iwag_login
|
10
|
+
@iwag_password = iwag_password
|
11
|
+
end
|
12
|
+
|
13
|
+
def mac_parse(mac)
|
14
|
+
a = mac.upcase
|
15
|
+
pos = a[0] + a[1]
|
16
|
+
if pos == "01"
|
17
|
+
subscribers_mac = a[2] + a[3] + ":" + a[5] + a[6] + ":" + a[7] + a[8] + ":" + a[10] + a[11] + ":" + a[12] + a[13] + ":" + a[15] + a[16]
|
18
|
+
else
|
19
|
+
subscribers_mac = a[0] + a[1] + ":" + a[2] + a[3] + ":" + a[5] + a[6] + ":" + a[7] + a[8] + ":" + a[10] + a[11] + ":" + a[12] + a[13]
|
20
|
+
end
|
21
|
+
subscribers_mac
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def iwag_get_dhcp_binding_ssh(bind_ip)
|
26
|
+
mac = "Unknown"
|
27
|
+
accessinterface = "Unknown"
|
28
|
+
hostname = "Unknown"
|
29
|
+
ssid = "Unknown"
|
30
|
+
iwag_thr = Thread.new do
|
31
|
+
Net::SSH.start(iwag_host, iwag_login, :password => iwag_password) do |session|
|
32
|
+
answ_bind = session.exec!("show ip dhcp binding #{bind_ip}")
|
33
|
+
regexp_main = /\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s{1,20}(\w{2,4}.\w{2,4}.\w{2,4}.\w{2,4})|\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s{1,20}(\w{4}.\w{4}.\w{4})/
|
34
|
+
#regexp_main = /\r\n(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s+(\S{13,18})\s+Sep 18 2020 07:44 PM\s+Automatic\s+Active\s+Tunnel201\r\n/
|
35
|
+
ggg7 = answ_bind.match(regexp_main)
|
36
|
+
begin
|
37
|
+
if ggg7[1] != nil
|
38
|
+
mac = mac_parse(ggg7[1])
|
39
|
+
else
|
40
|
+
mac = mac_parse(ggg7[2])
|
41
|
+
end
|
42
|
+
rescue
|
43
|
+
mac = "Unknown"
|
44
|
+
end
|
45
|
+
regexp_remote_id = /Remote id :\s(\S{2,100})/
|
46
|
+
regexp_tunnel = /Active\s{2,40}(\S{2,40})|Selecting\s{2,40}(\S{2,40})/
|
47
|
+
regexp_curcuit_id = /Circuit id :\s(\S{2,100})/
|
48
|
+
ggg9 = answ_bind.match(regexp_tunnel)
|
49
|
+
|
50
|
+
begin
|
51
|
+
if ggg9[1] != nil
|
52
|
+
accessinterface = ggg9[1]
|
53
|
+
else
|
54
|
+
accessinterface = ggg9[2]
|
55
|
+
end
|
56
|
+
rescue
|
57
|
+
accessinterface = "Unknown"
|
58
|
+
end
|
59
|
+
ggg8 = answ_bind.match(regexp_remote_id)
|
60
|
+
ggg10 = answ_bind.match(regexp_curcuit_id)
|
61
|
+
begin
|
62
|
+
a1 = ggg8[1].split(":")
|
63
|
+
hostname = a1[0]
|
64
|
+
ssid = a1[1]
|
65
|
+
rescue
|
66
|
+
begin
|
67
|
+
if ggg8[1] != nil
|
68
|
+
if ggg8[1].include?("wireless_public_interface")
|
69
|
+
hostname = ggg10[1]
|
70
|
+
ssid = "Unknown"
|
71
|
+
else
|
72
|
+
hostname = ggg8[1]
|
73
|
+
ssid = "Unknown"
|
74
|
+
end
|
75
|
+
else
|
76
|
+
ssid = "Unknown"
|
77
|
+
hostname = "Unknown"
|
78
|
+
end
|
79
|
+
rescue
|
80
|
+
ssid = "Unknown"
|
81
|
+
hostname = "Unknown"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
iwag_thr.join
|
87
|
+
{"mac": mac, "iwaginterface": accessinterface, "aphostname": hostname, "SSID": ssid}
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
class IwagDbCache
|
4
|
+
|
5
|
+
attr_accessor :db_host, :db_login, :db_password
|
6
|
+
|
7
|
+
def initialize(db_host, db_login, db_password)
|
8
|
+
@db_host = db_host
|
9
|
+
@db_login = db_login
|
10
|
+
@db_password = db_password
|
11
|
+
end
|
12
|
+
|
13
|
+
def check_db_exists(ip)
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def insert_new_cache()
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'net-telnet'
|
2
|
+
require 'net/ssh'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
class CSRtelnet_1
|
6
|
+
|
7
|
+
attr_accessor :iwag1_host, :iwag_username, :iwag_password
|
8
|
+
|
9
|
+
def initialize(iwag1_host, iwag_username, iwag_password)
|
10
|
+
@iwag1_host = iwag1_host
|
11
|
+
@iwag_username = iwag_username
|
12
|
+
@iwag_password = iwag_password
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_subs_mac2_1(ipaddress)
|
16
|
+
|
17
|
+
subscribers_mac = ""
|
18
|
+
|
19
|
+
#begin
|
20
|
+
|
21
|
+
dump =""
|
22
|
+
connection = Net::Telnet.new( "Host" => iwag1_host, "Timeout" => false, "Prompt" => /.*\#/ ) { |str| }
|
23
|
+
connection.login({ "Name" => iwag_username, "Password" => iwag_password, "LoginPrompt" => /Username:/ }) { |str| }
|
24
|
+
connection.cmd("show ip dhcp binding #{ipaddress}") {
|
25
|
+
|c|
|
26
|
+
p c
|
27
|
+
dump << c
|
28
|
+
}
|
29
|
+
connection.close
|
30
|
+
as = dump.split("\n")
|
31
|
+
p as
|
32
|
+
reer = as[4].split(" ")
|
33
|
+
|
34
|
+
ma = reer[1].to_s.upcase
|
35
|
+
pos = ma[0]+ma[1]
|
36
|
+
if pos=="01"
|
37
|
+
subscribers_mac = ma[2]+ma[3]+":"+ma[5]+ma[6]+":"+ma[7]+ma[8]+":"+ma[10]+ma[11]+":"+ma[12]+ma[13]+":"+ma[15]+ma[16]
|
38
|
+
else
|
39
|
+
subscribers_mac = ma[0]+ma[1]+":"+ma[2]+ma[3]+":"+ma[5]+ma[6]+":"+ma[7]+ma[8]+":"+ma[10]+ma[11]+":"+ma[12]+ma[13]
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
#rescue
|
44
|
+
# subscribers_mac = "unknown"
|
45
|
+
#end
|
46
|
+
|
47
|
+
return subscribers_mac
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
#test function. Not used
|
53
|
+
def get_iwag_info_ssh_1(ipaddress)
|
54
|
+
p DateTime.now
|
55
|
+
Net::SSH.start(iwag1_host, iwag_username, :password => iwag_password) do |ssh|
|
56
|
+
result = ssh.exec!("show ip dhcp binding #{ipaddress}\n")
|
57
|
+
p result
|
58
|
+
end
|
59
|
+
p DateTime.now
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
def return_iwag_access_interface_1(ipaddress)
|
65
|
+
host_iwag = iwag1_host
|
66
|
+
username_iwag = iwag_username
|
67
|
+
password_iwag = iwag_password
|
68
|
+
answer =""
|
69
|
+
|
70
|
+
dump =""
|
71
|
+
begin
|
72
|
+
connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*\#/) {|str| print str}
|
73
|
+
connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
|
74
|
+
connection.cmd("show ip dhcp binding #{ipaddress}") {
|
75
|
+
|c|
|
76
|
+
dump << c
|
77
|
+
}
|
78
|
+
connection.close
|
79
|
+
as = dump.split("\n")
|
80
|
+
|
81
|
+
if as[4] != nil && as[3] != ""
|
82
|
+
access_interface = as[4].gsub!(" ", "").split(" ").last
|
83
|
+
return access_interface
|
84
|
+
else
|
85
|
+
answer ="false"
|
86
|
+
return answer
|
87
|
+
end
|
88
|
+
rescue
|
89
|
+
begin
|
90
|
+
connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*\#/) {|str| print str}
|
91
|
+
connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
|
92
|
+
connection.cmd("show ip dhcp binding #{ipaddress}") {
|
93
|
+
|c|
|
94
|
+
dump << c
|
95
|
+
}
|
96
|
+
connection.close
|
97
|
+
as = dump.split("\n")
|
98
|
+
if as[4] != nil && as[3] != ""
|
99
|
+
access_interface = as[4].gsub!(" ", "").split(" ").last
|
100
|
+
return access_interface
|
101
|
+
else
|
102
|
+
answer ="false"
|
103
|
+
return answer
|
104
|
+
end
|
105
|
+
rescue
|
106
|
+
return "unknown"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
end
|
@@ -1427,6 +1427,6 @@ class IotFunctions_2
|
|
1427
1427
|
p "yyyyy"
|
1428
1428
|
|
1429
1429
|
#fff = HuaIot.new("134.17.93.4", "443", "/Users/imperituroard/Desktop/cert.crt", "/Users/imperituroard/Desktop/key.pem")
|
1430
|
-
p hua_aceanconnect_connector.querying_device_id("Jy5KpoBUOScZEcrO2bRZhzfaIOUa", "VFFWTOb9k3_cQhzrGsRWT4HE8Z0a", "
|
1430
|
+
p hua_aceanconnect_connector.querying_device_id("Jy5KpoBUOScZEcrO2bRZhzfaIOUa", "VFFWTOb9k3_cQhzrGsRWT4HE8Z0a", "123412341284999")
|
1431
1431
|
end
|
1432
1432
|
end
|
@@ -82,6 +82,7 @@ class HuaIot
|
|
82
82
|
request.content_type = 'application/x-www-form-urlencoded'
|
83
83
|
request.body = URI.encode_www_form(data)
|
84
84
|
res = https.request(request)
|
85
|
+
p "get_token"
|
85
86
|
p res.code
|
86
87
|
p res.message
|
87
88
|
p res.body.to_s
|
@@ -293,30 +294,30 @@ class HuaIot
|
|
293
294
|
|
294
295
|
#2.2.44 Querying the Device ID
|
295
296
|
def querying_device_id(app_id, secret, node_id)
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
297
|
+
get_token_data = get_token(app_id, secret)
|
298
|
+
if get_token_data[:code]=="200"
|
299
|
+
token = get_token_data[:body]["accessToken"]
|
300
|
+
uri1 = URI("https://134.17.93.4:8743/iocm/app/dm/v1.1.0/queryDeviceIdByNodeId?nodeId=" + node_id + "&" + app_id)
|
301
|
+
https = Net::HTTP.new(uri1.host, uri1.port)
|
302
|
+
https.use_ssl = true
|
303
|
+
https.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
|
304
|
+
https.key = OpenSSL::PKey::RSA.new(File.read(key_file))
|
305
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
306
|
+
request = Net::HTTP::Get.new(uri1)
|
307
|
+
request.content_type = 'application/json'
|
308
|
+
request['app_key'] = app_id
|
309
|
+
request['Authorization'] = 'Bearer ' + token
|
310
|
+
#request.set_form_data( params )
|
311
|
+
#request['node-id'] = node_id
|
312
|
+
bbb = {"nodeId": node_id, "appId": "Jy5KpoBUOScZEcrO2bRZhzfaIOUa"}.to_json
|
313
|
+
#request.body = bbb
|
314
|
+
res = https.request(request)
|
315
|
+
#p res.body.to_s
|
316
|
+
#p res.code
|
317
|
+
{:code => res.code, :message => res.message, :body => valid_json?(res.body.to_s)}
|
318
|
+
else
|
319
|
+
{:code => "500", :message => "Something wrong", :body => {}}
|
320
|
+
end
|
320
321
|
end
|
321
322
|
|
322
323
|
#2.2.14 Querying Device Activation Status
|