ruby_ucp 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -3
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/performance/stresser.rb +81 -0
- data/lib/ruby_ucp.rb +1 -1
- data/lib/samples/main.rb +5 -2
- data/lib/ucp/pdu/ucp51_operation.rb +2 -2
- data/lib/ucp/util/ucp.rb +22 -7
- data/lib/ucp/util/ucp_server.rb +8 -1
- metadata +5 -4
data/CHANGELOG
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
============ RELEASED ==============
|
2
2
|
|
3
|
+
= 0.3.0 (2011-10-21)
|
4
|
+
* fixed issues #10, #13, #14, #15
|
5
|
+
|
3
6
|
= 0.2.0 (2011-02-06)
|
4
7
|
* miscelaneous cleanup
|
5
8
|
* basic documentation of methods in Ucp::Util::UCP
|
@@ -39,6 +42,3 @@
|
|
39
42
|
|
40
43
|
= 0.4.0
|
41
44
|
* add samples
|
42
|
-
|
43
|
-
= 0.3.0
|
44
|
-
* methods documentation
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -0,0 +1,81 @@
|
|
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
|
+
|
27
|
+
|
28
|
+
$KCODE = 'UTF8'
|
29
|
+
require 'jcode'
|
30
|
+
require "rubygems"
|
31
|
+
require "ruby_ucp"
|
32
|
+
include Ucp::Util
|
33
|
+
require "benchmark"
|
34
|
+
|
35
|
+
|
36
|
+
def bench(test_name,test_code,*args)
|
37
|
+
total_runs = 1000
|
38
|
+
t=Benchmark.realtime { total_runs.times do; test_code.call(*args); end }
|
39
|
+
puts "#{test_name}: #{(total_runs/t).to_i} req/sec"
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
def test_parse_str
|
45
|
+
ustr=2.chr+"01/00357/O/51/961234567/1234/////////////////4/1072/0031003200330034003500360037003800390030003100320033003400350036003700380039003000310032003300340035003600370038003900300031003200330034003500360037003800390030003100320033003400350036003700380039003000310032003300340035003600370038003900300031003200330034003500360037//////////0106050003450201020108///01"+3.chr
|
46
|
+
ucp=UCP.parse_str(ustr)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_make_multi_ucps(msg_size)
|
50
|
+
UCP.make_multi_ucps(1235,961234568,"1234567890"*msg_size)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_ucp30_basic_submit(msg_size)
|
54
|
+
ucp=Ucp30Operation.new
|
55
|
+
ucp.basic_submit(1234, 961234567, "z"*msg_size)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
puts "== Ruby UCP methods benchmark =="
|
60
|
+
|
61
|
+
bench("UCP.parse_str()",method(:test_parse_str))
|
62
|
+
bench("UCP.make_multi_ucps(sms_len=10)",method(:test_make_multi_ucps),1)
|
63
|
+
bench("UCP.make_multi_ucps(sms_len=100)",method(:test_make_multi_ucps),10)
|
64
|
+
bench("UCP.make_multi_ucps(sms_len=300)",method(:test_make_multi_ucps),30)
|
65
|
+
|
66
|
+
puts "== == =="
|
67
|
+
|
68
|
+
bench("Ucp30Operation.basic_submit(sms_len=10)",method(:test_ucp30_basic_submit),10)
|
69
|
+
bench("Ucp30Operation.basic_submit(sms_len=100)",method(:test_ucp30_basic_submit),100)
|
70
|
+
bench("Ucp30Operation.basic_submit(sms_len=300)",method(:test_ucp30_basic_submit),300)
|
71
|
+
|
72
|
+
puts "== == =="
|
73
|
+
|
74
|
+
=begin
|
75
|
+
Benchmark.bm(7) do |x|
|
76
|
+
x.report("for:") { n.times do; ustr=2.chr+"01/00357/O/51/961234567/1234/////////////////4/1072/0031003200330034003500360037003800390030003100320033003400350036003700380039003000310032003300340035003600370038003900300031003200330034003500360037003800390030003100320033003400350036003700380039003000310032003300340035003600370038003900300031003200330034003500360037//////////0106050003450201020108///01"+3.chr
|
77
|
+
ucp=UCP.parse_str(ustr); end }
|
78
|
+
x.report("times:") { n.times do ; a = "1"; end }
|
79
|
+
x.report("upto:") { 1.upto(n) do ; a = "1"; end }
|
80
|
+
end
|
81
|
+
=end
|
data/lib/ruby_ucp.rb
CHANGED
data/lib/samples/main.rb
CHANGED
@@ -100,15 +100,18 @@ server.set_authentication_handler(method(:auth_handler))
|
|
100
100
|
cliente=UcpClient.new("localhost",port,{:login=>8006,:password=>"timor"})
|
101
101
|
#sent=cliente.send_message(1234,961234567,"1234567890"*17+"ola custa 1€ sabias?")
|
102
102
|
|
103
|
+
|
103
104
|
ans=cliente.send_alert("961234567","0100")
|
104
|
-
puts "
|
105
|
+
puts "ans_send_alert: #{ans}"
|
106
|
+
|
105
107
|
s="1234567890"*8+"1€"
|
106
108
|
sent=cliente.send_message(1234,961234567,s)
|
107
109
|
puts "sent: #{sent}"
|
108
110
|
ucp=Ucp30Operation.new
|
109
111
|
ucp.basic_submit(1234, 961234567, "ola 1€éuro Ç!@\'\"#\$%&/()=<>,.-;:*+[]")
|
110
112
|
ans=cliente.send_sync(ucp)
|
111
|
-
puts "
|
113
|
+
puts "--------------------------"
|
114
|
+
puts "ans_send_sync: #{ans}"
|
112
115
|
cliente.close
|
113
116
|
server.stop
|
114
117
|
exit
|
@@ -58,7 +58,7 @@ class Ucp::Pdu::Ucp51Operation < Ucp::Pdu::UCP5x
|
|
58
58
|
def parse_xser
|
59
59
|
@xservices.each { |xser|
|
60
60
|
|
61
|
-
puts "xser_id: #{xser[0,2]}"
|
61
|
+
# puts "xser_id: #{xser[0,2]}"
|
62
62
|
|
63
63
|
if xser[0,2].eql?("01")
|
64
64
|
header=xser[4,xser[2,2].to_i(16)*2]
|
@@ -128,7 +128,7 @@ class Ucp::Pdu::Ucp51Operation < Ucp::Pdu::UCP5x
|
|
128
128
|
# UCP51 supports IRA encoded SMS and 16 bits UCS2
|
129
129
|
# for now assume IRA
|
130
130
|
if !message.nil?
|
131
|
-
msg=UCP.ascii2ira(message)
|
131
|
+
msg=UCP.ascii2ira(message).encoded
|
132
132
|
end
|
133
133
|
mt=3
|
134
134
|
|
data/lib/ucp/util/ucp.rb
CHANGED
@@ -65,7 +65,7 @@ class Ucp::Util::UCP
|
|
65
65
|
add_char(0x00,"@")
|
66
66
|
add_char(0x01,"£")
|
67
67
|
add_char(0x02,"$")
|
68
|
-
|
68
|
+
add_char(0x03,"¥")
|
69
69
|
add_char(0x04,"è")
|
70
70
|
add_char(0x05,"é")
|
71
71
|
add_char(0x06,"ù")
|
@@ -73,12 +73,27 @@ class Ucp::Util::UCP
|
|
73
73
|
add_char(0x08,"ò")
|
74
74
|
add_char(0x09,"Ç")
|
75
75
|
add_char(0x0A,"\n")
|
76
|
-
|
77
|
-
|
76
|
+
add_char(0x0B,"Ø")
|
77
|
+
add_char(0x0C,"ø")
|
78
78
|
add_char(0x0D,"\r")
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
add_char(0x0E,"Å")
|
80
|
+
add_char(0x0F,"å")
|
81
|
+
|
82
|
+
add_char(0x10, "Δ")
|
83
|
+
add_char(0x11, "_")
|
84
|
+
add_char(0x12, "Φ")
|
85
|
+
add_char(0x13, "Γ")
|
86
|
+
add_char(0x14, "Λ")
|
87
|
+
add_char(0x15, "Ω")
|
88
|
+
add_char(0x16, "Π")
|
89
|
+
add_char(0x17, "Ψ")
|
90
|
+
add_char(0x18, "Σ")
|
91
|
+
add_char(0x19, "Θ")
|
92
|
+
add_char(0x1A, "Ξ")
|
93
|
+
# 0x1B is escape sequence for extended characters
|
94
|
+
add_char(0x1C, "Æ")
|
95
|
+
add_char(0x1D, "æ")
|
96
|
+
add_char(0x1E, "ß")
|
82
97
|
add_char(0x1F,"É")
|
83
98
|
|
84
99
|
|
@@ -87,7 +102,7 @@ class Ucp::Util::UCP
|
|
87
102
|
add_char(0x21,"!")
|
88
103
|
add_char(0x22,'"')
|
89
104
|
add_char(0x23,"#")
|
90
|
-
|
105
|
+
add_char(0x24,"¤")
|
91
106
|
add_char(0x25,"%")
|
92
107
|
add_char(0x26,"&")
|
93
108
|
add_char(0x27,"'")
|
data/lib/ucp/util/ucp_server.rb
CHANGED
@@ -99,12 +99,19 @@ class Ucp::Util::UcpServer
|
|
99
99
|
end
|
100
100
|
|
101
101
|
reply_ucp=UCP.make_ucp_result(ucp)
|
102
|
-
reply_ucp.
|
102
|
+
if reply_ucp.operation == "31" || reply_ucp.operation == "60"
|
103
|
+
reply_ucp.ack("ok")
|
104
|
+
else
|
105
|
+
smscid="#{ucp.get_field(:adc)}:#{Time.now.strftime("%d%m%y%H%M%S")}"
|
106
|
+
reply_ucp.ack("",smscid)
|
107
|
+
end
|
103
108
|
|
104
109
|
#puts "reply #{reply_ucp.to_s}"
|
105
110
|
s.print reply_ucp.to_s
|
106
111
|
puts "Ssent: #{reply_ucp.to_s}\n"
|
107
112
|
end
|
113
|
+
rescue Exception=>e
|
114
|
+
puts "Error: #{e.backtrace}"
|
108
115
|
ensure
|
109
116
|
puts "*** #{name}:#{port} disconnected/closed"
|
110
117
|
s.close # close socket on error
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_ucp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergio Freire
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-10-21 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- Rakefile
|
36
36
|
- Rakefile.orig
|
37
37
|
- VERSION
|
38
|
+
- lib/performance/stresser.rb
|
38
39
|
- lib/ruby_ucp.rb
|
39
40
|
- lib/samples/main.rb
|
40
41
|
- lib/ucp/base.rb
|