comunika_gsm 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28460a08eeb3f50c8dbd9877f380f67b92f74fe5
4
- data.tar.gz: b8b85e09297e5d3b2762e456dbe1b7e5e65df057
3
+ metadata.gz: 52b64ec7c573437629da2538ecfd5a6f0ae8d5ad
4
+ data.tar.gz: 839f25da8eeb8c96303b94f1ac6891c5c87c8fd7
5
5
  SHA512:
6
- metadata.gz: 85fd3a28f8c6828a45a5be191d2e8b27c65aedf9f317308990921eab07615516a1a457c775bb21d10a52395039f27eb27ff905ad5ec6cf1acec488cf1ef2f8da
7
- data.tar.gz: 973889bd1e78d0d65d6ec7577e140490193e38cb9e9d6c68532ff835f3f7ec279dc3dfb10a0e81154db19e5ed283957927d68485dd6a3cad73adf41284b28680
6
+ metadata.gz: b199f631b1148d4a021e2ec88b103c5665e8dacb56ffd99e9453b97fb075ab550a40e8b7308cd1905ad01ab53bb0fc0b9a4ac5db96f27e0d7ab2d620c9102097
7
+ data.tar.gz: 00eebf868230c315630c9d1ea4fdb44c7ec90b5cd5e98ba036521e03da49ab0886c4158d4e2c5db9da2ffff5bd3407ceca5ff160e44fe25b82543178bba55b0e
@@ -46,6 +46,7 @@ module ComunikaGsm
46
46
  attr_accessor :id,:port, :imei, :iccid, :provider, :gsm, :total
47
47
  def initialize(params)
48
48
  @id = params[:id]; @port = params[:port]; @imei = params[:imei]; @gsm = params[:gsm]; @total = params[:total] || 0
49
+ @provider = params[:provider]; @iccid = params[:iccid]
49
50
  end
50
51
 
51
52
  def send_sms(msg)
@@ -89,6 +90,5 @@ module ComunikaGsm
89
90
  msgs.collect!{ |m| PDU::PDUDecode.new(connection: @gsm, id: m[0], size: m[2], pdu: m[3].chomp).decode }# rescue nil
90
91
  end
91
92
  end
92
-
93
93
  end
94
94
  end
@@ -1,3 +1,3 @@
1
1
  module ComunikaGsm
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comunika_gsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jefferson Silva
@@ -79,7 +79,6 @@ files:
79
79
  - lib/comunika_gsm/js/pdu.min.js
80
80
  - lib/comunika_gsm/modem.rb
81
81
  - lib/comunika_gsm/pdu.rb
82
- - lib/comunika_gsm/sms.rb
83
82
  - lib/comunika_gsm/version.rb
84
83
  homepage: ''
85
84
  licenses:
@@ -1,52 +0,0 @@
1
- module ComunikaGsm
2
- module SMS
3
- class Provider
4
- attr_reader :gsm
5
- attr_accessor :total
6
- def initialize(port,debug=false)
7
- @gsm = GSM.new(:port => port, :debug => debug)
8
- @total = 0
9
- end
10
-
11
- def send_sms(msg)
12
- return {id: nil, status: "ERROR", code: "304"} if msg[:number].length == 0
13
- return {id: nil, status: "ERROR", code: "304"} if msg[:number].length < 11
14
- return {id: nil, status: "ERROR", code: "503"} if msg[:message].length == 0
15
-
16
- ## GENERATE PDU TO MESSAGE ##
17
- pdu = PDU.encode(:number => msg[:number].prepend("+55"), :smsc => msg[:smsc], :message => msg[:message])
18
-
19
- # cmd("AT+CMGS=\"#{options[:number]}\"\r")
20
- # res = cmd("#{options[:message][0..160]}#{26.chr}")
21
- @gsm.cmd("AT+CMGS=#{pdu.size}\r")
22
- res = @gsm.cmd("#{pdu.body}#{26.chr}")
23
-
24
- sleep 3
25
- while res.empty?
26
- res = @gsm.wait
27
- end
28
-
29
- if res.include?('+CMGS')
30
- res = res.scan(/\+(\S+)\: (\d+)\r\n/)
31
- status = 'OK'
32
- code = "-1"
33
- id = res.first[1]
34
- elsif res.include?('+CMS')
35
- res = res.scan(/\+CMS (\S+)\: (\d+)/).first
36
- status = 'ERROR'
37
- code = res[1]
38
- id = nil
39
- end
40
- {:id => id, :code => code, :status => status}
41
- end
42
-
43
- def messages
44
- sms = @gsm.cmd("AT+CMGL=4\r\n")
45
- msgs = sms.scan(/\+CMGL\:\s*?(\d+),\s*?(\d+),.*?\,s*?(\d+)\r\n(.*)/)
46
-
47
- ## IDS: 0 - ID, 1 -- ,2 - size, 3 - PDU
48
- msgs.collect!{ |m| PDU::PDUDecode.new(connection: @gsm, id: m[0], size: m[2], pdu: m[3].chomp).decode }# rescue nil
49
- end
50
- end
51
- end
52
- end