ruby_ucp 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +42 -0
- data/LICENSE +505 -0
- data/README +10 -0
- data/Rakefile +118 -0
- data/Rakefile.orig +45 -0
- data/VERSION +1 -0
- data/lib/ruby_ucp.rb +42 -0
- data/lib/samples/main.rb +182 -0
- data/lib/ucp/base.rb +24 -0
- data/lib/ucp/pdu/base.rb +22 -0
- data/lib/ucp/pdu/ucp01.rb +37 -0
- data/lib/ucp/pdu/ucp01_operation.rb +61 -0
- data/lib/ucp/pdu/ucp01_result.rb +60 -0
- data/lib/ucp/pdu/ucp30.rb +28 -0
- data/lib/ucp/pdu/ucp30_operation.rb +59 -0
- data/lib/ucp/pdu/ucp30_result.rb +63 -0
- data/lib/ucp/pdu/ucp31.rb +29 -0
- data/lib/ucp/pdu/ucp31_operation.rb +50 -0
- data/lib/ucp/pdu/ucp31_result.rb +61 -0
- data/lib/ucp/pdu/ucp51_operation.rb +167 -0
- data/lib/ucp/pdu/ucp51_result.rb +64 -0
- data/lib/ucp/pdu/ucp52_operation.rb +31 -0
- data/lib/ucp/pdu/ucp52_result.rb +31 -0
- data/lib/ucp/pdu/ucp53_operation.rb +31 -0
- data/lib/ucp/pdu/ucp53_result.rb +31 -0
- data/lib/ucp/pdu/ucp54_operation.rb +31 -0
- data/lib/ucp/pdu/ucp54_result.rb +31 -0
- data/lib/ucp/pdu/ucp55_operation.rb +31 -0
- data/lib/ucp/pdu/ucp55_result.rb +31 -0
- data/lib/ucp/pdu/ucp56_operation.rb +31 -0
- data/lib/ucp/pdu/ucp56_result.rb +31 -0
- data/lib/ucp/pdu/ucp57_operation.rb +31 -0
- data/lib/ucp/pdu/ucp57_result.rb +31 -0
- data/lib/ucp/pdu/ucp58_operation.rb +31 -0
- data/lib/ucp/pdu/ucp58_result.rb +31 -0
- data/lib/ucp/pdu/ucp5x.rb +40 -0
- data/lib/ucp/pdu/ucp60.rb +30 -0
- data/lib/ucp/pdu/ucp60_operation.rb +58 -0
- data/lib/ucp/pdu/ucp60_result.rb +60 -0
- data/lib/ucp/pdu/ucp61.rb +31 -0
- data/lib/ucp/pdu/ucp61_operation.rb +49 -0
- data/lib/ucp/pdu/ucp61_result.rb +60 -0
- data/lib/ucp/pdu/ucp_operation.rb +27 -0
- data/lib/ucp/pdu/ucp_result.rb +26 -0
- data/lib/ucp/pdu/ucpmessage.rb +125 -0
- data/lib/ucp/util/base.rb +22 -0
- data/lib/ucp/util/gsm_packed_msg.rb +50 -0
- data/lib/ucp/util/packed_msg.rb +34 -0
- data/lib/ucp/util/sms_request.rb +48 -0
- data/lib/ucp/util/ucp.rb +885 -0
- data/lib/ucp/util/ucp_client.rb +207 -0
- data/lib/ucp/util/ucp_server.rb +122 -0
- data/lib/ucp/util/ucs2_packed_msg.rb +29 -0
- metadata +120 -0
data/Rakefile.orig
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# To change this template, choose Tools | Templates
|
3
|
+
# and open the template in the editor.
|
4
|
+
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'rake'
|
8
|
+
require 'rake/clean'
|
9
|
+
require 'rake/gempackagetask'
|
10
|
+
require 'rake/rdoctask'
|
11
|
+
require 'rake/testtask'
|
12
|
+
|
13
|
+
spec = Gem::Specification.new do |s|
|
14
|
+
s.name = 'ruby_ucp'
|
15
|
+
s.version = '0.0.2'
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.extra_rdoc_files = ['README', 'LICENSE']
|
18
|
+
s.summary = 'EMI/UCP protocol library'
|
19
|
+
s.description = s.summary
|
20
|
+
s.author = 'Sergio Freire'
|
21
|
+
s.email = 'sergio-s-freire@ptinovacao.pt'
|
22
|
+
# s.executables = ['your_executable_here']
|
23
|
+
s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
|
24
|
+
s.require_path = "lib"
|
25
|
+
s.bindir = "bin"
|
26
|
+
end
|
27
|
+
|
28
|
+
Rake::GemPackageTask.new(spec) do |p|
|
29
|
+
p.gem_spec = spec
|
30
|
+
p.need_tar = true
|
31
|
+
p.need_zip = true
|
32
|
+
end
|
33
|
+
|
34
|
+
Rake::RDocTask.new do |rdoc|
|
35
|
+
files =['README', 'LICENSE', 'lib/**/*.rb']
|
36
|
+
rdoc.rdoc_files.add(files)
|
37
|
+
rdoc.main = "README" # page to start on
|
38
|
+
rdoc.title = "ruby_ucp Docs"
|
39
|
+
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
|
40
|
+
rdoc.options << '--line-numbers'
|
41
|
+
end
|
42
|
+
|
43
|
+
Rake::TestTask.new do |t|
|
44
|
+
t.test_files = FileList['test/**/*.rb']
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/ruby_ucp.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
=begin
|
2
|
+
Ruby library implementation of EMI/UCP protocol v4.6 for SMS
|
3
|
+
Copyright (C) 2011, Sergio Freire <sergio.freire@gmail.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
=end
|
19
|
+
|
20
|
+
|
21
|
+
$:.unshift(File.dirname(__FILE__))
|
22
|
+
|
23
|
+
require "ucp/base.rb"
|
24
|
+
require "ucp/pdu/ucpmessage.rb"
|
25
|
+
require "ucp/pdu/ucp01.rb"
|
26
|
+
require "ucp/pdu/ucp30.rb"
|
27
|
+
require "ucp/pdu/ucp31.rb"
|
28
|
+
require "ucp/pdu/ucp5x.rb"
|
29
|
+
require "ucp/pdu/ucp60.rb"
|
30
|
+
require "ucp/pdu/ucp61.rb"
|
31
|
+
require "ucp/util/base.rb"
|
32
|
+
|
33
|
+
|
34
|
+
# Load all YCP PDUs
|
35
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'ucp', 'pdu', '*.rb')) do |f|
|
36
|
+
require f unless f.match('ucpmessage.rb$')
|
37
|
+
end
|
38
|
+
|
39
|
+
# Load all auxiliary classes
|
40
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'ucp', 'util', '*.rb')) do |f|
|
41
|
+
require f unless f.match('base.rb$')
|
42
|
+
end
|
data/lib/samples/main.rb
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
=begin
|
2
|
+
Ruby library implementation of EMI/UCP protocol v4.6 for SMS
|
3
|
+
Copyright (C) 2011, Sergio Freire <sergio.freire@gmail.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
=end
|
19
|
+
|
20
|
+
=begin
|
21
|
+
this file actually contais a LOT of garbage... used just to test things while developing
|
22
|
+
i left so you can take a look of concrete examples, while I build clean samples along
|
23
|
+
with tests
|
24
|
+
=end
|
25
|
+
|
26
|
+
$KCODE = 'UTF8'
|
27
|
+
require 'jcode'
|
28
|
+
|
29
|
+
require "rubygems"
|
30
|
+
|
31
|
+
require "ruby_ucp"
|
32
|
+
include Ucp::Util
|
33
|
+
|
34
|
+
def handle_me(smsreq)
|
35
|
+
puts "handle_me [#{smsreq.source_ip}:#{smsreq.source_port}] (#{smsreq.originator},#{smsreq.recipient}) (#{smsreq.part_nr}/#{smsreq.total_parts}): #{smsreq.text}\n"
|
36
|
+
end
|
37
|
+
|
38
|
+
#ucp=UCP.parse_str("*00/00113/O/51/961234567/1234/////////////////4/120/B49AED86CBC162B219AD66BBE17230//////////0106050003450202///90#")
|
39
|
+
#puts "UCP: #{ucp.to_s}"
|
40
|
+
#exit
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
ucp=Ucp31Operation.new
|
47
|
+
puts "UCP: #{ucp.to_s}"
|
48
|
+
ucp=Ucp30Operation.new
|
49
|
+
ucp.basic_submit(1234, 961234567, "ola")
|
50
|
+
puts "UCP: #{ucp.to_s}"
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
ustr=2.chr+"01/00357/O/51/961234567/1234/////////////////4/1072/0031003200330034003500360037003800390030003100320033003400350036003700380039003000310032003300340035003600370038003900300031003200330034003500360037003800390030003100320033003400350036003700380039003000310032003300340035003600370038003900300031003200330034003500360037//////////0106050003450201020108///01"+3.chr
|
55
|
+
ucp=UCP.parse_str(ustr)
|
56
|
+
|
57
|
+
ucp.set_fields({:oadc=>"10412614190438AB4D",:otoa=>"5039"})
|
58
|
+
text=UCP.decode_ucp_msg(ucp)
|
59
|
+
originator=UCP.decode_ucp_oadc(ucp)
|
60
|
+
puts "originator: #{originator} ; text: #{text}"
|
61
|
+
|
62
|
+
#exit
|
63
|
+
|
64
|
+
|
65
|
+
puts UCP.str2ucs2("ola").encoded
|
66
|
+
|
67
|
+
s="1234567890"*7 +"1€"
|
68
|
+
UCP.make_multi_ucps(1235,961234568,s)
|
69
|
+
|
70
|
+
#exit
|
71
|
+
|
72
|
+
puts "1€€".length,"1€€".jlength
|
73
|
+
puts "1€"[1..1]
|
74
|
+
puts "1€".chars #[0..1]
|
75
|
+
"1€".each_char{ |c|
|
76
|
+
puts "C: #{c}"
|
77
|
+
}
|
78
|
+
#exit
|
79
|
+
|
80
|
+
|
81
|
+
#exit
|
82
|
+
|
83
|
+
ucp=Ucp01Operation.new
|
84
|
+
ucp.basic_submit("1234x",961234567,"ola")
|
85
|
+
#ucp.set_fields( {:mt=>"4", :oadc=>"x"})
|
86
|
+
ucp.trn="02"
|
87
|
+
puts ucp.to_s
|
88
|
+
|
89
|
+
|
90
|
+
port=12009
|
91
|
+
server=UcpServer.new(method(:handle_me),port)
|
92
|
+
|
93
|
+
|
94
|
+
cliente=UcpClient.new("localhost",port,{:login=>8006,:password=>"timor"})
|
95
|
+
#sent=cliente.send_message(1234,961234567,"1234567890"*17+"ola custa 1€ sabias?")
|
96
|
+
|
97
|
+
ans=cliente.send_alert("961234567","0100")
|
98
|
+
puts "ans: #{ans}"
|
99
|
+
s="1234567890"*8+"1€"
|
100
|
+
sent=cliente.send_message(1234,961234567,s)
|
101
|
+
puts "sent: #{sent}"
|
102
|
+
ucp=Ucp30Operation.new
|
103
|
+
ucp.basic_submit(1234, 961234567, "ola 1€éuro Ç!@\'\"#\$%&/()=<>,.-;:*+[]")
|
104
|
+
ans=cliente.send_sync(ucp)
|
105
|
+
puts "ans: #{ans}"
|
106
|
+
cliente.close
|
107
|
+
server.stop
|
108
|
+
exit
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
ucp=UCP.parse_str("*00/00113/O/51/961234567/1234/////////////////4/120/B49AED86CBC162B219AD66BBE17230//////////0106050003450202///90#")
|
115
|
+
puts ucp.to_s
|
116
|
+
|
117
|
+
|
118
|
+
puts UCP.pack7bits("€")
|
119
|
+
#puts UCP.packucs2("ola")
|
120
|
+
puts UCP.decode7bitgsm(UCP.pack7bits("1234567890"*17))
|
121
|
+
gsmparts= UCP.pack7bits2("1234567890"*17,134)
|
122
|
+
puts "septets: #{gsmparts.required_septets} ; unenc: #{gsmparts.unencoded}"
|
123
|
+
gsmparts= UCP.multi_pack7bits2("1234567890"*17,134)
|
124
|
+
gsmparts.each { |gsmpart|
|
125
|
+
puts "part: #{gsmpart.unencoded}"
|
126
|
+
}
|
127
|
+
|
128
|
+
UCP.make_multi_ucps(1235,961234568,"1234567890"*17)
|
129
|
+
|
130
|
+
str= UCP.pack7bits("1234567890"*17)
|
131
|
+
smparts=[]
|
132
|
+
i=0
|
133
|
+
while i*2<str.length
|
134
|
+
tmp= str[i*2,(i+134)*2]
|
135
|
+
puts "tmp.len. #{tmp.length/2} ; TMP: #{tmp}"
|
136
|
+
puts UCP.decode7bitgsm(tmp)
|
137
|
+
smparts << tmp
|
138
|
+
i+=134
|
139
|
+
end
|
140
|
+
|
141
|
+
puts str.length/2
|
142
|
+
puts str.length*8/14
|
143
|
+
#exit
|
144
|
+
|
145
|
+
#ucp=Ucp51Operation.new("1234x",961234567,"ola")
|
146
|
+
#ucp.set_fields( {:mt=>"4", :oadc=>"x"})
|
147
|
+
#ucp.add_xser_raw("020101")
|
148
|
+
#ucp.add_xser("03","01")
|
149
|
+
#ucp.trn="02"
|
150
|
+
#puts ucp.to_s
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
ucp=Ucp01Result.new
|
155
|
+
ucp.ack("ok")
|
156
|
+
puts ucp.to_s
|
157
|
+
puts ucp.is_nack?
|
158
|
+
|
159
|
+
ucp=Ucp01Result.new
|
160
|
+
ucp.nack("02","bla")
|
161
|
+
ucp.trn="12"
|
162
|
+
puts ucp.to_s
|
163
|
+
puts ucp.is_nack?
|
164
|
+
|
165
|
+
ucp=Ucp60Result.new()
|
166
|
+
ucp.ack("ok")
|
167
|
+
puts ucp.to_s
|
168
|
+
puts ucp.is_nack?
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
cliente=UcpClient.new("localhost",12000,{:login=>8006,:password=>"timor"})
|
173
|
+
ucp=Ucp51Operation.new(1234,961234567,"ola")
|
174
|
+
ans=cliente.send_sync(ucp)
|
175
|
+
|
176
|
+
if ans.is_ack?
|
177
|
+
puts "aceite!"
|
178
|
+
else
|
179
|
+
puts "rejeitado!"
|
180
|
+
end
|
181
|
+
|
182
|
+
cliente.close
|
data/lib/ucp/base.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
=begin
|
2
|
+
Ruby library implementation of EMI/UCP protocol v4.6 for SMS
|
3
|
+
Copyright (C) 2011, Sergio Freire <sergio.freire@gmail.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
=end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
module Ucp
|
23
|
+
|
24
|
+
end
|
data/lib/ucp/pdu/base.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
=begin
|
2
|
+
Ruby library implementation of EMI/UCP protocol v4.6 for SMS
|
3
|
+
Copyright (C) 2011, Sergio Freire <sergio.freire@gmail.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
=end
|
19
|
+
|
20
|
+
module Ucp::Pdu
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
=begin
|
2
|
+
Ruby library implementation of EMI/UCP protocol v4.6 for SMS
|
3
|
+
Copyright (C) 2011, Sergio Freire <sergio.freire@gmail.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
=end
|
19
|
+
|
20
|
+
class Ucp::Pdu::UCP01 < Ucp::Pdu::UCPMessage
|
21
|
+
|
22
|
+
def initialize()
|
23
|
+
super()
|
24
|
+
@operation="01"
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_fields(ucpfields={})
|
28
|
+
@h=@h.merge ucpfields
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize_message(ucpfields={})
|
32
|
+
super()
|
33
|
+
@h=@h.merge ucpfields
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
=begin
|
2
|
+
Ruby library implementation of EMI/UCP protocol v4.6 for SMS
|
3
|
+
Copyright (C) 2011, Sergio Freire <sergio.freire@gmail.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
=end
|
19
|
+
|
20
|
+
class Ucp::Pdu::Ucp01Operation < Ucp::Pdu::UCP01
|
21
|
+
|
22
|
+
def initialize(fields=nil)
|
23
|
+
super()
|
24
|
+
@operation_type="O"
|
25
|
+
@fields=[:adc,:oadc,:ac,:mt,:msg]
|
26
|
+
|
27
|
+
if fields.nil?
|
28
|
+
return
|
29
|
+
end
|
30
|
+
|
31
|
+
@trn=fields[0]
|
32
|
+
@operation_type=fields[2]
|
33
|
+
@operation=fields[3]
|
34
|
+
|
35
|
+
# *02/00050/O/01/961234567/0931D98C8607//3/6F7618/72#
|
36
|
+
|
37
|
+
for i in 4..(fields.length-1)
|
38
|
+
field=@fields[i-4]
|
39
|
+
@h[field]=fields[i]
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def basic_submit(originator,recipient,message,ucpfields={})
|
46
|
+
#super()
|
47
|
+
#@operation_type="O"
|
48
|
+
#@fields=[:adc,:oadc,:ac,:mt,:msg]
|
49
|
+
|
50
|
+
# UCP01 only supports IRA encoded SMS (7bit GSM alphabet chars, encoded in 8bits)
|
51
|
+
msg=UCP.ascii2ira(message).encoded
|
52
|
+
|
53
|
+
# UCP01 does NOT support alphanumeric oadc
|
54
|
+
oadc=originator
|
55
|
+
|
56
|
+
@h={:oadc=>oadc, :adc=>recipient, :msg=>msg,:mt=>3}
|
57
|
+
|
58
|
+
@h=@h.merge ucpfields
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
=begin
|
2
|
+
Ruby library implementation of EMI/UCP protocol v4.6 for SMS
|
3
|
+
Copyright (C) 2011, Sergio Freire <sergio.freire@gmail.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
=end
|
19
|
+
|
20
|
+
class Ucp::Pdu::Ucp01Result < Ucp::Pdu::UCP01
|
21
|
+
|
22
|
+
def initialize(fields=nil)
|
23
|
+
super()
|
24
|
+
@operation_type="R"
|
25
|
+
if fields.nil?
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
29
|
+
@trn=fields[0]
|
30
|
+
if fields[4].eql?("A")
|
31
|
+
# 06/00043/R/01/A/01234567890:090196103258/4E
|
32
|
+
ack(fields[5])
|
33
|
+
elsif fields[4].eql?("N")
|
34
|
+
# 12/00022/R/01/N/02//03
|
35
|
+
nack(fields[5],fields[6])
|
36
|
+
else
|
37
|
+
raise "invalid result in UCP01"
|
38
|
+
end
|
39
|
+
|
40
|
+
# TODO: verificar len e checksum
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def ack(sm="")
|
46
|
+
@fields=[:ack,:sm]
|
47
|
+
@h[:ack]="A"
|
48
|
+
@h[:sm]=sm
|
49
|
+
end
|
50
|
+
|
51
|
+
def nack(ec,sm="")
|
52
|
+
@fields=[:nack,:ec,:sm]
|
53
|
+
@h[:nack]="N"
|
54
|
+
@h[:ec]=ec
|
55
|
+
@h[:sm]=sm
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
=begin
|
2
|
+
Ruby library implementation of EMI/UCP protocol v4.6 for SMS
|
3
|
+
Copyright (C) 2011, Sergio Freire <sergio.freire@gmail.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
=end
|
19
|
+
|
20
|
+
class Ucp::Pdu::UCP30 < Ucp::Pdu::UCPMessage
|
21
|
+
|
22
|
+
def initialize()
|
23
|
+
super()
|
24
|
+
@operation="30"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
=begin
|
2
|
+
Ruby library implementation of EMI/UCP protocol v4.6 for SMS
|
3
|
+
Copyright (C) 2011, Sergio Freire <sergio.freire@gmail.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
=end
|
19
|
+
|
20
|
+
|
21
|
+
class Ucp::Pdu::Ucp30Operation < Ucp::Pdu::UCP30
|
22
|
+
|
23
|
+
def initialize(fields=nil)
|
24
|
+
super()
|
25
|
+
@operation_type="O"
|
26
|
+
@fields=[:adc,:oadc,:ac,:nrq,:nad,:npid,:dd,:ddt,:vp,:amsg]
|
27
|
+
|
28
|
+
if fields.nil?
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
32
|
+
@trn=fields[0]
|
33
|
+
@operation_type=fields[2]
|
34
|
+
@operation=fields[3]
|
35
|
+
|
36
|
+
# 44/00077/O/30/0673845336//////1/1003961344/1203961200/4D657373616765204F4B/27
|
37
|
+
|
38
|
+
for i in 4..(fields.length-1)
|
39
|
+
field=@fields[i-4]
|
40
|
+
@h[field]=fields[i]
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def basic_submit(originator,recipient,message,ucpfields={})
|
47
|
+
|
48
|
+
# UCP30 only supports IRA encoded SMS (7bit GSM alphabet chars, encoded in 8bits)
|
49
|
+
msg=UCP.ascii2ira(message).encoded
|
50
|
+
|
51
|
+
# UCP30 does NOT support alphanumeric oadc
|
52
|
+
oadc=originator
|
53
|
+
|
54
|
+
@h={:oadc=>oadc, :adc=>recipient, :amsg=>msg}
|
55
|
+
|
56
|
+
@h=@h.merge ucpfields
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
=begin
|
2
|
+
Ruby library implementation of EMI/UCP protocol v4.6 for SMS
|
3
|
+
Copyright (C) 2011, Sergio Freire <sergio.freire@gmail.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
=end
|
19
|
+
|
20
|
+
class Ucp::Pdu::Ucp30Result < Ucp::Pdu::UCP30
|
21
|
+
|
22
|
+
def initialize(fields=nil)
|
23
|
+
super()
|
24
|
+
@operation="30"
|
25
|
+
@operation_type="R"
|
26
|
+
if fields.nil?
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
@trn=fields[0]
|
31
|
+
if fields[4].eql?("A")
|
32
|
+
# 10/00039/R/30/A//067345:070295121212/6F
|
33
|
+
ack(fields[5],fields[6])
|
34
|
+
elsif fields[4].eql?("N")
|
35
|
+
# 11/00022/R/30/N/24//08
|
36
|
+
nack(fields[5],fields[6])
|
37
|
+
else
|
38
|
+
raise "invalid result in UCP51"
|
39
|
+
end
|
40
|
+
|
41
|
+
# TODO: verificar len e checksum
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def ack(mvp="",sm="")
|
47
|
+
@fields=[:ack,:sm]
|
48
|
+
@h[:ack]="A"
|
49
|
+
@h[:mvp]=mvp
|
50
|
+
@h[:sm]=sm
|
51
|
+
end
|
52
|
+
|
53
|
+
def nack(ec,sm="")
|
54
|
+
@fields=[:nack,:ec,:sm]
|
55
|
+
@h[:nack]="N"
|
56
|
+
@h[:ec]=ec
|
57
|
+
@h[:sm]=sm
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
=begin
|
2
|
+
Ruby library implementation of EMI/UCP protocol v4.6 for SMS
|
3
|
+
Copyright (C) 2011, Sergio Freire <sergio.freire@gmail.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License as published by the Free Software Foundation; either
|
8
|
+
version 2.1 of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
16
|
+
License along with this library; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
=end
|
19
|
+
|
20
|
+
|
21
|
+
class Ucp::Pdu::UCP31 < Ucp::Pdu::UCPMessage
|
22
|
+
|
23
|
+
def initialize()
|
24
|
+
super()
|
25
|
+
@operation="31"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|