As part of my work re-factoring PySMS I decided to abstract some parts into separate libraries. The first victim of this is the UCP message parser and creator.

Until now it was a bit of a bricolage. The functionality it had was very specific to the SMS Server and it was not easy to extend and not useful for general use so I decided to create ucplib. It is created from scratch as a general purpose UCP/EMI library and the aim is to provide all of the functionality demanded by the UCP/EMI specification v4.6.

The library is based on ideas from Net::UCP (Perl), Kannel © and things I learn from the PySMS development.

As I currently have no version online here a short excerpt how the library will look like:

To create a new UCP Message from a string just do:

msg = UcpMsg('00/00041/O/01/0888444///2/716436383334/C5')

msg has a fields attribute which is a dict with all the values of the corresponding message type.

msg.fields
{'ac': '', 'o_r': 'O', 'nmsg': '716436383334', 'checksum': 'C5',
'oadc': '', 'trn': '00', 'len': '00041', 'mt': '2', 'adc': '0888444', 'ot': '01'}

To create a string representation just do :

msg.pack(delimiter=False)
'00/00041/O/01/0888444///2/716436383334/C5'

Currently the library works for message type 01 and I’m working to support the full specification. When the base is working I will upload it to Lanuchpad.

If you are interested in this library or if you have some questions, just leave a comment and I will answer.