Click here to Skip to main content
15,887,485 members
Articles / Programming Languages / C#

Implementing an SMS Quiz Server Using a GSM Modem Enabled Mobile Phone

Rate me:
Please Sign up or sign in to vote.
4.82/5 (22 votes)
19 Jul 2006CPOL6 min read 177.3K   9.2K   104   40
A very simple application that uses SMS to send quiz questions and receive answers and notify winners at the end of the day using a Nokia 6610i and mCore.
Sample Image - SMSQuizServer.jpg

Introduction

This is a great tool to play with SMS, especially when it comes to sending messages to your near and dear ones. Everyone loves it more or less. For years, I have been using SMS without caring much how it really works. Recently, I discovered that using this small technology, some interesting work can be done. I always wondered how SMS quiz is implemented as shown on television or in the newspaper until I found my own developed SMS server with my Nokia 6610i. I came up with an idea of a Quiz Server which is implemented using .NET and SMS.

A Very Few Words about SMS (Short Message Service)

SMS stands for Short Message Service. It is a technology that enables the sending and receiving of messages between mobile phones. SMS first appeared in Europe in 1992. It was included in the GSM (Global System for Mobile Communications) standards right at the beginning. Later it was ported to wireless technologies like CDMA and TDMA. The GSM and SMS standards were originally developed by ETSI. ETSI is the abbreviation for European Telecommunications Standards Institute. Now the 3GPP (Third Generation Partnership Project) is responsible for the development and maintenance of the GSM and SMS standards.

A Little About mCore

mCore™ SMS is a powerful and easy to use ActiveX Component that can be used in your Windows applications and ASP Web pages for mobile messaging using GSM mobile phones or GSM modems connected to serial port or infrared port. Using mCore in your applications allows you to:

  • Send text messages
  • Read incoming text messages
  • Send WAP Push
  • Set various messaging and network parameters (PIN, SMSC, Message Memory, etc.)
  • Read modem and network information (Manufacturer, IMEI, Model, Signal Strength, etc.)

A rich set of properties, methods and its compatibility with wide range of GSM mobile phones and GSM modems makes mCore™ the best choice for any type of mobile messaging application.

The Project

It is not a core project and most intellectual peoples out there will think it as a newbie project but it is really a great playing tool for beginners. In the beginning, I found that I can download photos and upload applications with the Nokia PC Suite, I wondered how I could send SMS using my own program. After several Google searches, I found Nokia PC Suite Connectivity API 1.1. I was unable to use it properly because I have very little knowledge about the development suite. However, I began searching again. I came across AT commands. I was feeling like I was in the middle of MS DOS 6.2 age. The white window was distracting me a lot. I only wanted to send or receive SMS and do some magic with it. I was searching with all my fingers and all the keywords. I was searching for a .NET compliant thing that would ease my task.

At last I found mCore from here. I fell in love with the component. It was love at first sight and I eventually knew it was the right thing for my work. It had detailed help and a wonderful demo project. I began to tweak and made my first Quiz Server that was able to process and notify winners of a Quiz session daily.

The Quiz Server scans for users who sent SMS to get a question every day. At the end of the day, a random user is chosen among all the users who have given the correct answer.

The Ingredients

  • Nokia phone with GSM modem
  • Serial Cable
  • mCore from here

The Procedure

  1. Start/Run the project by pressing F5 and wait infinitely after connecting.
  2. A user sends a SMS with QUES.
  3. The server scans each message and parses to find the request of question and sends the question of the day.
  4. If the user sends SMS with ANS A.
  5. The server records the answer. User cannot send several answers.
  6. At the end of the day, a random user is chosen and a prize SMS is sent to him/her.

The admin of the server can change the question of the day very easily.

Sample screenshot

The Core Code

In the following code, the server scans for all messages in the inbox and sends them to ProcessSMS to parse and save the data. After the message has been parsed, the message is deleted.

C#
private void GetMessageFromMobile() 
 { 
     objSMS.MessageMemory = SMS.EnumMessageMemory.SM; 
 
     mCore.Inbox objInbox = objSMS.Inbox(); 
 
     for (int i = 1; i <= objInbox.Count ; i++) 
     { 
         txtNumber.Text = objInbox.Message(i).Phone.ToString(); 
         txtMessage.Text = objInbox.Message(i).Text.ToString(); 
         bool status = ProcessSMS(txtNumber.Text, txtMessage.Text); 
         if (status == true) 
         { 
             // Delete the Message that has already being parsed 
             objSMS.Inbox().Message(i).Delete(); 
         } 
     } 
 }

This part connects the application with the mobile. Make sure you know the Port number and the SMSC numbers. If you do not know the port name, go to the device manager in My Computer and see the properties in the GSM modem of your mobile phone.

C#
private void btnConnect_Click(object sender, EventArgs e) 
 { 
     try 
     { 
         btnConnect.Enabled = false; 
         objSMS.Port = "COM7"; 
         objSMS.BaudRate = SMS.EnumBaudRate.BaudRate_115200; 
         objSMS.DataBits = SMS.EnumDataBits.Eight; 
         objSMS.Parity = SMS.EnumParity.None; 
         objSMS.StopBits = SMS.EnumStopBits.One; 
         objSMS.FlowControl = SMS.EnumFlowControl.None; 
         objSMS.PIN = "1234"; 
         objSMS.SMSC = "+880150159999"; 
 
         objSMS.Connect(); 
         lbxStatus.Items.Add(objSMS.Model + " Connected "); 
         MyTimer.Interval = 10000; 
         MyTimer.Start(); 
 
         btnDisconnect.Enabled = true; 
     } 
     catch (Exception ex) 
     { 
         btnConnect.Enabled = true; 
         MessageBox.Show(ex.ToString()); 
     } 
 }

This timer scans for messages and processes the winner for the previous day. It also refreshes the inbox. Without refreshing the inbox, new messages will not be detected.

C#
private void MyTimer_Tick(object sender, EventArgs e) 
 { 
     Application.DoEvents(); 
     if(objSMS.Inbox().Count > 0) 
     { 
         GetMessageFromMobile(); 
     } 
     ProcessWinner(); 
     objSMS.Inbox().Refresh(); 
 }

The Server in Action

Sample screenshot

Pitfalls

Good things do not always come for free. I have used mCore which is not free of cost. It sends a message at the bottom of the real message with Powered by logixmobile.com at the end of each message sent. So if you don't want the message, please buy the component from logixmobile.com. You can also write the component by communicating with the serial port with any programming language. Well, that is another story. And, most important is, why invent wheels when it's already there.

Lastly, using a mobile phone or GSM/GPRS modem to send SMS messages has a major drawback, that is the SMS sending rate is too low. Only 6-10 SMS messages can be sent per minute (when the "SMS over GSM" mode is used). The performance is not affected by the connection between the computer and the mobile phone or GSM/GPRS modem (i.e. the SMS sending rate is about the same no matter whether the mobile phone or GSM/GPRS modem is connected to the computer through a serial cable, USB cable, Bluetooth link or infrared link) and does not depend on whether a mobile phone or GSM/GPRS modem is used (i.e. the SMS sending rate is about the same no matter if a mobile phone or a GSM/GPRS modem is used). The determining factor for the SMS sending rate is the wireless network.

Conclusion

This project will inspire people who have limited components to test and who want to use a SMS based server at home. This project will eventually lead novice programmers to build more useful and robust SMS based applications. I will refine the code or sort out the buggy things if someone wants to learn or share more of it. Till then, Ba-Bye.

History

  • 19th July, 2006: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO FastBikri.com
Bangladesh Bangladesh
Zakaria has a keen interest in developing new solutions and exploring new technologies. He has a wide experience in web technologies and business solutions.

Visit my works @ https://play.google.com/store/apps/dev?id=8713255821916123360

His latest project includes Library Management System for University of Dhaka using ASP.NET and Sql Server.

Zakaria completed Masters in Information Technology from Institute of Information Technology http://iit.univdhaka.edu/,
University of Dhaka, had his BSc in Computer Science from AIUB (www.aiub.edu).
School and college from SKBZBIS (www.skbzbis.com)

Latest Project : www.alamgroupae.com
for Alam Group of Companies, Abu Dhabi

Some of his Completed projects:

www.zakasoft.com
www.musaffah.info
www.shonpapri.com
www.skbzbis.com
www.bdembuae.org (The official website of Embassy of the People's Republic of Bangladesh, Abu Dhabi, United Arab Emirates)

Bangla Translation of the Holy Quran (C#/Access)
Library Management System (ASP.NET/C#/SQLServer)
Seat Reservation System (ASP.NET/C#/SQLServer)

Besides programming, he has published his first poetry book (na bola kothamala/Unspoken Words) and in the process of writing several new novels.

Founded ZakaSoft, a division of ZCom, Providing state-of-the-art solutions in United Arab Emirates.

Zakaria Lives in Abu Dhabi and enjoys his spare time in writing and music.

Comments and Discussions

 
AnswerRe: Problem with PIN Pin
Zakaria Bin Abdur Rouf12-Feb-07 6:15
Zakaria Bin Abdur Rouf12-Feb-07 6:15 
GeneralRunning without a connected mobile phone Pin
xaml.net13-Jan-07 2:08
xaml.net13-Jan-07 2:08 
Questionwhat s PIN Pin
hamid_m21-Oct-06 1:32
hamid_m21-Oct-06 1:32 
AnswerRe: what s PIN Pin
Colin Angus Mackay21-Oct-06 1:51
Colin Angus Mackay21-Oct-06 1:51 
GeneralNewMessageReceived Event instead of Inbox.Refresh method Pin
Santanu Biswas7-Aug-06 4:42
Santanu Biswas7-Aug-06 4:42 
GeneralRe: NewMessageReceived Event instead of Inbox.Refresh method Pin
Zakaria Bin Abdur Rouf12-Aug-06 9:33
Zakaria Bin Abdur Rouf12-Aug-06 9:33 
GeneralReal world SMS services Pin
Tili3-Aug-06 3:01
Tili3-Aug-06 3:01 
GeneralRe: Real world SMS services Pin
Santanu Biswas7-Aug-06 4:29
Santanu Biswas7-Aug-06 4:29 
Just wanted to make some comments on Tili's message...

Tili wrote:
I don't agree with the idea of buying a control for such a simple task.


I would rather say that for developers who dont wish to complicate their life by trying to understand the AT Commands etc then a third party component/library is the best option. The developer can focus on their application rather than spending time to understand principles of serial communication and AT Commands! Just imagine if a developer simply needs to pickup some information from database and send it out as SMS, then is it wise for him to go through the pain of understanding principles of serial communication or understanding complexity of AT Commands? As the author has rightly said - What is the point in trying to re-invent the wheel? Smile | :)


Tili wrote:
http://www.gnokii.org[^] is a nice piece of open software.


Gnokii is great, but my personal opinion is that it is too Nokia centric and Nokia modems are not only the most expensive ones but also most non-standard when it comes to following the ETSI standards for GSM Modems. When everyone else follows simple serial communication and AT Commands (as per ETSI Standards), Nokia seems to have this fancy for their proprietary protocol FBUS & MBUS (they even follow CIMD instead of SMPP when it comes to SMSC connectivity!). Try using Gnokii with modems from Sony Ericsson, Siemens, Wavecom, Falcom, iTegno, SIMCOM, Teltonika etc and you will know what I am exactly talking about! Wink | ;)


Tili wrote:
In realworld people wont actually use a mobile phone for an SMS service because of business and some technical issues.


Both SMS Service from Aggregators & Operators and GSM Modems have their own applications in the area of SMS. If you are looking at sending bulk SMS (i.e. SMS Spamming), then throughput is of more importance and obviously linking to a SMS Server of SMPP or HTTP etc is better. However, when your throughput requirement is no very high (e.g. Sales Force Automation, Small/Medium CRM, Business Applications for Small/Medium Enterprises etc) then GSM Modem is a better option. Moreover, many many business enterprises are very strict about information security and do not want to route messages through third party SMS Aggregators over HTTP/SMPP.

One more important point to consider - Try receiving SMS through one of the SMS Aggregators/Operators and you will see the cost difference. Most of them dont support incoming SMS and even if they do, their prices for it are extremely high (why should you pay for incoming SMS?)

I do not want to comment on open source versus commercially purchased component, because thats a never ending debate (both have their own importance in a developers life!) Smile | :)





Keep IT Simple
GeneralRe: Real world SMS services Pin
Tili9-Aug-06 8:25
Tili9-Aug-06 8:25 
GeneralRe: Real world SMS services Pin
NewB0724-May-07 17:43
NewB0724-May-07 17:43 
GeneralRe: Real world SMS services Pin
Tili27-May-07 23:21
Tili27-May-07 23:21 
GeneralComments are welcome! Pin
Zakaria Bin Abdur Rouf19-Jul-06 22:24
Zakaria Bin Abdur Rouf19-Jul-06 22:24 
GeneralRe: Comments are welcome! Pin
abhishek38521-Sep-06 8:16
abhishek38521-Sep-06 8:16 
GeneralPlease Help Pin
kamleshv31-Oct-06 6:51
kamleshv31-Oct-06 6:51 
GeneralRe: Please Help Pin
dungil10122-Mar-07 8:31
dungil10122-Mar-07 8:31 
GeneralRe: Comments are welcome! Pin
Manoranjini15-Jan-09 23:50
Manoranjini15-Jan-09 23:50 
GeneralRe: Comments are welcome! Pin
haider_IT8-Jun-10 19:12
haider_IT8-Jun-10 19:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.