Project

pdu_tools

0.01
No commit activity in last 3 years
No release in over 3 years
Tools for encoding and decoding GSM SMS PDUs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.2.3
 Project Readme

pdu_tools

Tools for encoding and decoding GSM SMS PDUs.

Usage

Encoding SMS message

encoder = PDUTools::Encoder.new recipient: "+421910100100", message: "This is a message"
pdus = encoder.encode # => [#<PDUTools::PDU:0x007fd5a4a1d908 @pdu_hex="0001000C9124910101100000001154747A0E4ACF416150BB3C9F87CF65">]

in pdus variable is array of PDUs, if the message is too long it is separated to multiple PDUs.

Decoding SMS message

decoder = PDUTools::Decoder.new "0001000C9124910101100000001154747A0E4ACF416150BB3C9F87CF65", :ms_to_sc
message_part = decoder.decode # => #<PDUTools::MessagePart:0x007fd5a503a9f8 @address="+421910100100", @body="This is a message", @timestamp=nil, @validity_period=nil, @user_data_header=nil>

in message_part variable is now MessagePart object which contains information extracted from the PDU, you can check if the message is complete using message_part.complete? to see if message was separated in multiple PDUs using User Data Header.

There is difference when PDU is comming from MS(Mobile Station) to SC(Service Center) or reverse. You need to specify the direction of PDU in decoder's second parameter: :ms_to_sc or :sc_to_ms.

This tool was build with help of this document

Features

  • Encoding 7 bit and 16 bit characters
  • Decoding 7 bit, 8 bit and 16 bit characters
  • Encoding and decoding User Data Header - used for concatenating SMS messages