comunika_gsm 0.1.17 → 0.1.18
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 +4 -4
- data/lib/comunika_gsm/gsm2.rb +28 -25
- data/lib/comunika_gsm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 96133aa9b5099b0c1c96538546aef17cdd961efd
|
|
4
|
+
data.tar.gz: caa32b6a6c5ee877247071632a85a9e89d636c33
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 02f0eba8fa068927bb2e29f8a4d5ca9a2dcb504f07e96a61d51b5299634e357ef832802dc270dc92e75a501f9998559107df6c2b5834dbc72f6a1e979ab9004f
|
|
7
|
+
data.tar.gz: 3ca6bfed477a44a179bd507b3e45b63e43ccfd8d52667463185e81b3281973d04cc45d1c12392d25970535373a963bd995261f078174e6b890256d00299225f7
|
data/lib/comunika_gsm/gsm2.rb
CHANGED
|
@@ -44,6 +44,9 @@ module ComunikaGsm
|
|
|
44
44
|
|
|
45
45
|
def wait
|
|
46
46
|
buffer = @@port.read
|
|
47
|
+
while buffer.length == 0
|
|
48
|
+
buffer = @@port.read
|
|
49
|
+
end
|
|
47
50
|
puts buffer if @@debug
|
|
48
51
|
@@port.flush()
|
|
49
52
|
buffer
|
|
@@ -51,39 +54,39 @@ module ComunikaGsm
|
|
|
51
54
|
|
|
52
55
|
def close
|
|
53
56
|
puts "Fechando conexão"
|
|
54
|
-
@@port.close
|
|
57
|
+
@@port.close if @@port
|
|
55
58
|
@status = false
|
|
56
59
|
end
|
|
57
60
|
|
|
58
|
-
def send_sms(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
def send_sms(number,message,params = {})
|
|
62
|
+
if number.length == 0 || number.length < 11 || message.length == 0
|
|
63
|
+
return {id: nil, status: "ERROR", code: "304"}
|
|
64
|
+
else
|
|
65
|
+
## GENERATE PDU TO MESSAGE ##
|
|
66
|
+
pdu = PDU.encode(:number => "+55" + number, :message => message, :smsc => params[:smsc])
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
cmd("AT+CMGS=#{pdu[:size]}\r")
|
|
69
|
+
res = cmd("#{pdu[:pdu]}#{26.chr}")
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
sleep 3
|
|
72
|
+
while res.length == 0
|
|
73
|
+
res = wait
|
|
74
|
+
end
|
|
68
75
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
if res.include?('+CMGS')
|
|
77
|
+
res = res.scan(/\+(\S+)\: (\d+)\r\n/)
|
|
78
|
+
status = 'OK'
|
|
79
|
+
code = "-1"
|
|
80
|
+
id = res.first[1]
|
|
81
|
+
elsif res.include?('+CMS')
|
|
82
|
+
res = res.scan(/\+CMS (\S+)\: (\d+)/).first
|
|
83
|
+
status = 'ERROR'
|
|
84
|
+
code = res[1]
|
|
85
|
+
id = nil
|
|
86
|
+
end
|
|
73
87
|
|
|
74
|
-
|
|
75
|
-
res = res.scan(/\+(\S+)\: (\d+)\r\n/)
|
|
76
|
-
status = 'OK'
|
|
77
|
-
code = "-1"
|
|
78
|
-
id = res.first[1]
|
|
79
|
-
elsif res.include?('+CMS')
|
|
80
|
-
res = res.scan(/\+CMS (\S+)\: (\d+)/).first
|
|
81
|
-
status = 'ERROR'
|
|
82
|
-
code = res[1]
|
|
83
|
-
id = nil
|
|
88
|
+
{:id => id, :code => code, :status => status}
|
|
84
89
|
end
|
|
85
|
-
|
|
86
|
-
{:id => id, :code => code, :status => status}
|
|
87
90
|
end
|
|
88
91
|
|
|
89
92
|
def messages
|
data/lib/comunika_gsm/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.1.18
|
|
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-10-
|
|
11
|
+
date: 2017-10-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|