python-messaging: SMS encoder/decoder for the masses

___

python-messaging is a pure python SMS encoder decoder. Some of its features:

  • 7bit/8bit/UCS2 encoding: Now you can text your Chinese friend
  • Multipart SMS: Because sometimes 140 chars are not enough
  • SMS status report: Be sure they read it
  • Stuff you take for granted: Alphanumeric addresses, timezone awareness, good test coverage
  • Used in production by several projects: Wader, BCM and MobileManager

As far as we know, is the most advanced SMS encoder/decoder written in pure Python (otherwise we would be using it ;) If you need a PDU encoder/decoder for your project, python-messaging should fit your needs.

API walkthrough

The only class you need to deal with is PDU. It is able to encode and decode PDUs with two simple functions: encode_pdu and decode_pdu. encode_pdu receives a number and the text you want to send, plus a number of optional parameters where you can specify smsc, validity, reference number, whether you want a confirmation or not, etc. The function returns a list of tuples with the pdu length and the pdu as a string ready to be sent via the serial port. Why a list of tuples? Well, you might want to send a SMS with more than 140 chars. If so, every fragment of the SMS will be a tuple in the list.

python-messaging can not send the SMS, is just an encoder! This is what you need to do in order to send a SMS with pyserial and python-messaging:

It was not too hard was it? This code does not deal with PIN authentication by the way, so be sure your device is already authenticated, or auth is disabled. Oh by the way, sending a UCS2 encoded message is easy, just pass a unicode string and the PDU object will do the right thing.

Decoding a PDU is a no brainer:

This PDU string was taken from redxanela's online decoder default text, you can compare python-messaging's output with redxanela. Check out the method signatures for what options accepts. I need to write a thorough documentation one of this days, this is an initial effort in that way.

Hope you liked this walkthrough and that python-messaging fits your project needs. I didn't want to bother you with the project's history, you can check it out in the README. Looking forward to any questions/contributions ;-)


comments powered by Disqus

Last posts

___

post thumbnail

Urban Airship 1.0 integration with an Android Phonegap app

post thumbnail

Urban Airship integration with an Android Phonegap app

post thumbnail

Sitemaps for Django static pages

post thumbnail

What I've been up to

post thumbnail

python-messaging: SMS encoder/decoder for the masses

post thumbnail

reStructuredText directive for google-code-prettify

post thumbnail

Playing with QML and DBus (Part 2)

post thumbnail

Playing with QML and DBus (Part 1)

post thumbnail

Testing ntrack

post thumbnail

minimoesfuerzo.org site details

Scroll top