imperituroard 0.4.3 → 0.4.4

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: '088118e62f44142a8e96e6275b6f80902133f675'
4
- data.tar.gz: de5d6a58525645906238977ed3ff2016c3cea3f0
3
+ metadata.gz: 80e97d149199ca8d19d1f44fd7efa93c83fb3735
4
+ data.tar.gz: c3fb37c6327ba5f80409e8a1de60eacef665b16d
5
5
  SHA512:
6
- metadata.gz: c6aa662e9956771a4f4e5adadc5e26c8ac7881fa5b8a3ce67c6c7affb80a720b303b183365a31410625d32c5201d6959a92310c0b564182d2b11221f8eee9aad
7
- data.tar.gz: c9d6dc4d4106a4ec23aa25a7749ea7e0d098972a7c50a3c5860ffe7de2995382ad63253f7fed739693caedd4bbf19a967ea6366f64ba1b11e407ccf9f932d761
6
+ metadata.gz: 76330a50f5c3e066b16374ce5ec656c855bb6988987d608f3d42ff0cbf1e7677562c071ca4ccf3b693affa51d517710f874d0dadac3d9f93e7f4a6212d96ea17
7
+ data.tar.gz: 8f71b08f56d0cc2134048be60d81eb42f73d5f6fc8e2a5b909d876cf398be587f774407603b0beb77fc1c6951037734211482da73a3740c7ae5b2881c94c5f7a
data/lib/imperituroard.rb CHANGED
@@ -248,60 +248,6 @@ class Iot
248
248
  end
249
249
 
250
250
 
251
-
252
- #additional procedure for checking status on iot platform
253
- def get_info_by_imeilist_from_iot(login, imei_list)
254
- resp_out={}
255
- begin
256
- dev_id_list = []
257
- resss = {}
258
- data_from_db = mongo_client.get_imei_info_from_db(imei_list)
259
- p data_from_db
260
- for g in data_from_db[:body]
261
- dev_id_list.append(g["huadata"]["body"]["deviceId"])
262
- end
263
- credentials = mongo_client.get_iot_oceanconnect_credent(login)
264
- if credentials[:code]==200
265
- p apid = credentials[:body][:app_id]
266
- p secre = credentials[:body][:secret]
267
- resp_out = hua_aceanconnect_connector.quer_dev_query_list(apid, secre, dev_id_list)
268
- end
269
- rescue
270
- resp_out = {:code => "500", :message => "get_info_by_imeilist_from_iot: Something wrong", :body => {"devices" => []}}
271
- end
272
- internal_func.printer_texter(resp_out, "debug")
273
- resp_out
274
- end
275
-
276
-
277
- #for internal use. Add new device model
278
- def add_model_to_mongo(model, manufacture_id, manufacture_name, device_type, description, note)
279
- model = {
280
- model: model,
281
- ManufacturerID: manufacture_id,
282
- ManufacturerNAME: manufacture_name,
283
- device_type: device_type,
284
- description: description,
285
- note: note,
286
- created: DateTime.now
287
- }
288
- mongo_client.imei_insert_model(model)
289
- end
290
-
291
- def test()
292
- #ddd = MongoIot.new(mongoip, mongoport, mongo_database)
293
- #ddd.get_profiles_by_login("test")
294
-
295
- ff = [131234123412341233, 131234123127341233]
296
- #ddd.get_imsi_info_from_db(ff)
297
-
298
- #p ddd.get_profile_id_by_name("1341241")
299
- #p ddd.get_device_type_info_by_model("BGT_PPMC11")
300
-
301
- #fff = HuaIot.new("134.17.93.4", "443", "/Users/imperituroard/Desktop/cert.crt", "/Users/imperituroard/Desktop/key.pem")
302
- p hua_aceanconnect_connector.querying_device_id("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "eWllZpHgXgvgDAQlJjWs4QXaR94a", "91234")
303
- end
304
-
305
251
  end
306
252
 
307
253
 
@@ -651,6 +651,7 @@ class IotFunctions_2
651
651
 
652
652
  begin
653
653
  data_processed = []
654
+ data_soapgw = []
654
655
  login_info = mongo_client.get_login_inf2_select(login)
655
656
  if login_info[:code]==200
656
657
  permit_profiles = login_info[:body]["permit_profiles"]
@@ -665,14 +666,29 @@ class IotFunctions_2
665
666
  :profile => ff["profile"],
666
667
  :info => ff["info"]
667
668
  })
669
+ data_soapgw.append({:id => ff["profile_id"], :form => ff["form"], :description => ff["description"], :profile => ff["profile"]})
670
+
668
671
  end
669
- resp_out = {:code => 200, :result => "Request completed successfully", :body => {:data => data_processed}}
672
+ tosoapgw = { :code => 200,
673
+ :result => "Request completed successfully",
674
+ :profiles => data_soapgw
675
+ }
676
+
677
+ resp_out = {:code => 200, :result => "Request completed successfully", :body => {:data => data_processed, :tosoapgw => tosoapgw}}
670
678
  else
671
- resp_out = {:code => login_info[:code], :result => login_info[:result]}
679
+ tosoapgw = { :code => login_info[:code],
680
+ :result => login_info[:result],
681
+ :profiles => data_soapgw
682
+ }
683
+ resp_out = {:code => login_info[:code], :result => login_info[:result], :body => {:tosoapgw => tosoapgw}}
672
684
  end
673
685
 
674
686
  rescue
675
- resp_out = {:code => 507, :result => "Unknown SDK error"}
687
+ tosoapgw = { :code => 507,
688
+ :result => "Unknown SDK error",
689
+ :profiles => data_soapgw
690
+ }
691
+ resp_out = {:code => 507, :result => "Unknown SDK error", :body => {:tosoapgw => tosoapgw}}
676
692
  end
677
693
  mongo_client.audit_logger("get_available_prof_2", remote_ip, input_params, resp_out, real_ip)
678
694
  resp_out
@@ -686,6 +702,7 @@ class IotFunctions_2
686
702
 
687
703
  begin
688
704
  data_processed = []
705
+ data_soapgw = []
689
706
  login_info = mongo_client.get_login_inf2_select(login)
690
707
  if login_info[:code]==200
691
708
 
@@ -705,14 +722,29 @@ class IotFunctions_2
705
722
  :model => ff["model"],
706
723
  :info => ff["info"]
707
724
  })
725
+ data_soapgw.append({:name => ff["model"], :form => ff["form"], :description => ff["description"], :type_id => ff["type_id"]})
708
726
  end
709
- resp_out = {:code => 200, :result => "Request completed successfully", :body => {:data => data_processed}}
727
+
728
+ tosoapgw = { :code => 200,
729
+ :result => "Request completed successfully",
730
+ :types => data_soapgw
731
+ }
732
+
733
+ resp_out = {:code => 200, :result => "Request completed successfully", :body => {:data => data_processed, :tosoapgw => tosoapgw}}
710
734
  else
711
- resp_out = {:code => login_info[:code], :result => login_info[:result]}
735
+ tosoapgw = { :code => login_info[:code],
736
+ :result => login_info[:result],
737
+ :types => data_soapgw
738
+ }
739
+ resp_out = {:code => login_info[:code], :result => login_info[:result], :body => {:tosoapgw => tosoapgw}}
712
740
  end
713
741
 
714
742
  rescue
715
- resp_out = {:code => 507, :result => "Unknown SDK error"}
743
+ tosoapgw = { :code => 507,
744
+ :result => "Unknown SDK error",
745
+ :types => data_soapgw
746
+ }
747
+ resp_out = {:code => 507, :result => "Unknown SDK error", :body => {:tosoapgw => tosoapgw}}
716
748
  end
717
749
  mongo_client.audit_logger("get_available_types_2", remote_ip, input_params, resp_out, real_ip)
718
750
  resp_out
@@ -726,7 +758,8 @@ class IotFunctions_2
726
758
  output_answ = {}
727
759
  mon_answer = {}
728
760
  begin
729
- if type.is_a? String
761
+ #if type.is_a? String
762
+ if internal_func.if_digit_or_string(type)[:body][:string]
730
763
  mon_answer = mongo_client.get_type_by_name(type)
731
764
  else
732
765
  mon_answer = mongo_client.get_type_by_id(type)
@@ -753,11 +786,9 @@ class IotFunctions_2
753
786
 
754
787
  input_params = {:profile => profile}
755
788
  output_answ = {}
756
-
757
789
  mon_answer = {}
758
-
759
790
  begin
760
- if profile.is_a? String
791
+ if internal_func.if_digit_or_string(profile)[:body][:string]
761
792
  mon_answer = mongo_client.get_profile_id_by_name(profile)
762
793
  else
763
794
  mon_answer = mongo_client.get_profile_name_by_id(profile)
@@ -782,4 +813,63 @@ class IotFunctions_2
782
813
 
783
814
  end
784
815
 
816
+
817
+
818
+
819
+ #additional procedure for checking status on iot platform
820
+ def get_info_by_imeilist_from_iot(login, imei_list)
821
+ resp_out={}
822
+ begin
823
+ dev_id_list = []
824
+ resss = {}
825
+ data_from_db = mongo_client.get_imei_info_from_db(imei_list)
826
+ p data_from_db
827
+ for g in data_from_db[:body]
828
+ dev_id_list.append(g["huadata"]["body"]["deviceId"])
829
+ end
830
+ credentials = mongo_client.get_iot_oceanconnect_credent(login)
831
+ if credentials[:code]==200
832
+ p apid = credentials[:body][:app_id]
833
+ p secre = credentials[:body][:secret]
834
+ resp_out = hua_aceanconnect_connector.quer_dev_query_list(apid, secre, dev_id_list)
835
+ end
836
+ rescue
837
+ resp_out = {:code => "500", :message => "get_info_by_imeilist_from_iot: Something wrong", :body => {"devices" => []}}
838
+ end
839
+ internal_func.printer_texter(resp_out, "debug")
840
+ resp_out
841
+ end
842
+
843
+
844
+ #for internal use. Add new device model
845
+ def add_model_to_mongo(model, manufacture_id, manufacture_name, device_type, description, note)
846
+ model = {
847
+ model: model,
848
+ ManufacturerID: manufacture_id,
849
+ ManufacturerNAME: manufacture_name,
850
+ device_type: device_type,
851
+ description: description,
852
+ note: note,
853
+ created: DateTime.now
854
+ }
855
+ mongo_client.imei_insert_model(model)
856
+ end
857
+
858
+
859
+ def test()
860
+ #ddd = MongoIot.new(mongoip, mongoport, mongo_database)
861
+ #ddd.get_profiles_by_login("test")
862
+
863
+ ff = [131234123412341233, 131234123127341233]
864
+ #ddd.get_imsi_info_from_db(ff)
865
+
866
+ #p ddd.get_profile_id_by_name("1341241")
867
+ #p ddd.get_device_type_info_by_model("BGT_PPMC11")
868
+
869
+ #fff = HuaIot.new("134.17.93.4", "443", "/Users/imperituroard/Desktop/cert.crt", "/Users/imperituroard/Desktop/key.pem")
870
+ p hua_aceanconnect_connector.querying_device_id("Cd1v0k2gTBCbpQlMVlW1FVqOSqga", "eWllZpHgXgvgDAQlJjWs4QXaR94a", "91234")
871
+ end
872
+
873
+
874
+
785
875
  end
@@ -44,6 +44,34 @@ class InternalFunc
44
44
  end
45
45
 
46
46
 
47
+ def if_digit_or_string(data)
48
+
49
+ input_params = {:data => data}
50
+ output_params = {}
51
+ str_incr = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
52
+ 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
53
+ ]
54
+ d_a_t_a = data.split('')
55
+
56
+ is_string = 0
57
+
58
+ for ddd in d_a_t_a
59
+ if str_incr.include?(ddd)
60
+ is_string = 1
61
+ end
62
+ end
63
+
64
+ if is_string == 0
65
+ output_params = {:code => 200, :result => "if_digit_or_string: Request processed", :body => {:string => false}}
66
+ else
67
+ output_params = {:code => 200, :result => "if_digit_or_string: Request processed", :body => {:string => true}}
68
+ end
69
+
70
+ output_params
71
+
72
+ end
73
+
74
+
47
75
 
48
76
  def test()
49
77
  p "eeeeeeeeeeeeeeeeeeeeeeee"
@@ -1,3 +1,3 @@
1
1
  module Imperituroard
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperituroard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy