Packages
smppex
0.0.4
3.3.0
3.2.4
3.2.3
3.2.2
3.2.1
3.2.0
retired
3.1.0
retired
3.0.6
3.0.5
3.0.4
3.0.3
3.0.2
3.0.1
3.0.0
2.4.0
2.3.3
2.3.2
2.3.1
2.3.0
2.2.9
2.2.8
2.2.7
2.2.6
2.2.5
2.2.4
2.2.3
2.2.2
2.2.1
2.2.0
2.1.0
2.0.1
2.0.0
1.0.1
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
SMPP 3.4 protocol and framework implemented in Elixir
Current section
Files
Jump to
Current section
Files
lib/smppex/pdu/factory.ex
defmodule SMPPEX.Pdu.Factory do
alias SMPPEX.Protocol.CommandNames
alias SMPPEX.Pdu
@message_state_delivered 2
def bind_transmitter(system_id, password, opts \\ %{}) do
bind(:bind_transmitter, system_id, password, opts)
end
def bind_receiver(system_id, password, opts \\ %{}) do
bind(:bind_receiver, system_id, password, opts)
end
def bind_transceiver(system_id, password, opts \\ %{}) do
bind(:bind_transceiver, system_id, password, opts)
end
def bind(command_name, system_id, password, opts \\ %{}) when command_name == :bind_transceiver or command_name == :bind_transmitter or command_name == :bind_receiver do
mandatory = opts
|> Map.put(:system_id, system_id)
|> Map.put(:password, password)
bind(command_name, mandatory)
end
def bind(command_name, opts) when command_name == :bind_transceiver or command_name == :bind_transmitter or command_name == :bind_receiver do
{:ok, command_id} = CommandNames.id_by_name(command_name)
Pdu.new(
command_id,
opts
)
end
def bind_transmitter_resp(command_status, system_id \\ "") do
{:ok, command_id} = CommandNames.id_by_name(:bind_transmitter_resp)
bind_resp(command_id, command_status, system_id)
end
def bind_receiver_resp(command_status, system_id \\ "") do
{:ok, command_id} = CommandNames.id_by_name(:bind_receiver_resp)
bind_resp(command_id, command_status, system_id)
end
def bind_transceiver_resp(command_status, system_id \\ "") do
{:ok, command_id} = CommandNames.id_by_name(:bind_transceiver_resp)
bind_resp(command_id, command_status, system_id)
end
def bind_resp(command_id, command_status, system_id) do
Pdu.new(
{command_id, command_status, 0},
%{
system_id: system_id
}
)
end
def enquire_link do
{:ok, command_id} = CommandNames.id_by_name(:enquire_link)
Pdu.new(command_id)
end
def enquire_link_resp(command_status \\ 0) do
{:ok, command_id} = CommandNames.id_by_name(:enquire_link_resp)
Pdu.new({command_id, command_status, 0})
end
def submit_sm({source_addr, source_addr_ton, source_addr_npi}, {dest_addr, dest_addr_ton, dest_addr_npi}, message, registered_delivery \\ 0) do
{:ok, command_id} = CommandNames.id_by_name(:submit_sm)
Pdu.new(
command_id,
%{
source_addr: source_addr,
source_addr_ton: source_addr_ton,
source_addr_npi: source_addr_npi,
destination_addr: dest_addr,
dest_addr_ton: dest_addr_ton,
dest_addr_npi: dest_addr_npi,
short_message: message,
registered_delivery: registered_delivery
}
)
end
def submit_sm_resp(command_status, message_id \\ "") do
{:ok, command_id} = CommandNames.id_by_name(:submit_sm_resp)
Pdu.new(
{command_id, command_status, 0},
%{
message_id: message_id
}
)
end
def deliver_sm({source_addr, source_addr_ton, source_addr_npi}, {dest_addr, dest_addr_ton, dest_addr_npi}, message) do
{:ok, command_id} = CommandNames.id_by_name(:deliver_sm)
Pdu.new(
command_id,
%{
source_addr: source_addr,
source_addr_ton: source_addr_ton,
source_addr_npi: source_addr_npi,
destination_addr: dest_addr,
dest_addr_ton: dest_addr_ton,
dest_addr_npi: dest_addr_npi,
short_message: message
}
)
end
def delivery_report(message_id, {source_addr, source_addr_ton, source_addr_npi}, {dest_addr, dest_addr_ton, dest_addr_npi}, message \\ "", message_state \\ @message_state_delivered) do
{:ok, command_id} = CommandNames.id_by_name(:deliver_sm)
Pdu.new(
command_id,
%{
source_addr: source_addr,
source_addr_ton: source_addr_ton,
source_addr_npi: source_addr_npi,
destination_addr: dest_addr,
dest_addr_ton: dest_addr_ton,
dest_addr_npi: dest_addr_npi,
short_message: message
},
%{
message_state: message_state,
receipted_message_id: message_id
}
)
end
def deliver_sm_resp(command_status \\ 0) do
{:ok, command_id} = CommandNames.id_by_name(:deliver_sm_resp)
Pdu.new({command_id, command_status, 0})
end
end