by Njål

Telenor 3G modem + Python + C# = SMS Gateway

Bilde av Option Icon 225 modemThe past year we have been using an Android phone running SmsSync as a SMS gateway (connected to the server through USB). This setup requires that SMSSync is started & running and that the phone is sharing internet through the usb cable +++. If the server rebooted – then the SMS Gateway wouldn’t work until we set it up again. Not an ideal setup.

So I set out to replace it with something that was robust, stable and reboot friendly. It turned out the solution to this problem was in my desk drawer. An old Telenor 3G Option Icon 225 modem that we didn’t use anymore. I inserted a Network Norway SIM card into it – and shoved it into a usb port. The modem was locked and would only accept Telenor SIM cards. I should have guessed it.

Based on this blogpost by Dogbert – I was able to unlock the modem using these steps (I had to use pywin 2.1.4):

 

  1. Install python 2.6.x (32 bit version): http://www.python.org/download/releases/2.6/
  2. Install pywin32 – 2.1.4 – for python 2.6: http://sourceforge.net/projects/pywin32/files/
  3. Install pyserial: http://sourceforge.net/projects/pyserial/files/
  4. Download the unlocker (http://sites.google.com/site/dogber1/blag/msm-unlock-v1.6.zip) and unpack it (e.g. into the directory C:msm)
  5. Download a firmware update for the 3G modem from Option or T-Mobile
  6. Unpack the firmware update into the directory used above (e.g. C:msm)
  7. IMPORTANT: The superfire.exe file of the update is packed. For the newest update, the superfire.exe can be used as it is.
  8. Remove the SIM card from the modem and plug it in . Make sure that you have the latest drivers from the option website installed before you start msm_unlock.py. Also, close all the tools for the stick (‘connection manager’ etc.).
  9. Write down the unlock code. Unplug the stick, replug it and apply the unlock code with msm_apply.py. If the unlock code is not accepted, search the comments for a posting by “muxx” – he has given detailed instructions on how to manually enter the unlock code.
  10. Unplug and replug the stick once more and you’ve got yourself an unlocked 3G modem.

After unlocking the modem it was time to test it. I first started out in Putty – connecting to the COM3 port – which it was running at. Sending some AT* commands worked fine.

I then downloaded Stefay Mayr’s excellent .NET GSMCOMM Library – and imported the DLL’s into a new Visual Studio project. It turned out sending an SMS was extremely easy:

 

//Connect to modem
var comm = new GsmCommMain(3, 9600, 1000); //ComPort, BaudRate, Timeout
comm.Open();

//Send SMS
var sms = new SmsSubmitPdu("Unicode ÆØÅ nn Supported!", "+4795441144");
comm.SendMessage(sms);

 

The gateway has been tested the last couple of days – and it seems to work flawlessly.

  • http://blog.degree.no/bloggere/ Andreas

    :)