Click here to Skip to main content
15,867,686 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 176.8K   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

 
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 
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 
Hi

I went thru the article for SMS quiz server and found it very enlightning.

I was planning to swet up a server where I can provide services like free ring tones and other SMS services.

I want to know some details for the same.

IE
Requirements
from where can I get a short code for the same where I have my own number like indiatimes.com has 8888.

Plz throw some light on the detail functionality of the whole setup

Thanks and Regards
Abhishek Malhotra
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.