SMPPEX.Pdu.UDH.add

You're seeing just the function add, go back to SMPPEX.Pdu.UDH module for more information.

Specs

add([ie()], binary()) :: {:ok, binary()} | {:error, any()}

Encodes IEs and prepends message with the encoded value.

The result is one of the following:

  • {:ok, message} where message is the original message prefixed with UDH;
  • {:error, reason} in case of errors.

Example

iex> ies = [{0x05, <<0x06, 0x2d, 0x00, 0x00>>}, {0x00, <<0x01, 0x02, 0x01>>}]
iex> SMPPEX.Pdu.UDH.add(ies, "message")
{:ok, <<0x0B, 0x05, 0x04, 0x06, 0x2d, 0x00, 0x00, 0x00, 0x03, 0x01, 0x02, 0x01, "message">>}

iex> ies = [{0, 123}]
iex> SMPPEX.Pdu.UDH.add(ies, "message")
{:error, "Invalid UDH IE data"}

iex> ies = [{345, "ie"}]
iex> SMPPEX.Pdu.UDH.add(ies, "message")
{:error, "Invalid UDH IE id"}

iex> ies = [{-1, "ie"}]
iex> SMPPEX.Pdu.UDH.add(ies, "message")
{:error, "Invalid UDH IE id"}

iex> ies = [{0, <<1 :: integer-size(2040)>>}]
iex> SMPPEX.Pdu.UDH.add(ies, "message")
{:error, "UDH is too long"}