SMPPEX.Pdu.Multipart.split_message

You're seeing just the function split_message, go back to SMPPEX.Pdu.Multipart module for more information.
Link to this function

split_message(ref_num, message, max_len)

View Source

Specs

split_message(ref_num :: integer(), message :: binary(), max_len :: integer()) ::
  split_result()

Splits message into parts prepending each part with multipart information UDH so that the resulting size of each part does not exceed max_len bytes.

The result is one of the following:

  • {:ok, :unsplit} if the message already fits into max_len bytes;
  • {:ok, :split, parts} if the message was succesfully split into parts;
  • {:error, reason} in case of errors.

Example

iex> SMPPEX.Pdu.Multipart.split_message(123, "abc", 3)
{:ok, :unsplit}

iex> SMPPEX.Pdu.Multipart.split_message(123, "abcdefg", 6)
{:error, "Invalid limits for splitting message"}

iex> SMPPEX.Pdu.Multipart.split_message(123, "abcdefghi", 8)
{:ok, :split, [
  <<0x05, 0x00, 0x03, 0x7b, 0x05, 0x01, "ab">>,
  <<0x05, 0x00, 0x03, 0x7b, 0x05, 0x02, "cd">>,
  <<0x05, 0x00, 0x03, 0x7b, 0x05, 0x03, "ef">>,
  <<0x05, 0x00, 0x03, 0x7b, 0x05, 0x04, "gh">>,
  <<0x05, 0x00, 0x03, 0x7b, 0x05, 0x05, "i">>
]}
Link to this function

split_message(ref_num, message, max_len, max_split)

View Source

Specs

split_message(
  ref_num :: integer(),
  message :: binary(),
  max_len :: integer(),
  max_split :: integer()
) :: split_result()

Splits message into parts not exceeding max_split bytes and prepending each part with multipart information UDH. The message is not split if its size does not exceed max_len bytes.

The results format is the same as in split_message/3.

Example

iex> SMPPEX.Pdu.Multipart.split_message(123, "abcdefghi", 0, 2)
{:ok, :split, [
  <<0x05, 0x00, 0x03, 0x7b, 0x05, 0x01, "ab">>,
  <<0x05, 0x00, 0x03, 0x7b, 0x05, 0x02, "cd">>,
  <<0x05, 0x00, 0x03, 0x7b, 0x05, 0x03, "ef">>,
  <<0x05, 0x00, 0x03, 0x7b, 0x05, 0x04, "gh">>,
  <<0x05, 0x00, 0x03, 0x7b, 0x05, 0x05, "i">>
]}