Telenor 3G modem + Python + C# = SMS Gateway
The 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):
|
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 ÆØÅ \n\n Supported!", "+4795441144"); comm.SendMessage(sms); |
The gateway has been tested the last couple of days – and it seems to work flawlessly.