Permalink
Browse files

Merge pull request #1 from aerosol/master

ucp_common dependency / code cleanup
  • Loading branch information...
2 parents c7fde14 + 2bfb8bc commit ab6884ea737529670c815de9afd561729c9d5384 Adam Rutkowski committed Jan 29, 2012
Showing with 61 additions and 638 deletions.
  1. +1 −1 Makefile
  2. +0 −36 include/ira.hrl
  3. +0 −206 include/ucp_syntax.hrl
  4. +2 −0 rebar.config
  5. +0 −67 src/ucp_7bit.erl
  6. +0 −22 src/ucp_ira.erl
  7. +30 −18 src/ucp_server.erl
  8. +6 −19 src/ucp_simulator_app.erl
  9. +22 −24 src/ucp_simulator_sup.erl
  10. +0 −245 src/ucp_utils.erl
View
@@ -20,4 +20,4 @@ clean-deps:
@$(REBAR) delete-deps
run: all
- erl -pa deps/*/ebin -pa ebin -s lager -s ucp_simulator start
+ erl -pa deps/*/ebin -pa ebin -boot start_sasl -s lager -s ucp_simulator_app
View
@@ -1,36 +0,0 @@
--define(IRA, [
- {$!, 33},
- {$", 34},
- {$#, 35},
- {$$, 36},
- {$%, 37},
- {$&, 38},
- {$', 39},
- {$(, 40},
- {$), 41},
- {$*, 42},
- {$+, 43},
- {$,, 44},
- {$-, 45},
- {$., 46},
- {$/, 47},
-
- {$:, 58},
- {$;, 59},
- {$<, 60},
- {$=, 61},
- {$>, 62},
- {$?, 63},
- {$@, 64},
-
- {$[, 91},
- {$\\, 92},
- {$], 93},
- {$^, 94},
- {$_, 95},
-
- {${, 123},
- {$|, 124},
- {$}, 125},
- {$~, 126}
-]).
View
@@ -1,206 +0,0 @@
--record(ucp_header, {
- trn = "00",
- %% Transaction reference number, right justified with leading zero.
- len = "00000",
- %% Total number of IRA characters contained
- %% between stx and etx, right justified with leading zeros.
- o_r = "O",
- %% “O” indicates operation, “R” indicates result
- ot = "00"
- %% Operation Type:
- %% 01 Call input operation
- %% 02 Multiple address call input operation
- %% 03 Call input with supplementary services operation
- %% 30 SMS message transfer operation
- %% 31 SMT alert operation
- %% 5x 50-series, see chapter 5, 7
- %% 6x 60-series, see chapter 6, 7
- }).
-
--record(ucp_cmd_31,{
- adc = "", %% Address code for the SMT, maximum length is 16 digits.
- pid = "" %% SMT:
- %% 0100 Mobile Station
- %% 0122 Fax Group 3
- %% 0131 X.400
- %% 0138 Menu over PSTN
- %% 0139 PC appl. via PSTN
- %% 0339 PC appl. via X.25
- %% 0439 PC appl. via ISDN
- %% 0539 PC appl. via TCP/IP
- %% 0639.....PC appl. via abbreviated number
- }).
-
--record(ucp_cmd_5x, {
- adc = "", %% Address code recipient for the SM OadC 16 Num.
- %% String Address code originator
- %% If the OTOA field indicates alphanumeric OAdC.
- %% A 22 character string corresponds with a max. 11 character alphanumeric string.
- oadc = "", %% Address code originator, maximum length is 16 digits.
- ac = "", %% Authentication code originator (min 4 char., max 16 char)
- nrq = "", %% Notification Request 0 = NAdC not used 1 = NAdC used
- nadc = "", %% Notification Address
- nt = "", %% Notification Type1:
- %% Buffered message notification (BN),
- %% Delivery Notification (DN),
- %% Non-delivery notification (ND),
- %% 0 default value, 1 = DN, 2 = ND, 3 = DN+ND, 4 = BN, 5 = BN+DN, 6 = BN+ND, 7 = all.
- npid = "", %% Notification PID value:
- %% 0100 Mobile Station
- %% 0122 Fax Group 3
- %% 0131 X.400
- %% 0138 Menu over PSTN
- %% 0139 PC appl. over PSTN (E.164)
- %% 0339 PC appl. over X.25 (X.121)
- %% 0439 PC appl. over ISDN (E.164)
- %% 0539 PC appl. over TCP/IP
- lrq = "", %% Last Resort Address request: 0 = LRAd not used 1 = LRAd used
- lrad = "", %% Last Resort Address
- lpid = "", %% LRAd PID value:
- %% 0100 Mobile Station
- %% 0122 Fax Group 3
- %% 0131 X.400
- %% 0138 Menu over PSTN
- %% 0139 PC appl. over PSTN (E.164)
- %% 0339 PC appl. over X.25 (X.121)
- %% 0439 PC appl. over ISDN (E.164)
- %% 0539 PC appl. over TCP/IP
- dd = "", %% Deferred Delivery requested: 0 = DDT not used 1 = DDT used
- ddt = "", %% Deferred delivery time in DDMMYYHHmm
- vp = "", %% Validity period in DDMMYYHHmm
- rpid = "", %% Replace PID2, value 0000...0071, 0095,
- %% 0127(SIM Data Download), 0192...0255.
- scts = "", %% Service Centre Time Stamp in DDMMYYHHmmss.
- %% For a Short Message this is the time stamp of the Short Message itself.
- %% For a Notification this is the time stamp of the corresponding Short Message.
- dst = "", %% Delivery status:
- %% 0 = delivered
- %% 1 = buffered (see Rsn)
- %% 2 = not delivered (see Rsn)
- rsn = "", %% Reason code, value '000'...'255'.
- %% Code can be found in an SMSC configuration file witch can be
- %% changed by the operator. (See appendix A)
- dscts = "", %% Delivery time stamp in DDMMYYHHmmss.
- %% Indicates the actual time of delivery of the Short Message.
- mt="3", %% Message Type. Associated parameters depend on the value of MT.
- nb = "",
- msg = "",
- mms = "", %% More Messages to Send (to the same SME)
- pr = "", %% Priority Requested
- dcs = "", %% Deprecated. Data Coding scheme:
- %% 0 = default alphabet
- %% 1 = user defined data ('8 bit')
- mcls = "", %% Message Class:
- %% 0 = message class 0
- %% 1 = message class 1
- %% 2 = message class 2
- %% 3 = message class 3
- rpi = "", %% Reply Path:
- %% 1 = request
- %% 2 = response
- cpg = "", %% (reserved for Code Page)
- rply = "", %% (reserved for Reply type)
- otoa="1139", %% Originator Type Of Address:
- %% 1139 The OadC is set to NPI telephone and TON international.
- %% 5039 The OAdC contains an alphanumeric address (see OAdC and below).
- %% Leave OTOA empty for a numeric address in the OAdC.
- hplmn = "", %% Home PLMN Address
- xser = "", %% Extra Services
- %% With the XSer field one or more additional services can be specified.
- %% These services consist of IRA encoded data constructed in the
- %% following common format: TTLLDD...
- %% TT: represents two HEX characters defining the type of service.
- %% For a description of available services refer to section “Description Of XSer Extra Services”
- %% LL: represents two HEX characters defining the number of octets
- %% present in the data field DD.
- %% (Note that the number of HEX characters in the data DD is twice the number of octets)
- %% DD...: represents a stream of HEX characters defining the service specific data itself.
- %% If more than one additional service is to be specified in one message,
- %% this service information is concatenated without any separators, i.e.
- %% TT1LL1DD1...DD1TT2LL2DD2..DD2
- %% The above construction is designed such that in the
- %% future additional service types can be added to the XSer field.
- res4 = "", %% (reserved for future use)
- res5 = "" %% (reserved for future use)
- }).
-
--record(ucp_cmd_60, {
- oadc = "",
- %% Any valid X.121, E164, TCP/IP or abbreviated address, excluding prefixes
- oton = "", %% Originator Type of Numbering
- %% 1 = International number (starts with the country code)
- %% 2 = National number (default value if omitted)
- %% 6 = Abbreviated number (short number alias)
- onpi = "", %% Originator Numbering Plan Id:
- %% 1 = E.164 address (default value if omitted)
- %% 3 = X121 address
- %% 5 = Private (TCP/IP address/abbreviated number address)
- styp = "", %% Subtype of operation:
- %% 1 = open session
- %% 2 = reserved
- %% 3 = change password
- %% 4 = open provisioning session
- %% 5 = reserved
- %% 6 = change provisioning password
- pwd = "", %% Current password encoded into IRA characters,
- npwd = "", %% New password encoded into IRA characters
- vers = "", %% Version number 0100'
- ladc = "", %% Address to be filled in, removed from or checked in a
- %% VSMSC list, containing a valid X.121, E.164
- %% or TCP/IP address excluding prefixes
- lton = "", %% Type of Number list address:
- %% 1 = International number (starts with the country code)
- %% 2 = National number (default value if omitted)
- lnpi = "", %% Numbering Plan Id list address
- opid = "", %% Originator Protocol Identifier: 00 = Mobile station 39 = PC application
- res1 = ""
- }).
-
--record(ucp_cmd_61, {
- oadc = "", %% Any valid X.121, E164, TCP/IP or abbreviated address, excluding prefixes
- oton = "", %% Originator Type of Number:
- %% 1 = International number (starts with the country code)
- %% 2 = National number (default value if omitted)
- %% 6 = Abbreviated number (short number alias)
- onpi = "", %% Originator Numbering Plan Id:
- %% 1 = E.164 address (default value if omitted)
- %% 3 = X121 address
- %% 5 = Private (TCP/IP address/abbreviated number address)
- styp = "", %% Subtype of operation:
- %% 1 = open session
- %% 2 = reserved
- %% 3 = change password
- %% 4 = open provisioning session
- %% 5 = reserved
- %% 6 = change provisioning password
- pwd = "", %% Current password encoded into IRA characters,
- npwd = "", %% New password encoded into IRA characters
- vers = "", %% Version number 0100'
- ladc = "", %% Address to be filled in, removed from or checked in a
- %% VSMSC list, containing a valid X.121, E.164
- %% or TCP/IP address excluding prefixes
- lton = "", %% Type of Number list address:
- %% 1 = International number (starts with the country code)
- %% 2 = National number (default value if omitted)
- lnpi = "",
- res1 = "",
- res2 = ""
- }).
-
--record(short_ack,{
- ack = "A", %% Positive acknowledgement Char A
- sm = "" %% System message , String
- }).
-
--record(ack,{
- ack = "A", %% Positive acknowledgement Char A
- mvp = "",
- sm = "" %% System message , String
- }).
-
--record(nack, {
- nack = "N", %% Negative acknowledgement
- ec = "", %% Error Code, 2 Chars
- sm = "" %% System message , String
- }).
-
View
@@ -4,6 +4,8 @@
{lib_dirs, ["deps"]}.
{deps, [
+ {'ucp_common', ".*", {git, "git://github.com/jtendo/ucp_common.git",
+ "master"}},
{'lager', ".*", {git, "git://github.com/basho/lager.git", "master"}}
]}.
View
@@ -1,67 +0,0 @@
--module(ucp_7bit).
-
--author("dawid.figiel@gmail.com").
--compile(export_all).
-
-%% 7-bit encoding
-%% ---------------------------------------------------------------------
-%% Function for converting string to 7-bit encoding according to:
-%% GSM 03.38 Version 5.3.0
-%% ---------------------------------------------------------------------
-%% Initial Function call: to_7bit(String).
-%% ---------------------------------------------------------------------
-%% Input: String containing only ASCII characters
-%% ---------------------------------------------------------------------
-%% Output: Binary encoded String
-%% ---------------------------------------------------------------------
-to_7bit([]) -> <<>>;
-to_7bit(String) -> to_7bit(list_to_binary(String),<<>>,1).
-
-to_7bit(<<Char1:8>>,<<>>,_Cntr) -> <<<<Char1>>/binary>>;
-to_7bit(<<_Char1:8>>,Out,8) -> Out;
-to_7bit(<< Char1:8>>,Out,7) ->
-%% << Out/binary,<<((Char1 bsr 6) bor 26)>>/binary >>;
- << Out/binary,<<((Char1 bsr 6) bor 64)>>/binary >>;
-to_7bit(<<Char1:8>>,Out,Cntr) ->
- << Out/binary,<<(Char1 bsr (Cntr - 1))>>/binary >>;
-to_7bit(<<_Char:8,In/binary>>,Out,8)->
- to_7bit(In,Out,1);
-to_7bit(<<Char1:8,Char2:8,In/binary>>,Out,Cntr)->
- SRChar1 = Char1 bsr (Cntr - 1),
- NewChar1 = <<Char2:Cntr,SRChar1:(8-Cntr)>>,
- to_7bit(<<<<Char2>>/binary,In/binary>>,<<Out/binary,NewChar1/binary>>,Cntr+1).
-
-%% 7-bit decoding
-%% ---------------------------------------------------------------------
-%% Function for converting 7-bit encoding to String according to:
-%% GSM 03.38 Version 5.3.0
-%% ---------------------------------------------------------------------
-%% Initial Function call: from_7bit(SevenBitEncodedBinary).
-%% ---------------------------------------------------------------------
-%% Input: Binary encoded String
-%% ---------------------------------------------------------------------
-%% Output: String containing only ASCII characters
-%% ---------------------------------------------------------------------
-from_7bit(List) when is_list(List) -> from_7bit(list_to_binary(List));
-from_7bit(<<>>) -> [];
-from_7bit(Bin) ->
- from_7bit(Bin,<<>>,<<>>,1).
-
-%%from_7bit(<<>>,<<13>>,Out,8) ->
-from_7bit(<<>>,<<32>>,Out,8) ->
- binary_to_list(Out);
-from_7bit(<<>>,<<CharN>>,Out,8) ->
- binary_to_list(<<Out/binary,CharN:8>>);
-from_7bit(<<>>,<<0>>,Out,_Cntr) ->
- binary_to_list(Out);
-from_7bit(<<>>,<<CharN>>,Out,Cntr) ->
- binary_to_list(<<Out/binary,0:(9-Cntr),CharN:(Cntr-1)>>);
-from_7bit(<<CharN:1,CharO:7,In/binary>>,<<CharI>>,Out,8) ->
- from_7bit(In,<<CharN>>,<<Out/binary,0:1,CharI:7,0:1,CharO:7>>,2);
-from_7bit(<<Byte:8,In/binary>>,<<>>,<<>>,1) ->
- CharN = Byte bsr 7,
- from_7bit(In,<<CharN>>,<<(Byte band 127)>>,2);
-from_7bit(<<Byte:8,In/binary>>,<<CharI>>,Out,Cntr) ->
- Char = (Byte bsl (Cntr - 1)) bor CharI,
- CharN = Byte bsr (8 - Cntr),
- from_7bit(In,<<CharN>>,<<Out/binary,0:1,Char:7>>,Cntr+1).
View
@@ -1,22 +0,0 @@
--module(ucp_ira).
--author('adam.rutkowski@jtendo.com').
--export([to/2]).
--include("ira.hrl").
-
-to(ira, Char) when is_integer(Char) ->
- case lists:keyfind(Char, 1, ?IRA) of
- {_, Ira} -> Ira;
- false -> Char
- end;
-to(ascii, Char) when is_integer(Char) ->
- case lists:keyfind(Char, 2, ?IRA) of
- {Ascii, _} -> Ascii;
- false -> Char
- end;
-to(Type, Str) when is_atom(Type), is_list(Str) ->
- lists:foldl(fun(Char, Acc) ->
- Acc ++ [to(Type, Char)]
- end, "", Str).
-
-
-
Oops, something went wrong.

0 comments on commit ab6884e

Please sign in to comment.