SMPPEX.Pdu.Multipart.extract

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

Specs

extract(SMPPEX.Pdu.t() | binary()) :: extract_result()

Extracts multipart information from PDU or directly from binary message. This function is deprecated. Use extract_from_pdu/1 or extract_from_message/1 instead.

Returns one of the following:

  • {:ok, :single, message} if the message does not contain any multipart information and represents a single message;
  • {:ok, {ref_num, count, seq_num}, message} if the original message contains multipart information in UDH fields. The outcoming message is cleared from UDH bytes.
  • {:error, reason}

Example

iex> data = <<0x05, 0x00, 0x03, 0x03, 0x02, 0x01, "message">>
iex> SMPPEX.Pdu.Multipart.extract(data)
{:ok, {3,2,1}, "message"}

iex> data = <<0x06, 0x08, 0x04, 0x00, 0x03, 0x02, 0x01, "message">>
iex> SMPPEX.Pdu.Multipart.extract(data)
{:ok, {3,2,1}, "message"}

iex> pdu = Pdu.new({1,0,1}, %{esm_class: 0b01000000, short_message: <<0x05, 0x00, 0x03, 0x03, 0x02, 0x01, "message">>})
iex> SMPPEX.Pdu.Multipart.extract(pdu)
{:ok, {3,2,1}, "message"}

iex> pdu = Pdu.new({1,0,1}, %{short_message: <<0x05, 0x00, 0x03, 0x03, 0x02, 0x01, "message">>})
iex> SMPPEX.Pdu.Multipart.extract(pdu)
{:error, "Message is not multipart"}