imperituroard 1.0.3 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5264f8d3d00a73980d4de22a91b93c49ccd65904
4
- data.tar.gz: a165a821f4ea118ca20916f6ca512aa4d1f4b173
3
+ metadata.gz: 9c8f6bbfe4c5e01a964045775d36b13741596323
4
+ data.tar.gz: 310767c96c24eaba6b79bd68ea5deea2040f6df3
5
5
  SHA512:
6
- metadata.gz: e8d44ca288a3ebadc98ebd0ad7844e781c1ca3085c4df144113f9cd61a349915f71565daeeaa460437d4b6da545a40f7577c488bc7f4f6ca09230dafacc535b1
7
- data.tar.gz: 1161e315402988d67d08cb63d0c7660412a24d2826172e5d23c38f81d1fa876c84cfef2f56b83754a7f8ff3cbc1d45e2cdd1415b6cc96abb8c8a9a8a5c15739f
6
+ metadata.gz: a11a03525f557e5c371b66826dc040c3eeaaf991697bf292c565b5f9f2431b568764765a4b1add9bbdbcdd3a5187f035c0f3790b13703d99dbd552d701b764a4
7
+ data.tar.gz: 83ab21b87e290534e833043230524fbef8b1fa1def3112c80b6e3046b21dd1ce180651f99d31626780ff89803f7f52434e24451b174e49470898cbfa5d253971
@@ -0,0 +1,21 @@
1
+ <component name="ProjectRunConfigurationManager">
2
+ <configuration default="false" name="version" 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" />
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/version.rb" />
18
+ <RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
19
+ <method />
20
+ </configuration>
21
+ </component>
@@ -33,6 +33,7 @@ require 'net/http'
33
33
  require 'uri'
34
34
 
35
35
  module Imperituroard
36
+
36
37
  class Error < StandardError;
37
38
  end
38
39
 
@@ -42,6 +43,7 @@ module Imperituroard
42
43
  def hhh(jjj)
43
44
  p jjj
44
45
  end
46
+
45
47
  # Your code goes here...
46
48
  end
47
49
 
@@ -239,6 +241,11 @@ class Iot
239
241
  iot_connector.get_available_types_2(login, real_ip, remote_ip)
240
242
  end
241
243
 
244
+ #9-1 get available types for login and profile
245
+ def get_available_types2(login, profile, real_ip, remote_ip)
246
+ iot_connector.get_available_types2_2(login, profile, real_ip, remote_ip)
247
+ end
248
+
242
249
  #10 get info for device type
243
250
  def get_info_data_type(type, real_ip, remote_ip)
244
251
  iot_connector.get_info_data_type_2(type, real_ip, remote_ip)
@@ -115,10 +115,9 @@ class IotFunctions_2
115
115
  end
116
116
  end
117
117
 
118
-
119
118
  begin
120
119
  added_on_iot_platf = []
121
- if for_insert!=[]
120
+ if for_insert != []
122
121
  ##Logic for IOT Platform connection###
123
122
 
124
123
 
@@ -132,16 +131,22 @@ class IotFunctions_2
132
131
 
133
132
  #########
134
133
 
134
+ if aaa.key?("type") && !aaa.key?("device_type")
135
+ aaa["device_type"] = aaa["type"]
136
+ elsif aaa.key?("device_type") && !aaa.key?("type")
137
+ aaa["type"] = aaa["device_type"]
138
+ end
135
139
 
136
140
  if credentials[:code] == 200
137
141
 
138
-
139
142
  begin
140
143
  dev_name = aaa["imei"].to_s
141
144
 
142
145
  #get {"model"=>"BGT_PPMC", "ManufacturerID"=>"unknown", "ManufacturerNAME"=>"unknown", "device_type"=>"unknown"}
143
146
  #from database
144
- model_data = mongo_client.get_device_type_info_by_model(aaa["device_type"])
147
+ model_data = mongo_client.get_device_type_info_universal(aaa["device_type"])
148
+ p model_data
149
+ p "model_data"
145
150
  resss = hua_aceanconnect_connector.add_new_device_on_huawei(credentials[:body][:app_id],
146
151
  credentials[:body][:secret],
147
152
  aaa["imei"],
@@ -154,7 +159,6 @@ class IotFunctions_2
154
159
  model_data[:body]["model"]
155
160
  )
156
161
  if resss[:code]=="200"
157
-
158
162
  if resss[:body].key?("error_code") && resss[:body]["error_code"] != 200
159
163
  not_processed_list.append({:imei => aaa["imei"], :error => resss})
160
164
  else
@@ -163,15 +167,12 @@ class IotFunctions_2
163
167
  s1[:created] = DateTime.now
164
168
  added_on_iot_platf.append(s1)
165
169
  end
166
-
167
170
  else
168
171
  not_processed_list.append({:imei => aaa["imei"], :error => resss})
169
172
  end
170
173
  rescue
171
174
  not_processed_list.append({:imei => aaa["imei"], :error => "Unknown error with insertion imei on IOT platform"})
172
175
  end
173
-
174
-
175
176
  #########end iot platform logic#######
176
177
 
177
178
  else
@@ -187,16 +188,12 @@ class IotFunctions_2
187
188
  else
188
189
  resp_out = {:code => 202, :result => "Empty list. Nothing for insertion", :body => {:imei_processed => added_on_iot_platf, :error_list => not_processed_list}}
189
190
  end
190
-
191
-
192
191
  else
193
192
  resp_out = {:code => 202, :result => "Nothing for insertion", :body => {:imei_processed => added_on_iot_platf, :error_list => not_processed_list}}
194
-
195
193
  end
196
194
  rescue
197
195
  resp_out = {:code => 505, :result => "Error with database communication"}
198
196
  end
199
-
200
197
  else
201
198
  resp_out = {:code => 509, :result => "Input data invalid"}
202
199
  end
@@ -206,9 +203,7 @@ class IotFunctions_2
206
203
  end
207
204
  thr1.join
208
205
 
209
-
210
206
  resp_out[:body][:tosoapgw] = internal_func.iot_create_dev_soapgw_answer(input_json, resp_out)
211
-
212
207
  mongo_client.audit_logger("add_device_to_profile", remote_ip, input_json, resp_out, real_ip)
213
208
  resp_out
214
209
  end
@@ -228,16 +223,16 @@ class IotFunctions_2
228
223
  resp_out = {}
229
224
  begin
230
225
  thr2 = Thread.new do
231
- if add_functions_connector.check_input_2(login, imei_list)[:code]==200
226
+ if add_functions_connector.check_input_2(login, imei_list)[:code] == 200
232
227
 
233
228
  for t in imei_list
234
229
  prof_name1 = mongo_client.get_profile_name_from_imei(t)
235
- if prof_name1[:code]==200
230
+ if prof_name1[:code] == 200
236
231
  begin
237
232
  permiss1 = mongo_client.check_login_profile_permiss(login, prof_name1[:body]["profile"])
238
233
  p "permiss1"
239
234
  p permiss1
240
- if permiss1[:code]==200
235
+ if permiss1[:code] == 200
241
236
  ime_list_approved.append(t)
242
237
  else
243
238
  ime_list_notapproved.append({:imei => t, :error => permiss1})
@@ -467,12 +462,12 @@ class IotFunctions_2
467
462
  begin
468
463
  thr4 = Thread.new do
469
464
 
470
- if add_functions_connector.check_input_4(login, imei)[:code]==200
465
+ if add_functions_connector.check_input_4(login, imei)[:code] == 200
471
466
 
472
467
  prof_name = mongo_client.get_profile_name_from_imei(imei)
473
- if prof_name[:code]==200
468
+ if prof_name[:code] == 200
474
469
  permiss = mongo_client.check_login_profile_permiss(login, prof_name[:body]["profile"])
475
- if permiss[:code]==200
470
+ if permiss[:code] == 200
476
471
 
477
472
  ##Logic for IOT Platform connection###
478
473
 
@@ -486,17 +481,17 @@ class IotFunctions_2
486
481
 
487
482
  resp = {}
488
483
 
489
- if credentials[:code]==200
484
+ if credentials[:code] == 200
490
485
 
491
486
  imei_data = mongo_client.get_imei_info_from_db([imei])
492
- if imei_data[:body]!=[]
487
+ if imei_data[:body] != []
493
488
  ans = {}
494
489
  if imei_data[:body][0]["huadata"]["body"]["deviceId"] != nil
495
490
  ans = hua_aceanconnect_connector.remove_one_device_from_iot(credentials[:body][:app_id], credentials[:body][:secret], imei_data[:body][0]["huadata"]["body"]["deviceId"])
496
491
  else
497
492
  ans = {:code => "204", :result => "Not processed by iot platform. deviceId not found in mongoDB"}
498
493
  end
499
- if ans[:code]=="204" or ans[:code]=="200"
494
+ if ans[:code] == "204" or ans[:code] == "200"
500
495
  resp = mongo_client.device_remove_single_mongo(imei)
501
496
  else
502
497
  resp = {:code => 500, :result => "Unknown IOT platform error", :body => ans}
@@ -580,10 +575,8 @@ class IotFunctions_2
580
575
  imei_data = mongo_client.get_imei_info_from_db([p[:imei]])
581
576
  if imei_data[:body]!=[]
582
577
  ans = hua_aceanconnect_connector.modify_location_iot(credentials[:body][:app_id], credentials[:body][:secret], imei_data[:body][0]["huadata"]["body"]["deviceId"], p[:address])
583
-
584
578
  internal_func.printer_texter({:function => "device_add_address Step2", :ans => ans, :descrition => "answer from hua IOT", :input => {:did => imei_data[:body][0]["huadata"]["body"]["deviceId"], :appid => credentials[:body][:app_id], :secret => credentials[:body][:secret], :address => p[:address]}}, "debug")
585
579
  end
586
-
587
580
  end
588
581
 
589
582
  #########end iot platform logic#######
@@ -658,7 +651,7 @@ class IotFunctions_2
658
651
  if attr["profile"].is_a? Integer
659
652
  p "Ok"
660
653
  else
661
- p new = mongo_client.get_profile_id_by_name(attr["profile"])
654
+ p new = mongo_client.get_profile_universal(attr["profile"])
662
655
  attr["profile"] = new["profile_id"]
663
656
  end
664
657
  end
@@ -686,9 +679,7 @@ class IotFunctions_2
686
679
  else
687
680
  resp_out = {:code => 509, :result => "Input data invalid"}
688
681
  end
689
-
690
682
  end
691
-
692
683
  rescue
693
684
  resp_out = {:code => 507, :result => "Unknown SDK error"}
694
685
  end
@@ -745,6 +736,7 @@ class IotFunctions_2
745
736
  permit_profiles = login_info[:body]["permit_profiles"]
746
737
  permit_types = login_info[:body]["permit_types"]
747
738
  data_from_mongo = mongo_client.get_profile_list_by_id(permit_profiles)
739
+ p data_from_mongo
748
740
 
749
741
  for ff in data_from_mongo
750
742
  data_processed.append({:profile_id => ff["profile_id"],
@@ -849,33 +841,47 @@ class IotFunctions_2
849
841
  data_processed = []
850
842
  data_soapgw = []
851
843
  login_info = mongo_client.get_login_inf2_select(login)
844
+ prof_data = mongo_client.get_profile_universal(profile)
852
845
  if login_info[:code]==200
853
846
 
854
847
  permit_profiles = login_info[:body]["permit_profiles"]
855
848
  permit_types = login_info[:body]["permit_types"]
849
+ perm_tp_prof = prof_data["permit_types"]
850
+
851
+ if permit_profiles.include?(prof_data["profile_id"])
852
+ res_types_permitted = internal_func.compare_dict(permit_types, perm_tp_prof)
853
+ data_from_mongo = mongo_client.get_type_list_by_id(res_types_permitted)
854
+
855
+ for ff in data_from_mongo
856
+ data_processed.append({:type_id => ff["type_id"],
857
+ :description => ff["description"],
858
+ :note => ff["note"],
859
+ :form => ff["form"],
860
+ :ManufacturerID => ff["ManufacturerID"],
861
+ :ManufacturerNAME => ff["ManufacturerNAME"],
862
+ :device_type => ff["device_type"],
863
+ :model => ff["model"],
864
+ :info => ff["info"]
865
+ })
866
+ data_soapgw.append({:name => ff["model"], :form => ff["form"], :description => ff["description"], :type_id => ff["type_id"]})
867
+ end
856
868
 
857
- data_from_mongo = mongo_client.get_type_list_by_id(permit_types)
869
+ tosoapgw = {:code => 200,
870
+ :result => "Request completed successfully",
871
+ :types => data_soapgw
872
+ }
858
873
 
859
- for ff in data_from_mongo
860
- data_processed.append({:type_id => ff["type_id"],
861
- :description => ff["description"],
862
- :note => ff["note"],
863
- :form => ff["form"],
864
- :ManufacturerID => ff["ManufacturerID"],
865
- :ManufacturerNAME => ff["ManufacturerNAME"],
866
- :device_type => ff["device_type"],
867
- :model => ff["model"],
868
- :info => ff["info"]
869
- })
870
- data_soapgw.append({:name => ff["model"], :form => ff["form"], :description => ff["description"], :type_id => ff["type_id"]})
874
+ resp_out = {:code => 200, :result => "Request completed successfully", :body => {:data => data_processed, :tosoapgw => tosoapgw}}
875
+
876
+ else
877
+ tosoapgw = {:code => 700,
878
+ :result => "Profile not permitted",
879
+ :types => data_soapgw
880
+ }
881
+ resp_out = {:code => 700, :result => "Profile not permitted", :body => {:tosoapgw => tosoapgw}}
871
882
  end
872
883
 
873
- tosoapgw = {:code => 200,
874
- :result => "Request completed successfully",
875
- :types => data_soapgw
876
- }
877
884
 
878
- resp_out = {:code => 200, :result => "Request completed successfully", :body => {:data => data_processed, :tosoapgw => tosoapgw}}
879
885
  else
880
886
  tosoapgw = {:code => login_info[:code],
881
887
  :result => login_info[:result],
@@ -939,6 +945,8 @@ class IotFunctions_2
939
945
  mon_answer = mongo_client.get_profile_name_by_id(profile)
940
946
  end
941
947
 
948
+ p mon_answer
949
+
942
950
  if mon_answer != {} && mon_answer != []
943
951
  output_answ = {:code => 200, :result => "Request completed successfully", :body => {:data => {:info => mon_answer["info"],
944
952
  :profile => mon_answer["profile"],
@@ -952,7 +960,6 @@ class IotFunctions_2
952
960
  end
953
961
  mongo_client.audit_logger("get_info_data_profile_2", remote_ip, input_params, output_answ, real_ip)
954
962
  output_answ
955
-
956
963
  end
957
964
 
958
965
 
@@ -971,136 +978,162 @@ class IotFunctions_2
971
978
  inp_login = soapgw_params["autorization"]["login"]
972
979
  inp_dev_list = soapgw_params["datalist"]
973
980
 
974
- inp_dev_list.each do |curr_dev|
975
- begin
976
- if curr_dev["imei"] != [] && curr_dev["imei"] != nil && curr_dev["imei"] != ""
977
- list_checked = mongo_client.check_imei_exists([curr_dev["imei"].to_i])
978
- if list_checked[:code] == 200 && list_checked[:body][:exists] != [] && list_checked[:body][:not_exists] == []
979
-
980
- #step1 checking permission for writing for imei list
981
- prof_name1 = mongo_client.get_profile_name_from_imei(curr_dev["imei"].to_i)
982
- if prof_name1[:code] == 200
983
-
984
- if curr_dev["new_profile"] != "nil" && curr_dev["new_profile"] != "null" && curr_dev["new_profile"] != "empty"
985
- prof_new_id = mongo_client.get_profile_universal(curr_dev["new_profile"])["profile_id"]
986
- else
987
- prof_new_id = prof_name1[:body]["profile_id"]
988
- end
989
-
990
-
991
- if curr_dev["new_type"] != "nil" && curr_dev["new_type"] != "null" && curr_dev["new_type"] != "empty"
992
- type_new_pr = curr_dev["new_type"]
993
- else
994
- type_new_pr = prof_name1[:imei_info][:body][0]["device_type"]
995
- end
996
-
981
+ thr13set = Thread.new do
982
+ inp_dev_list.each do |curr_dev|
983
+ begin
984
+ if curr_dev["imei"] != [] && curr_dev["imei"] != nil && curr_dev["imei"] != ""
985
+ list_checked = mongo_client.check_imei_exists([curr_dev["imei"].to_i])
986
+ if list_checked[:code] == 200 && list_checked[:body][:exists] != [] && list_checked[:body][:not_exists] == []
987
+
988
+ #step1 checking permission for writing for imei list
989
+ prof_name1 = mongo_client.get_profile_name_from_imei(curr_dev["imei"].to_i)
990
+ p prof_name1
991
+ p "prof_name1"
992
+ if prof_name1[:code] == 200
993
+
994
+ if curr_dev["new_profile"] != "nil" && curr_dev["new_profile"] != "null" && curr_dev["new_profile"] != "empty" && curr_dev["new_profile"] != "nill"
995
+ prof_new_id = mongo_client.get_profile_universal(curr_dev["new_profile"])["profile_id"]
996
+ else
997
+ prof_new_id = prof_name1[:body]["profile_id"]
998
+ end
997
999
 
998
- get_login_info = mongo_client.check_login_prof_perm_id_one(inp_login, prof_name1[:body]["profile_id"])
999
- if get_login_info[:code] == 200
1000
- get_login_info_new = mongo_client.check_login_prof_perm_id_one(inp_login, prof_new_id)
1001
- if get_login_info_new[:code] == 200
1002
- cur_comp1 = mongo_client.compare_profiles(prof_name1[:body]["profile_id"], prof_new_id)
1003
- cur_comp2 = mongo_client.compare_device_types(prof_name1[:imei_info][:body][0]["device_type"], type_new_pr)
1000
+ if curr_dev["new_type"] != "nil" && curr_dev["new_type"] != "null" && curr_dev["new_type"] != "empty" && curr_dev["new_type"] != "nill"
1001
+ type_new_pr = curr_dev["new_type"]
1002
+ else
1003
+ type_new_pr = prof_name1[:imei_info][:body][0]["device_type"]
1004
+ end
1004
1005
 
1005
- if cur_comp1[:is_the_same] && cur_comp2[:is_the_same]
1006
- #the same. Nothing to do
1007
- processed_list.append(curr_dev)
1008
- ########
1009
- else
1010
- credentials_old = mongo_client.get_iot_oceanconn_credent_2(prof_name1[:body]["profile"])
1011
- credentials_new = mongo_client.get_iot_oceanconn_credent_2(prof_new_id)
1012
- #########
1013
- if credentials_old[:code] == 200 && credentials_new[:code] == 200
1014
- imei_data = mongo_client.get_imei_info_from_db([curr_dev["imei"].to_i])
1015
- if imei_data[:body] != []
1016
- ans = {}
1017
- if imei_data[:body][0]["huadata"]["body"]["deviceId"] != nil
1018
- model_data = mongo_client.get_device_type_info_universal(type_new_pr)
1019
- #####all checks completed. then process data#####
1020
- ans_old = hua_aceanconnect_connector.remove_one_device_from_iot(credentials_old[:body][:app_id], credentials_old[:body][:secret], imei_data[:body][0]["huadata"]["body"]["deviceId"])
1021
-
1022
- if ans_old[:code].to_i == 200 || ans_old[:code].to_i == 202 || ans_old[:code].to_i == 204
1023
- begin
1024
- resss = hua_aceanconnect_connector.add_new_device_on_huawei(credentials_new[:body][:app_id],
1025
- credentials_new[:body][:secret],
1026
- curr_dev["imei"].to_i,
1027
- curr_dev["imei"].to_s,
1028
- prof_name1[:body]["description"],
1029
- model_data[:body]["device_type"],
1030
- curr_dev["new_profile"],
1031
- model_data[:body]["ManufacturerID"],
1032
- model_data[:body]["ManufacturerNAME"],
1033
- model_data[:body]["model"]
1034
- )
1035
- if resss[:code]=="200"
1036
- if resss[:body].key?("error_code") && resss[:body]["error_code"] != 200
1037
- not_processed_list.append({:imei => curr_dev["imei"], :error => resss})
1038
- else
1039
- new_id_iot = resss[:body]
1040
- new_profile_id = prof_new_id
1041
- now_date = DateTime.now
1042
- #finished success. update database
1043
- attribute = {profile: new_profile_id, device_type: model_data[:body]["model"], huadata: {body: new_id_iot}, updated: now_date}
1044
- answ_mongo = mongo_client.modify_attr_mongo_universal(curr_dev["imei"].to_i, attribute)
1045
- if answ_mongo[:code] != 200
1046
- not_processed_list.append({:imei => curr_dev["imei"], :error => "Critical error. Mongo not updated", :mongo_err => answ_mongo})
1006
+ p type_new_pr
1007
+ p prof_new_id
1008
+ p "st111111"
1009
+
1010
+ get_login_info = mongo_client.check_login_prof_perm_id_one(inp_login, prof_name1[:body]["profile_id"])
1011
+ p get_login_info
1012
+ p "get_login_info"
1013
+ if get_login_info[:code] == 200
1014
+ get_login_info_new = mongo_client.check_login_prof_perm_id_one(inp_login, prof_new_id)
1015
+ p get_login_info_new
1016
+ p "get_login_info_new"
1017
+ if get_login_info_new[:code] == 200
1018
+ cur_comp1 = mongo_client.compare_profiles(prof_name1[:body]["profile_id"], prof_new_id)
1019
+ p cur_comp1
1020
+ p "cur_comp1"
1021
+ cur_comp2 = mongo_client.compare_device_types(prof_name1[:imei_info][:body][0]["device_type"], type_new_pr)
1022
+
1023
+
1024
+ p cur_comp2
1025
+ p "cur_comp2"
1026
+
1027
+ if cur_comp1[:is_the_same] && cur_comp2[:is_the_same]
1028
+ #the same. Nothing to do
1029
+ processed_list.append(curr_dev)
1030
+ ########
1031
+ else
1032
+ credentials_old = mongo_client.get_iot_oceanconn_credent_2(prof_name1[:body]["profile"])
1033
+ credentials_new = mongo_client.get_iot_oceanconn_credent_2(prof_new_id)
1034
+ p credentials_new
1035
+ p "credentials_new"
1036
+ #########
1037
+ if credentials_old[:code] == 200 && credentials_new[:code] == 200
1038
+ imei_data = mongo_client.get_imei_info_from_db([curr_dev["imei"].to_i])
1039
+ p imei_data
1040
+ p "imei_data"
1041
+ if imei_data[:body] != []
1042
+ ans = {}
1043
+ if imei_data[:body][0]["huadata"]["body"]["deviceId"] != nil
1044
+ model_data = mongo_client.get_device_type_info_universal(type_new_pr)
1045
+ p model_data
1046
+ p "model_data"
1047
+ #####all checks completed. then process data#####
1048
+ ans_old = hua_aceanconnect_connector.remove_one_device_from_iot(credentials_old[:body][:app_id], credentials_old[:body][:secret], imei_data[:body][0]["huadata"]["body"]["deviceId"])
1049
+
1050
+
1051
+ if ans_old[:code].to_i == 200 || ans_old[:code].to_i == 202 || ans_old[:code].to_i == 204
1052
+ begin
1053
+ resss = hua_aceanconnect_connector.add_new_device_on_huawei(credentials_new[:body][:app_id],
1054
+ credentials_new[:body][:secret],
1055
+ curr_dev["imei"].to_i,
1056
+ curr_dev["imei"].to_s,
1057
+ prof_name1[:body]["description"],
1058
+ model_data[:body]["device_type"],
1059
+ curr_dev["new_profile"],
1060
+ model_data[:body]["ManufacturerID"],
1061
+ model_data[:body]["ManufacturerNAME"],
1062
+ model_data[:body]["model"]
1063
+ )
1064
+ if resss[:code] == "200"
1065
+ if resss[:body].key?("error_code") && resss[:body]["error_code"] != 200
1066
+ not_processed_list.append({:imei => curr_dev["imei"], :error => resss})
1047
1067
  else
1048
- processed_list.append(curr_dev)
1068
+ p resss
1069
+ new_id_iot = resss[:body]
1070
+ new_profile_id = prof_new_id
1071
+ now_date = DateTime.now
1072
+ #finished success. update database
1073
+ attribute = {profile: new_profile_id, device_type: model_data[:body]["model"], huadata: resss, updated: now_date}
1074
+ answ_mongo = mongo_client.modify_attr_mongo_universal(curr_dev["imei"].to_i, attribute)
1075
+ if answ_mongo[:code] != 200
1076
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "Critical error. Mongo not updated", :mongo_err => answ_mongo})
1077
+ else
1078
+ processed_list.append(curr_dev)
1079
+ end
1049
1080
  end
1050
- #added_on_iot_platf.append(s1)
1081
+ else
1082
+ not_processed_list.append({:imei => curr_dev["imei"], :error => resss})
1051
1083
  end
1052
- else
1053
- not_processed_list.append({:imei => curr_dev["imei"], :error => resss})
1084
+ rescue
1085
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "Unknown error with insertion imei on IOT platform"})
1054
1086
  end
1055
- rescue
1056
- not_processed_list.append({:imei => curr_dev["imei"], :error => "Unknown error with insertion imei on IOT platform"})
1087
+ else
1088
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "Something wrong with IOT platform"})
1057
1089
  end
1090
+ else
1091
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "Not processed by iot platform. deviceId not found in mongoDB"})
1058
1092
  end
1059
1093
  else
1060
- not_processed_list.append({:imei => curr_dev["imei"], :error => "Not processed by iot platform. deviceId not found in mongoDB"})
1094
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "Failed to get info from database"})
1061
1095
  end
1062
1096
  else
1063
- not_processed_list.append({:imei => curr_dev["imei"], :error => "Failed to get info from database"})
1097
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "Failed to get credentials from database"})
1064
1098
  end
1065
- else
1066
- not_processed_list.append({:imei => curr_dev["imei"], :error => "Failed to get credentials from database"})
1067
1099
  end
1100
+ else
1101
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "New profile modification not permitted"})
1068
1102
  end
1069
1103
  else
1070
- not_processed_list.append({:imei => curr_dev["imei"], :error => "New profile modification not permitted"})
1104
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "Old profile modification not permitted"})
1071
1105
  end
1072
1106
  else
1073
- not_processed_list.append({:imei => curr_dev["imei"], :error => "Old profile modification not permitted"})
1107
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "Unknown current profile"})
1074
1108
  end
1075
1109
  else
1076
- not_processed_list.append({:imei => curr_dev["imei"], :error => "Unknown current profile"})
1110
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "Device not exists"})
1077
1111
  end
1078
1112
  else
1079
- not_processed_list.append({:imei => curr_dev["imei"], :error => "Device not exists"})
1113
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "IMEI can't be nil"})
1080
1114
  end
1081
- else
1082
- not_processed_list.append({:imei => curr_dev["imei"], :error => "IMEI can't be nil"})
1115
+ rescue
1116
+ not_processed_list.append({:imei => curr_dev["imei"], :error => "Unknown SDK error"})
1083
1117
  end
1084
- rescue
1085
- not_processed_list.append({:imei => curr_dev["imei"], :error => "Unknown SDK error"})
1086
- end
1087
1118
 
1088
- end
1119
+ end
1089
1120
 
1090
- err_li = []
1091
- if not_processed_list.length > 0
1092
- not_processed_list.each do |err_l|
1093
- err_li.append({:failedimei => err_l[:imei]})
1121
+ err_li = []
1122
+ if not_processed_list.length > 0
1123
+ not_processed_list.each do |err_l|
1124
+ err_li.append({:failedimei => err_l[:imei]})
1125
+ end
1094
1126
  end
1095
- end
1096
1127
 
1097
- if processed_list.length > 0
1098
- soap_answ = {:code=>200, :result=>"Success", :body=>{:processednum => processed_list.length, :failednum => not_processed_list.length, :deviceserr => err_li}}
1099
- else
1100
- soap_answ = {:code=>202, :result=>"Nothing done", :body=>{:processednum => 0, :failednum => not_processed_list.length, :deviceserr => err_li}}
1128
+ if processed_list.length > 0
1129
+ answ_to_soapgw = {:code => 200, :result => "Success", :body => {:processednum => processed_list.length, :failednum => not_processed_list.length, :deviceserr => err_li}}
1130
+ else
1131
+ answ_to_soapgw = {:code => 202, :result => "Nothing done", :body => {:processednum => 0, :failednum => not_processed_list.length, :deviceserr => err_li}}
1132
+ end
1101
1133
  end
1134
+ thr13set.join
1102
1135
 
1103
- output_answ = {:code => 200, :result => "Success", :body => {:to_soap_gw => soap_answ, :not_processed_list => not_processed_list, :processed_list => processed_list}}
1136
+ output_answ = {:code => 200, :result => "Success", :body => {:to_soap_gw => answ_to_soapgw, :not_processed_list => not_processed_list, :processed_list => processed_list}}
1104
1137
  mongo_client.audit_logger("set_data_replace_2", remote_ip, input_params, output_answ, real_ip)
1105
1138
  output_answ
1106
1139
  end
@@ -54,6 +54,9 @@ class HuaIot
54
54
  def get_token(app_id, secret)
55
55
  internal_func.printer_texter("get_token: start. Step1, iput: app_id: #{app_id.to_s}, secret: #{secret.to_s}", "debug")
56
56
  out_resp = {}
57
+ fff = {}
58
+ data = {}
59
+ url_string = ""
57
60
  begin
58
61
  path = "/iocm/app/sec/v1.1.0/login"
59
62
  url_string = "https://" + platformip + ":" + platformport + path
@@ -73,15 +76,19 @@ class HuaIot
73
76
  request.content_type = 'application/x-www-form-urlencoded'
74
77
  request.body = URI.encode_www_form(data)
75
78
  res = https.request(request)
79
+ p res.code
80
+ p res.message
81
+ p res.body.to_s
76
82
  out_resp = {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
77
83
  fff = {:func => "get_token",
78
84
  :iot_fun => "",
79
- :req_header => {:content_type => 'application/x-www-form-urlencoded'
85
+ :req_header => {:content_type => 'application/x-www-form-urlencoded',
86
+ :platform => "Huawei oceanconnect"
80
87
  }}
81
- client_iot_mongo.audit_iot_logger(fff, url_string, data, out_resp)
82
88
  rescue
83
89
  out_resp = {:code => 500, :message => "failed get token"}
84
90
  end
91
+ client_iot_mongo.audit_iot_logger(fff, url_string, data, out_resp)
85
92
  jjj = {:procedure => "get_token", :answ => out_resp}
86
93
  internal_func.printer_texter(jjj, "debug")
87
94
  out_resp
@@ -92,6 +99,9 @@ class HuaIot
92
99
 
93
100
  internal_func.printer_texter("token_logout Step1 token: #{token}", "debug")
94
101
  out_resp = {}
102
+ fff = {}
103
+ data = {}
104
+ url_string = ""
95
105
  begin
96
106
  path = "/iocm/app/sec/v1.1.0/logout"
97
107
  url_string = "https://" + platformip + ":" + platformport + path
@@ -112,12 +122,17 @@ class HuaIot
112
122
  res = https.request(request)
113
123
  out_resp = {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
114
124
  fff = {:func => "token_logout",
115
- :iot_fun => "logout"
125
+ :iot_fun => "logout",
126
+ :platform => "Huawei oceanconnect"
116
127
  }
117
- client_iot_mongo.audit_iot_logger(fff, url_string, data, out_resp)
128
+ p res.code
129
+ p res.message
130
+ p res.body.to_s
131
+
118
132
  rescue
119
133
  out_resp = {:code => 500, :message => "failed logout token"}
120
134
  end
135
+ client_iot_mongo.audit_iot_logger(fff, url_string, data, out_resp)
121
136
  jjj = {:procedure => "token_logout", :answ => out_resp}
122
137
  internal_func.printer_texter(jjj, "debug")
123
138
  out_resp
@@ -125,6 +140,7 @@ class HuaIot
125
140
 
126
141
  #Registering a Directly Connected Device (Verification Code Mode) (V2)
127
142
  def dev_register_verif_code_mode(app_id, secret, node_id)
143
+ out_resp = {}
128
144
  token = get_token(app_id, secret)[:body]["accessToken"]
129
145
  path = "/iocm/app/reg/v1.1.0/deviceCredentials?appId=" + app_id
130
146
  url_string = "https://" + platformip + ":" + platformport + path
@@ -138,9 +154,17 @@ class HuaIot
138
154
  request.content_type = 'application/json'
139
155
  request['Authorization'] = 'Bearer ' + token
140
156
  request['app_key'] = app_id
141
- request.body = {nodeId: node_id}.to_json
157
+ data = {nodeId: node_id}
158
+ request.body = data.to_json
142
159
  res = https.request(request)
143
- {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
160
+ out_resp = {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
161
+ fff = {:func => "dev_register_verif_code_mode",
162
+ :iot_fun => "Registering a Directly Connected Device (Verification Code Mode) (V2)",
163
+ :req_header => {:content_type => 'application/json',
164
+ :platform => "Huawei oceanconnect"
165
+ }}
166
+ client_iot_mongo.audit_iot_logger(fff, url_string, data, out_resp)
167
+ out_resp
144
168
  end
145
169
 
146
170
  #2.2.4 Registering a Directly Connected Device (Password Mode) (V2)
@@ -176,7 +200,8 @@ class HuaIot
176
200
  :iot_fun => "2.2.4",
177
201
  :req_header => {:authorization => 'Bearer ' + token,
178
202
  :content_type => 'application/json',
179
- :app_key => app_id
203
+ :app_key => app_id,
204
+ :platform => "Huawei oceanconnect"
180
205
  }}
181
206
  client_iot_mongo.audit_iot_logger(fff, url_string, data_out, out_resp)
182
207
  out_resp
@@ -199,13 +224,21 @@ class HuaIot
199
224
  request.content_type = 'application/json'
200
225
  request['Authorization'] = 'Bearer ' + token
201
226
  request['app_key'] = app_id
202
- data_out = {deviceInfo: attr_list}.to_json
227
+ data = {deviceInfo: attr_list}
228
+ data_out = data.to_json
203
229
  internal_func.printer_texter({:procedure => "dev_register_passw_code_mode2", :data => {:body => data_out, :url => url_string}}, "debug")
204
230
  request.body = data_out
205
231
  res = https.request(request)
206
232
  p res.body.to_s
207
233
  out_resp = {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
208
- p out_resp
234
+ fff = {:func => "dev_reg_passw_code_mode2_2",
235
+ :iot_fun => "2.2.4",
236
+ :req_header => {:content_type => 'application/json',
237
+ :authorization => 'Bearer ' + token,
238
+ :app_key => app_id,
239
+ :platform => "Huawei oceanconnect"
240
+ }}
241
+ client_iot_mongo.audit_iot_logger(fff, url_string, data, out_resp)
209
242
  out_resp
210
243
  end
211
244
 
@@ -237,7 +270,8 @@ class HuaIot
237
270
  :iot_fun => "2.2.12",
238
271
  :req_header => {:authorization => 'Bearer ' + token,
239
272
  :content_type => 'application/json',
240
- :app_key => app_id
273
+ :app_key => app_id,
274
+ :platform => "Huawei oceanconnect"
241
275
  }}
242
276
  client_iot_mongo.audit_iot_logger(fff, url_string, "Delete", out_resp)
243
277
  rescue
@@ -274,6 +308,7 @@ class HuaIot
274
308
 
275
309
  #2.2.14 Querying Device Activation Status
276
310
  def querying_device_activ_status(app_id, secret, device_id)
311
+ output_ans = {}
277
312
  token = get_token(app_id, secret)[:body]["accessToken"]
278
313
  path = "/iocm/app/reg/v1.1.0/devices/" + device_id + "?app_Id=" + app_id
279
314
  url_string = "https://" + platformip + ":" + platformport + path
@@ -288,12 +323,22 @@ class HuaIot
288
323
  request['Authorization'] = 'Bearer ' + token
289
324
  request['app_key'] = app_id
290
325
  res = https.request(request)
291
- {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
326
+ output_ans = {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
327
+ fff = {:func => "querying_device_activ_status",
328
+ :iot_fun => "2.2.14",
329
+ :req_header => {:content_type => 'application/json',
330
+ :authorization => 'Bearer ' + token,
331
+ :app_key => app_id,
332
+ :platform => "Huawei oceanconnect"
333
+ }}
334
+ client_iot_mongo.audit_iot_logger(fff, url_string, data, output_ans)
335
+ output_ans
292
336
  end
293
337
 
294
338
 
295
339
  #2.9.1 Querying Information About a Device
296
340
  def querying_device_info(app_id, secret, device_id)
341
+ out_resp = {}
297
342
  token = get_token(app_id, secret)[:body]["accessToken"]
298
343
  path = "/iocm/app/dm/v1.1.0/devices/" + device_id + "?app_Id=" + app_id
299
344
  url_string = "https://" + platformip + ":" + platformport + path
@@ -308,7 +353,16 @@ class HuaIot
308
353
  request['Authorization'] = 'Bearer ' + token
309
354
  request['app_key'] = app_id
310
355
  res = https.request(request)
311
- {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
356
+ out_resp = {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
357
+ fff = {:func => "querying_device_info",
358
+ :iot_fun => "2.9.1",
359
+ :req_header => {:authorization => 'Bearer ' + token,
360
+ :content_type => 'application/json',
361
+ :app_key => app_id,
362
+ :platform => "Huawei oceanconnect"
363
+ }}
364
+ client_iot_mongo.audit_iot_logger(fff, url_string, "Get", out_resp)
365
+ out_resp
312
366
  end
313
367
 
314
368
  #2.9.6 Querying Directly Connected Devices and Their Mounted Devices in Batches
@@ -335,7 +389,8 @@ class HuaIot
335
389
  :iot_fun => "2.9.6",
336
390
  :req_header => {:authorization => 'Bearer ' + token,
337
391
  :content_type => 'application/json',
338
- :app_key => app_id
392
+ :app_key => app_id,
393
+ :platform => "Huawei oceanconnect"
339
394
  }}
340
395
  client_iot_mongo.audit_iot_logger(fff, url_string, req_body, output_str)
341
396
  output_str
@@ -344,6 +399,7 @@ class HuaIot
344
399
 
345
400
  #2.9.19 Querying the Complete Device Type List of All Device Capabilities
346
401
  def querying_device_type_list(app_id, secret)
402
+ output_ans = {}
347
403
  token = get_token(app_id, secret)[:body]["accessToken"]
348
404
  path = "/iocm/app/profile/v1.1.0/allDeviceTypes"
349
405
  url_string = "https://" + platformip + ":" + platformport + path
@@ -358,13 +414,24 @@ class HuaIot
358
414
  request['Authorization'] = 'Bearer ' + token
359
415
  request['app_key'] = app_id
360
416
  res = https.request(request)
361
- {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
417
+ output_ans = {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
418
+
419
+ fff = {:func => "querying_device_type_list",
420
+ :iot_fun => "2.9.19",
421
+ :req_header => {:content_type => 'application/json',
422
+ :authorization => 'Bearer ' + token,
423
+ :app_key => app_id,
424
+ :platform => "Huawei oceanconnect"
425
+ }}
426
+ client_iot_mongo.audit_iot_logger(fff, url_string, "Get", output_ans)
427
+ output_ans
428
+
362
429
  end
363
430
 
364
431
 
365
432
  #2.9.6 Querying Directly Connected Devices and Their Mounted Devices in Batches
366
433
  def quer_dev_direct_conn_batches(app_id, dev_list, token)
367
-
434
+ output_ans = {}
368
435
  path = "/iocm/app/dm/v1.1.0/queryDevicesByIds"
369
436
  url_string = "https://" + platformip + ":" + platformport + path
370
437
  p url_string
@@ -378,10 +445,19 @@ class HuaIot
378
445
  request.content_type = 'application/json'
379
446
  request['Authorization'] = 'Bearer ' + token
380
447
  request['app_key'] = app_id
381
- request.body = {deviceIds: dev_list}.to_json
448
+ data = {deviceIds: dev_list}
449
+ request.body = data.to_json
382
450
  res = https.request(request)
383
- {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
384
-
451
+ output_ans = {:code => res.code, :message => res.message, :body => JSON.parse(res.body.to_s)}
452
+ fff = {:func => "quer_dev_direct_conn_batches",
453
+ :iot_fun => "2.9.6",
454
+ :req_header => {:content_type => 'application/json',
455
+ :authorization => 'Bearer ' + token,
456
+ :app_key => app_id,
457
+ :platform => "Huawei oceanconnect"
458
+ }}
459
+ client_iot_mongo.audit_iot_logger(fff, url_string, data, output_ans)
460
+ output_ans
385
461
  end
386
462
 
387
463
 
@@ -417,7 +493,8 @@ class HuaIot
417
493
  :iot_fun => "2.2.11",
418
494
  :req_header => {:authorization => 'Bearer ' + token,
419
495
  :content_type => 'application/json',
420
- :app_key => app_id
496
+ :app_key => app_id,
497
+ :platform => "Huawei oceanconnect"
421
498
  }}
422
499
  client_iot_mongo.audit_iot_logger(fff, url_string, req_b, out_resp)
423
500
  rescue
@@ -155,6 +155,14 @@ class InternalFunc
155
155
  answer
156
156
  end
157
157
 
158
+ #compare dictionaries
159
+ def compare_dict(dict1, dict2)
160
+ v1 = dict1 - dict2
161
+ v2 = dict2 - dict1
162
+ v3 = dict2 + dict1
163
+ v3.uniq - v2.uniq - v1.uniq
164
+ end
165
+
158
166
  def test()
159
167
  p "eeeeeeeeeeeeeeeeeeeeeeee"
160
168
  end
@@ -194,7 +194,7 @@ class MongoIot
194
194
  begin
195
195
  result_ps = []
196
196
  collection = client[:device_profiles]
197
- collection.find({"profile_id" => profile_id}).each {|row|
197
+ collection.find({"profile_id" => profile_id.to_i}).each {|row|
198
198
  result_ps.append(row)
199
199
  }
200
200
  result_ps[0]
@@ -238,7 +238,7 @@ class MongoIot
238
238
  begin
239
239
  result_ps = []
240
240
  collection = client[:device_types]
241
- collection.find({"type_id" => type_id}).each {|row|
241
+ collection.find({"type_id" => type_id.to_i}).each {|row|
242
242
  result_ps.append(row)
243
243
  }
244
244
  result_ps[0]
@@ -260,19 +260,20 @@ class MongoIot
260
260
  end
261
261
  end
262
262
 
263
+ #universal procedure. might be profile id or name
263
264
  def check_login_profile_permiss(login, profile)
264
265
  out_resp = {}
265
266
  get_login_info = get_profiles_by_login(login)
266
- if get_login_info[:code]==200
267
- dst_profile = get_profile_id_by_name(profile)
268
- access=1
269
- if get_login_info[:body]!=[]
270
- if dst_profile!=[]
267
+ if get_login_info[:code] == 200
268
+ dst_profile = get_profile_universal(profile)
269
+ access = 1
270
+ if get_login_info[:body] != []
271
+ if dst_profile != []
271
272
  for j in get_login_info[:body]
272
- if j["profile_id"].to_i==dst_profile["profile_id"].to_i
273
- access=0
273
+ if j["profile_id"].to_i == dst_profile["profile_id"].to_i
274
+ access = 0
274
275
  end
275
- if access==0
276
+ if access == 0
276
277
  out_resp = {:code => 200, :result => "check_login_profile_permiss: Permission granted"}
277
278
  else
278
279
  out_resp = {:code => 400, :result => "check_login_profile_permiss: Access denied. This incident will be reported."}
@@ -292,13 +293,15 @@ class MongoIot
292
293
  end
293
294
 
294
295
 
296
+ #universal procedure. You can use profile id or profile name as profile_id (string or int)
295
297
  def check_login_prof_perm_id_one(login, profile_id)
296
298
  out_resp = {}
297
299
  get_login_info = get_profiles_by_login(login)
300
+ profile_data = self.get_profile_universal(profile_id)
298
301
  access=1
299
302
  if get_login_info[:body]!=[]
300
303
  for j in get_login_info[:body]
301
- if j["profile_id"].to_i==profile_id.to_i
304
+ if j["profile_id"].to_i==profile_data["profile_id"]
302
305
  access=0
303
306
  end
304
307
  if access==0
@@ -340,7 +343,7 @@ class MongoIot
340
343
  description: "test imei",
341
344
  note: "second description",
342
345
  profile: 0,
343
- type: 0,
346
+ device_type: 0,
344
347
  address: "unknown"
345
348
  }
346
349
  result = collection.insert_one(l)
@@ -363,7 +366,7 @@ class MongoIot
363
366
  description: "test imei",
364
367
  note: "second description",
365
368
  profile: 0,
366
- type: 0,
369
+ device_type: 0,
367
370
  address: "unknown"
368
371
  }
369
372
  result = collection.insert_one(l)
@@ -501,6 +504,7 @@ class MongoIot
501
504
 
502
505
 
503
506
  #function for get iot platform credentials from profile
507
+ #universal procedure. use profile or profile id
504
508
  def get_iot_oceanconn_credent_2(profile)
505
509
  out_resp = {}
506
510
  begin
@@ -536,7 +540,7 @@ class MongoIot
536
540
  result_ps.append(row)
537
541
  }
538
542
  dattaa = result_ps[0]
539
- if dattaa!=nil
543
+ if dattaa != nil
540
544
  out_resp = {:code => 200, :result => "get_device_type_info_by_model: Request completed successfully", :body => dattaa}
541
545
  else
542
546
  out_resp = {:code => 404, :result => "get_device_type_info_by_model: Device info not found", :body => {"model" => device_model, "ManufacturerID" => "unknown", "ManufacturerNAME" => "unknown", "device_type" => "unknown"}}
@@ -548,6 +552,7 @@ class MongoIot
548
552
  out_resp
549
553
  end
550
554
 
555
+ #universal procedure. Use id or name
551
556
  def get_device_type_info_universal(device_model)
552
557
  out_resp = {}
553
558
  begin
@@ -561,9 +566,9 @@ class MongoIot
561
566
  }
562
567
  dattaa = result_ps[0]
563
568
  if dattaa!=nil
564
- out_resp = {:code => 200, :result => "get_device_type_info_by_model: Request completed successfully", :body => dattaa}
569
+ out_resp = {:code => 200, :result => "get_device_type_info_universal: Request completed successfully", :body => dattaa}
565
570
  else
566
- out_resp = {:code => 404, :result => "get_device_type_info_by_model: Device info not found", :body => {"model" => device_model, "ManufacturerID" => "unknown", "ManufacturerNAME" => "unknown", "device_type" => "unknown"}}
571
+ out_resp = {:code => 404, :result => "get_device_type_info_universal: Device info not found", :body => {"model" => device_model, "ManufacturerID" => "unknown", "ManufacturerNAME" => "unknown", "device_type" => "unknown"}}
567
572
  end
568
573
  else
569
574
  result_ps2 = []
@@ -573,9 +578,9 @@ class MongoIot
573
578
  }
574
579
  dattaa = result_ps2[0]
575
580
  if dattaa!=nil
576
- out_resp = {:code => 200, :result => "get_device_type_info_by_model: Request completed successfully", :body => dattaa}
581
+ out_resp = {:code => 200, :result => "get_device_type_info_universal: Request completed successfully", :body => dattaa}
577
582
  else
578
- out_resp = {:code => 404, :result => "get_device_type_info_by_model: Device info not found", :body => {"model" => device_model, "ManufacturerID" => "unknown", "ManufacturerNAME" => "unknown", "device_type" => "unknown"}}
583
+ out_resp = {:code => 404, :result => "get_device_type_info_universal: Device info not found", :body => {"model" => device_model, "ManufacturerID" => "unknown", "ManufacturerNAME" => "unknown", "device_type" => "unknown"}}
579
584
  end
580
585
  end
581
586
 
@@ -632,6 +637,9 @@ class MongoIot
632
637
  out_answ = {}
633
638
  tp1 = internal_func.if_digit_or_string(type1)
634
639
  tp2 = internal_func.if_digit_or_string(type2)
640
+ p tp1
641
+ p tp2
642
+ p "tp"
635
643
 
636
644
  if tp1[:body][:string] == tp2[:body][:string] && tp1[:body][:string] == false
637
645
  if type1.to_i == type2.to_i
@@ -648,6 +656,7 @@ class MongoIot
648
656
  else
649
657
  tp1_data = {}
650
658
  tp2_data = {}
659
+ p "gggggggg"
651
660
  if tp1[:body][:string]
652
661
  tp1_data = self.get_type_by_name(type1)
653
662
  else
@@ -660,6 +669,11 @@ class MongoIot
660
669
  tp2_data = self.get_type_by_id(type2.to_i)
661
670
  end
662
671
 
672
+ p tp1_data
673
+ p tp2_data
674
+ p type1
675
+ p type2
676
+
663
677
  if tp1_data["type_id"] == tp2_data["type_id"]
664
678
  out_answ = {:code => 200, :result => "compare_device_types: profiles are the same", :is_the_same => true, :data_type => "different"}
665
679
  else
@@ -670,6 +684,7 @@ class MongoIot
670
684
  end
671
685
 
672
686
 
687
+ #universal procedure. put there profile name or id in string or int
673
688
  def get_profile_universal(profile)
674
689
  inn = internal_func.if_digit_or_string(profile)
675
690
  out = {}
@@ -1,4 +1,4 @@
1
1
  module Imperituroard
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.9"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperituroard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-08 00:00:00.000000000 Z
11
+ date: 2020-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -187,6 +187,7 @@ extra_rdoc_files: []
187
187
  files:
188
188
  - ".gitignore"
189
189
  - ".idea/runConfigurations/hua_oceanconnect_adapter.xml"
190
+ - ".idea/runConfigurations/version.xml"
190
191
  - ".ruby-gemset"
191
192
  - ".ruby-version"
192
193
  - ".travis.yml"