comunika_gsm 0.1.9 → 0.1.10

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: 61e83d4112815af17ab005e1769a7bc98d43420f
4
- data.tar.gz: 2e18b980945f7ab62ce8db61307368bd71450fbc
3
+ metadata.gz: 1a0a190ee77641764e442423fbe8ea8997db3133
4
+ data.tar.gz: ac227aa30e9dcf8b65f715186df8cb4029d92545
5
5
  SHA512:
6
- metadata.gz: b94eb847e2f56a1f107a9c799193408e6267eb9e16c3aac43805e0a9d3834342a28674bf043a138b10960d8b9091dffab61bd4116af48a4d1bf0beb4d5019145
7
- data.tar.gz: f797081a63de2d54fec0bf95cae4bc211966d592f99761522736f14afd03d95f958b9357bce6e42791e43db2bfa55c6e7bff3c470ea765d8bd457ad0a69fd163
6
+ metadata.gz: 2f1bb1d2cf1430aa6b450c144d37b515bfafe6111ff2a4228a4d82edd14425eefd9ae3344e018766d243ddcce09900348e0c73c2c49a6ed4fa1c70ca8560842c
7
+ data.tar.gz: c5cb62174d8db05fe364d6c538e4a9a92af59b9812a6deabddecf2454743a480e4dd603691623204ba862dd446907f370de5c0b3bbbe126069d17a3d0c22d988
@@ -22,21 +22,13 @@ module ComunikaGsm
22
22
  threads = []
23
23
  self.ports.each do |port|
24
24
  threads << Thread.new {
25
- gsm = GSM2.new(:port => port, :debug => params[:debug])
26
- if gsm.status
27
- result = gsm.cmd("AT\r\n")
28
- if result.to_s.length > 0
29
- imei = gsm.cmd("AT+CGSN\r\n")
30
- iccid = gsm.cmd("AT+CRSM=176,12258,0,0,10\r\n")
31
- provider = gsm.cmd("AT+COPS?\r\n")
32
- signal = gsm.cmd("AT+CSQ\r\n")
33
- unless @@devices.find {|m| m[:imei] == imei}
34
- @@devices << {:port => port,:gsm => gsm, :imei => imei, :iccid => iccid, :provider => provider, :signal => signal}
35
- end
36
- else
37
- gsm.close
38
- end
25
+ ## Check port and add in to devices ##
26
+ modem = self.load_modem(port, params[:debug])
27
+ if modem
28
+ self.add(modem)
39
29
  end
30
+
31
+ Thread.current.kill
40
32
  }
41
33
  end
42
34
 
@@ -47,6 +39,29 @@ module ComunikaGsm
47
39
  @@devices.collect! {|d| Device.new(d) }#.uniq {|d| d[:imei] }#.find_all{|dev| dev.status == true }.uniq!{|d| d.imei }
48
40
  end
49
41
 
42
+ def add(device)
43
+ @@devices << device
44
+ end
45
+
46
+ def load_modem(port, debug=false)
47
+ gsm = GSM2.new(:port => port, :debug => debug)
48
+ if gsm.status
49
+ result = gsm.cmd("AT\r\n")
50
+ if result.to_s.length > 0
51
+ imei = gsm.cmd("AT+CGSN\r\n")
52
+ iccid = gsm.cmd("AT+CRSM=176,12258,0,0,10\r\n")
53
+ provider = gsm.cmd("AT+COPS?\r\n")
54
+ signal = gsm.cmd("AT+CSQ\r\n")
55
+ unless @@devices.find {|m| m[:imei] == imei}
56
+ return Device.new(:port => port,:gsm => gsm, :imei => imei, :iccid => iccid, :provider => provider, :signal => signal)
57
+ end
58
+ else
59
+ gsm.close
60
+ return nil
61
+ end
62
+ end
63
+ end
64
+
50
65
  class Device
51
66
  attr_accessor :port, :gsm, :imei, :iccid, :provider, :signal
52
67
  def initialize(params)
@@ -1,3 +1,3 @@
1
1
  module ComunikaGsm
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comunika_gsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jefferson Silva
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-22 00:00:00.000000000 Z
11
+ date: 2017-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.6.12
105
+ rubygems_version: 2.6.13
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Gem of use internal