ruby_ucp 0.1.0
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.
- 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
@@ -0,0 +1,31 @@
|
|
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
|
+
require "ucp/pdu/ucp51_result.rb"
|
22
|
+
|
23
|
+
class Ucp::Pdu::Ucp57Result < Ucp::Pdu::Ucp51Result
|
24
|
+
|
25
|
+
def initialize(fields=nil)
|
26
|
+
super(fields)
|
27
|
+
@operation="57"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,31 @@
|
|
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
|
+
require "ucp/pdu/ucp51_operation.rb"
|
22
|
+
|
23
|
+
class Ucp::Pdu::Ucp58Operation < Ucp::Pdu::Ucp51Operation
|
24
|
+
|
25
|
+
def initialize(fields=nil)
|
26
|
+
super(fields)
|
27
|
+
@operation="58"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,31 @@
|
|
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
|
+
require "ucp/pdu/ucp51_result.rb"
|
22
|
+
|
23
|
+
class Ucp::Pdu::Ucp58Result < Ucp::Pdu::Ucp51Result
|
24
|
+
|
25
|
+
def initialize(fields=nil)
|
26
|
+
super(fields)
|
27
|
+
@operation="58"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,40 @@
|
|
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::UCP5x < Ucp::Pdu::UCPMessage
|
22
|
+
|
23
|
+
@xservices=[]
|
24
|
+
|
25
|
+
def initialize()
|
26
|
+
super()
|
27
|
+
@xservices=Array.new
|
28
|
+
@fields=[:adc,:oadc,:ac,:nrq,:nadc,:nt,:npid,:lrq,:lrad,:lpid,:dd,:ddt,:vp,:rpid,:scts,:dst,:rsn,:dscts,:mt,:nb,:msg,:mms,:pr,:dcs,:mcls,:rpi,:cpg,:rply,:otoa,:hplmn,:xser,:res4,:res5]
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_fields(ucpfields={})
|
32
|
+
@h=@h.merge ucpfields
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize_message(ucpfields={})
|
36
|
+
super()
|
37
|
+
@h=@h.merge ucpfields
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,30 @@
|
|
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::UCP61 < Ucp::Pdu::UCPMessage
|
22
|
+
|
23
|
+
def initialize()
|
24
|
+
super()
|
25
|
+
@operation="61"
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,58 @@
|
|
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::Ucp60Operation < Ucp::Pdu::UCP60
|
22
|
+
|
23
|
+
def initialize(fields=nil)
|
24
|
+
super()
|
25
|
+
#@operation="60"
|
26
|
+
@operation_type="O"
|
27
|
+
@fields=[:oadc,:oton,:onpi,:styp,:pwd,:npwd,:vers,:ladc,:lton,:lnpi,:opid,:res1]
|
28
|
+
|
29
|
+
if fields.nil?
|
30
|
+
return
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
@trn=fields[0]
|
35
|
+
@operation_type=fields[2]
|
36
|
+
@operation=fields[3]
|
37
|
+
|
38
|
+
# *00/00050/O/60/8006/6/5/1/F474FB2D07//0100//////15#
|
39
|
+
|
40
|
+
for i in 4..(fields.length-1)
|
41
|
+
field=@fields[i-4]
|
42
|
+
@h[field]=fields[i]
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
def basic_auth(originator,password,ucpfields={})
|
51
|
+
#super()
|
52
|
+
#@operation_type="O"
|
53
|
+
|
54
|
+
@h={:oadc=>originator, :pwd=>UCP.ascii2ira(password), :vers=>"0100", :styp=>"1", :oton=>"6",:onpi=>"5"}
|
55
|
+
@h=@h.merge ucpfields
|
56
|
+
end
|
57
|
+
|
58
|
+
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
|
+
|
21
|
+
class Ucp::Pdu::Ucp60Result < Ucp::Pdu::UCP60
|
22
|
+
|
23
|
+
def initialize(fields=nil)
|
24
|
+
super()
|
25
|
+
@operation_type="R"
|
26
|
+
if fields.nil?
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
@trn=fields[0]
|
31
|
+
if fields[4].eql?("A")
|
32
|
+
# 00/00019/R/60/A//6D
|
33
|
+
ack(fields[5])
|
34
|
+
elsif fields[4].eql?("N")
|
35
|
+
# 00/00022/R/60/N/01//04
|
36
|
+
nack(fields[5],fields[6])
|
37
|
+
else
|
38
|
+
raise "invalid result in UCP60"
|
39
|
+
end
|
40
|
+
|
41
|
+
# TODO: verificar len e checksum
|
42
|
+
|
43
|
+
end
|
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,31 @@
|
|
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
|
+
class Ucp::Pdu::UCP60 < Ucp::Pdu::UCPMessage
|
23
|
+
|
24
|
+
def initialize()
|
25
|
+
super()
|
26
|
+
@operation="60"
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,49 @@
|
|
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::Ucp61Operation < Ucp::Pdu::UCP61
|
22
|
+
|
23
|
+
def initialize(fields=nil)
|
24
|
+
super()
|
25
|
+
@operation_type="O"
|
26
|
+
@fields=[:oadc,:oton,:onpi,:styp,:pwd,:npwd,:vers,:ladc,:lton,:lnpi,:res1,:res2]
|
27
|
+
|
28
|
+
if fields.nil?
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
@trn=fields[0]
|
34
|
+
@operation_type=fields[2]
|
35
|
+
@operation=fields[3]
|
36
|
+
|
37
|
+
# 00/00058/O/61/04568768///2///0100/1920870340094000//5///06
|
38
|
+
|
39
|
+
|
40
|
+
for i in 4..(fields.length-1)
|
41
|
+
field=@fields[i-4]
|
42
|
+
@h[field]=fields[i]
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
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
|
+
|
21
|
+
class Ucp::Pdu::Ucp61Result < Ucp::Pdu::UCP61
|
22
|
+
|
23
|
+
def initialize(fields=nil)
|
24
|
+
super()
|
25
|
+
@operation_type="R"
|
26
|
+
if fields.nil?
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
@trn=fields[0]
|
31
|
+
if fields[4].eql?("A")
|
32
|
+
# 00/00019/R/61/A//6E
|
33
|
+
ack(fields[5])
|
34
|
+
elsif fields[4].eql?("N")
|
35
|
+
# 00/00022/R/61/N/02//06
|
36
|
+
nack(fields[5],fields[6])
|
37
|
+
else
|
38
|
+
raise "invalid result in UCP61"
|
39
|
+
end
|
40
|
+
|
41
|
+
# TODO: verificar len e checksum
|
42
|
+
|
43
|
+
end
|
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,27 @@
|
|
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::UcpOperation < Ucp::Pdu::UCPMessage
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@operation_type="O"
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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::UcpResult < Ucp::Pdu::UCPMessage
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@operation_type="R"
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,125 @@
|
|
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
|
+
|
23
|
+
class UCPMessage
|
24
|
+
DELIMITER="/"
|
25
|
+
STX=2.chr
|
26
|
+
ETX=3.chr
|
27
|
+
|
28
|
+
|
29
|
+
@fields=[]
|
30
|
+
@h={}
|
31
|
+
|
32
|
+
# @@trn="00"
|
33
|
+
attr_reader :operation
|
34
|
+
attr_reader :operation_type
|
35
|
+
attr_accessor :trn
|
36
|
+
attr_reader :dcs
|
37
|
+
attr_reader :message_ref, :part_nr, :total_parts
|
38
|
+
|
39
|
+
# usado pelas classes que o extendem
|
40
|
+
def initialize()
|
41
|
+
@dcs="01"
|
42
|
+
|
43
|
+
@trn="00"
|
44
|
+
@fields=[]
|
45
|
+
@h=Hash.new
|
46
|
+
|
47
|
+
@message_ref=0
|
48
|
+
@part_nr=1
|
49
|
+
@total_parts=1
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_field(field)
|
53
|
+
return @h[field]
|
54
|
+
end
|
55
|
+
|
56
|
+
def set_field(field,value)
|
57
|
+
@h[field]=value
|
58
|
+
end
|
59
|
+
|
60
|
+
def set_fields(ucpfields={})
|
61
|
+
@h=@h.merge ucpfields
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def is_operation?
|
66
|
+
return @operation_type=="O"
|
67
|
+
end
|
68
|
+
|
69
|
+
def is_result?
|
70
|
+
return @operation_type=="R"
|
71
|
+
end
|
72
|
+
|
73
|
+
def is_ack?
|
74
|
+
return @h.has_key?(:ack)
|
75
|
+
end
|
76
|
+
|
77
|
+
def is_nack?
|
78
|
+
return @h.has_key?(:nack)
|
79
|
+
end
|
80
|
+
|
81
|
+
def checksum(s)
|
82
|
+
# The <checksum> is derived by the addition of all bytes of the header, data field separators
|
83
|
+
# and data fields (i.e. all characters after the stx-character, up to and including the last “/”
|
84
|
+
# before the checksum field). The 8 Least Significant Bits (LSB) of the result is then
|
85
|
+
# represented as two printable characters.
|
86
|
+
|
87
|
+
sum=0
|
88
|
+
s.each_byte { |byte|
|
89
|
+
sum+=byte
|
90
|
+
}
|
91
|
+
#return sprintf("%02x",sum)[-2,2]
|
92
|
+
return sum.to_s(16)[-2,2].upcase
|
93
|
+
end
|
94
|
+
|
95
|
+
def length(s)
|
96
|
+
return sprintf("%05d",s.length+16)
|
97
|
+
end
|
98
|
+
|
99
|
+
def to_s
|
100
|
+
|
101
|
+
s=""
|
102
|
+
@fields.each{ |key|
|
103
|
+
value=@h[key]
|
104
|
+
if value.nil?
|
105
|
+
s+=DELIMITER
|
106
|
+
else
|
107
|
+
s+=value.to_s+DELIMITER
|
108
|
+
end
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
pdu=@trn+DELIMITER
|
113
|
+
pdu+=length(s)+DELIMITER
|
114
|
+
pdu+=@operation_type+DELIMITER
|
115
|
+
pdu+=@operation+DELIMITER
|
116
|
+
pdu+=s
|
117
|
+
pdu+=checksum(pdu)
|
118
|
+
pdu=STX+pdu+ETX
|
119
|
+
return pdu
|
120
|
+
end
|
121
|
+
|
122
|
+
end # class
|
123
|
+
|
124
|
+
|
125
|
+
end # module
|
@@ -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::Util
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,50 @@
|
|
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::Util::GsmPackedMsg < Ucp::Util::PackedMsg
|
21
|
+
|
22
|
+
|
23
|
+
# attr_reader :encoded,:unencoded,:chars,:required_septets,:part_nr,:total_parts,:message_ref
|
24
|
+
|
25
|
+
@encoded=""
|
26
|
+
@unencoded=""
|
27
|
+
@required_septets=0
|
28
|
+
@chars=0
|
29
|
+
|
30
|
+
# ??
|
31
|
+
#@dcs=nil
|
32
|
+
|
33
|
+
# @part_nr=nil
|
34
|
+
# @total_parts=nil
|
35
|
+
# @message_ref=nil
|
36
|
+
|
37
|
+
def initialize(encoded,unencoded,chars,required_septets,tainted=false)
|
38
|
+
@encoded=encoded
|
39
|
+
@unencoded=unencoded
|
40
|
+
@chars=chars
|
41
|
+
@required_septets=required_septets
|
42
|
+
@tainted=tainted
|
43
|
+
|
44
|
+
# @part_nr=1
|
45
|
+
# @total_parts=1
|
46
|
+
# @message_ref=0
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|