sms_serial 0.1.2 → 0.1.3
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
- checksums.yaml.gz.sig +3 -4
- data/lib/sms_serial.rb +23 -6
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a75b0d87e21e0b2c7d3c7d1ea5e85842c16aa04e3f7116e966e1eda99c74be3
|
4
|
+
data.tar.gz: b13eae5dc152fa3da533dbaa07e391ec7362372dbedaab3206f837f91de895e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 615c227c6f9ee357102113ec97f7495d2ac0ac10ac926f576a58832a60e6c49790ca4fff0f2ef95b7398b635b3d2ec0e35e9ba2a3d8c13fc44779bf3b85201c7
|
7
|
+
data.tar.gz: 17cb01a5a135599c331b6de88afd66004aee074182e3cd2a0516f5121df4ac48119183db07e47635c7f420b06bc5b244f4fffb4daa6bf8de85d31df8783bb96e
|
checksums.yaml.gz.sig
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
"�
|
4
|
-
��|����3h'�"�T.2Wȧr�UB�֟c��ı�0�MX�����J}N�|�����}�����*EG��{N��CU������@�����D�-���͟��$;��Y��z&Km�jx��z'p|&�J�$�5�0��5%���1o`A�D�Dٱ9q{���%����M�̣Y� ,q�� yIk�c��h��.�?
|
1
|
+
������͚���Q�{�^�^�Jw�8Z��SsHe�e�c�ܯ��Ċ������Ҍ��ԝS��Ĕ�Rre�r�(o� 8u�a̴O\�J%�ç�
|
2
|
+
��P�:�=Ǯ|Ͼ9�5����Ւ Ҁ$�o��8 <�uQC�n�O� C�L�TZ��-�_EWQm�7�$:�=�N6�
|
3
|
+
X������GEV�\([���I:���ׯz&Ӧ�AƐQ��������Ӗܵ��_֭�j�N�r�t_���2�F��h��{Y�7�LcE�JAn�n�G����|�ڴ�ٰ�'6߫����m��*�1c��WƂ�C�Tq�னe+���+.1�m�X�}"cnFd���Ā3&T�^��q{��p�(M�i�
|
data/lib/sms_serial.rb
CHANGED
@@ -14,6 +14,7 @@ end
|
|
14
14
|
class SmsSerial
|
15
15
|
using ColouredText
|
16
16
|
|
17
|
+
attr_reader :t
|
17
18
|
|
18
19
|
def initialize(dev='/dev/ttyUSB0', callback: nil, debug: false)
|
19
20
|
|
@@ -29,12 +30,16 @@ class SmsSerial
|
|
29
30
|
|
30
31
|
message = @sp.read
|
31
32
|
if message.length > 0
|
32
|
-
|
33
|
+
|
34
|
+
callback.call(message) if callback and @debug
|
35
|
+
|
33
36
|
if message =~ /^\+CMTI:/ then
|
34
37
|
callback.call(message.lines[2]) if callback
|
35
38
|
else
|
36
39
|
|
40
|
+
Thread.current[:v] ||= []
|
37
41
|
Thread.current[:v] << message
|
42
|
+
|
38
43
|
end
|
39
44
|
end
|
40
45
|
end
|
@@ -103,8 +108,10 @@ class SmsSerial
|
|
103
108
|
#
|
104
109
|
def cmd(s)
|
105
110
|
|
106
|
-
|
107
|
-
|
111
|
+
puts ('inside cmd s: ' + s.inspect).debug if @debug
|
112
|
+
r2 = @sp.write "AT+%s\r\n" % [s]
|
113
|
+
puts 'r2: ' + r2.inspect if @debug
|
114
|
+
puts '@t[:v] ' + @t[:v].inspect if @debug
|
108
115
|
|
109
116
|
r = read_buffer
|
110
117
|
|
@@ -117,18 +124,28 @@ class SmsSerial
|
|
117
124
|
end
|
118
125
|
|
119
126
|
def read_buffer()
|
120
|
-
|
127
|
+
|
128
|
+
sleep 2 if @debug
|
129
|
+
|
130
|
+
puts 'inside read_buffer @t[:v]: ' + @t[:v].inspect if @debug
|
131
|
+
r = ''
|
132
|
+
@t[:v].any? ? (r += @t[:v].shift until @t[:v].empty?).to_s : r = ''
|
133
|
+
|
134
|
+
puts 'read_buffer r: ' + r.inspect if @debug
|
135
|
+
r
|
136
|
+
|
121
137
|
end
|
122
138
|
|
123
139
|
def parse_msg(r)
|
124
140
|
|
125
141
|
puts ('parse_msg r: ' + r.inspect).debug if @debug
|
126
142
|
return if r.empty?
|
127
|
-
heading = r.lines[2][/\+CMG[RL]: (
|
143
|
+
heading = r.lines[2][/\+CMG[RL]: (?:[^,]+,)?(.*)/,1]
|
144
|
+
puts ('heading: ' + heading.inspect).debug if @debug
|
128
145
|
|
129
146
|
raise SmsSerialError, "Message not found" unless heading
|
130
147
|
|
131
|
-
sender, sent = CSV.parse(heading).first.values_at(
|
148
|
+
sender, sent = CSV.parse(heading).first.values_at(0,2)
|
132
149
|
{sender: sender, sent: Time.parse(sent), body: r.lines[4].rstrip}
|
133
150
|
|
134
151
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|