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
- Start/Run the project by pressing F5 and wait infinitely after connecting.
- A user sends a SMS with QUES.
- The server scans each message and parses to find the request of question and sends the question of the day.
- If the user sends SMS with ANS A.
- The server records the answer. User cannot send several answers.
- 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.
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.
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)
{
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.
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.
private void MyTimer_Tick(object sender, EventArgs e)
{
Application.DoEvents();
if(objSMS.Inbox().Count > 0)
{
GetMessageFromMobile();
}
ProcessWinner();
objSMS.Inbox().Refresh();
}
The Server in Action
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