Subscribe For Free Updates!

We'll not spam mate! We promise.

Showing posts with label VB. Show all posts
Showing posts with label VB. Show all posts

Apr 30, 2012

Send and Receive SMS Through AT commands

Views:

Send Sms Through AT commands
AT commands is use to communicate with GSM  Madame and Mobile Phone.There are a lot of libraries which has been made using AT commands and These libraries are not Free it charge money for Using it But Today You learn how to Send and receive sms through AT commands .

Using AT commands you're not restricted to a specific phone model, as long as the phone supports the commands you are using.

This program uses the text mode for sending the message, which is good for starting, but it may not be supported by every phone. If you want to use the PDU mode instead of the text mode - which is supported by all mobiles but is more complicated - see the PDU encoding sample for creating the required data.
Sample source code is available for VB6.
Details about the VB6 sample:
  • Shows how to use the MSComm ActiveX control
  • Shows how to use the SMS AT commands
  • Includes a trace output to see what's going on
  • Includes error handling for common errors
  • Is not optimized for performance

Download
VB6 projectVB6: SendSMS_AT_VB6_20041025.zip

Encoding SMS messages for PDU mode

This demonstrates how to create an SMS-SUBMIT PDU for a simple text message.
Download
VB6 projectVB6: EncodePDU_VB6_20040419.zip
C# projectC#: EncodePDU_CS_20040418.zip
Requires .NET Framework 1.1
Note: This program does only the coding, it does not actually send the message. For testing you can use a terminal program like HyperTerminal (included in Windows) to transfer the encoded message, as given in the following sample:

AT+CMGF=0<CR>
AT+CMGS=<actual PDU length><CR>
<encoded message><EOF>
<CR> = ASCII 13 = ENTER
<EOF> = ASCII 26 = CTRL+Z

Using AT commands to read SMS messages

Using AT commands you're not restricted to a specific phone model, as long as the phone supports the commands you are using.
This program uses the text mode for reading the messages, which is good for learning how it works, but it may not be supported by every phone. You may have to change character sets depending on the characters used in the messages to get the original text back.
Download
C# projectC#: ReadSMS_AT_CS20_20060718.zip
Requires .NET Framework 2.0

Basically there are two ways to send SMS.

  1. Connect a mobile phone or GSM/GPRS modem to a computer / PC. Then use the computer / PC and AT commands to instruct the mobile phone or GSM/GPRS modem to send SMS messages.
  2. Connect the computer / PC to the SMS center (SMSC) or SMS gateway of a wireless carrier or SMS service provider. Then send SMS messages using a protocol / interface supported by the SMSC or SMS gateway.
 In this tutorial we'll use first method. We can send SmS through AT commands, AT commands are instructions to Send/Receive SMS. (for more detail about AT Commands wait for my Next Post about AT commands).

Lets Start..
Step-1
Open Visual Studio, Create a New Project with the Name SMS. (In this tutorial I'm not going to show you how to create a new project, I'm skipping the detail about it.)

Step-2
In the solution Explorer, Right Click on the Project and Click on Add -> Add New Item and Add New Class with the name SmsClass.cs copy the following code in the class.

SmsClass.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.IO.Ports;
using System.Windows.Forms;
namespace SMS
{
    class SmsClass
    {
        SerialPort serialPort;
        public SmsClass(string comPort)
        {
            this.serialPort = new SerialPort();
            this.serialPort.PortName = comPort;
            this.serialPort.BaudRate = 9600;
            this.serialPort.Parity = Parity.None;
            this.serialPort.DataBits = 8;
            this.serialPort.StopBits = StopBits.One;
            this.serialPort.Handshake = Handshake.RequestToSend;
            this.serialPort.DtrEnable = true;
            this.serialPort.RtsEnable = true;
            this.serialPort.NewLine = System.Environment.NewLine;
        }
        public bool sendSms(string cellNo, string sms)
        {
            string messages = null;
            messages = sms;
            if (this.serialPort.IsOpen == true)
            {
                try
                {
                    this.serialPort.WriteLine("AT" + (char)(13));
                    Thread.Sleep(4);
                    this.serialPort.WriteLine("AT+CMGF=1" + (char)(13));
                    Thread.Sleep(5);
                    this.serialPort.WriteLine("AT+CMGS=\"" + cellNo + "\"");
                    Thread.Sleep(10);
                    this.serialPort.WriteLine(">" + messages + (char)(26));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Source);
                }
                return true;
            }
            else
                return false;
        }

        public void Opens()
        {
            if (this.serialPort.IsOpen == false)
            {
                this.serialPort.Open();
            }
        }
        public void Closes()
        {
            if (this.serialPort.IsOpen == true)
            {
                this.serialPort.Close();
            }
        }
    }
}
Step-3
Now on the Form1, we'll use
  1. combo Box (cboPorts) which will show the available ports on the computer.
  2. Two TextBoxes One for Receivers Cell No. (txtphone) and other for Message body (txtMessage) with Multiline property set to True.
  3. Send Button (btnSend) to Send SMS.
 Step-4
Copy and Paste the following code in the Form1 Code.
Form1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace SMS
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            loadPorts();
        }
        private void loadPorts()
        {
            string[] ports = SerialPort.GetPortNames();
            foreach (string port in ports)
            {
                cboPorts.Items.Add(port);
            }
        }
        private void btnSend_Click(object sender, EventArgs e)
        {
            SmsClass sm = new SmsClass(cboPorts.Text);
            sm.Opens();
            sm.sendSms(txtPhone.Text, txtMessage.Text);
            sm.Closes();
            MessageBox.Show("Message Sent!");
        }

      
    }
}
Now , You Just need to connect your GSM modem/mobile to your PC through USB or Serial cable.
and Run the Project. From the main Window Select COM Port  on which your Modem/Phone is Connected to.

Note: This application is Tested using Nokia N82 By Me...

Download Source Code:
http://www.multiupload.com/1E2JGHS1ZF


Apr 1, 2011

VB Soup to Nuts

Views:

Video Sub Category

NOTE:-  To view a video, click on the title. To update time watched, please login. (The Microsoft videos are totally free, but they  do require that you register with them to view the videos and you also have to use Internet Explorer browser, instead of Firefox, Safari, etc.)




SeriesTitleDatePresenterMin
VB Soup to Nuts Introduction - video missing2/7/2007Ron Cundiff 60
VB Soup to NutsVisual Basic 2005 Express Edition- video missing2/13/2007Ron Cundiff 60
VB Soup to NutsClass Libraries -video missing2/19/2007Ron Cundiff 60
VB Soup to NutsVB.NET Program Structure - video missing2/20/2007Ron Cundiff 60
VB Soup to NutsLanguage Fundamentals3/5/2007Ron Cundiff 60
VB Soup to NutsClasses and Objects3/19/2007Ron Cundiff 60
VB Soup to NutsOperator Basics3/26/2007Ron Cundiff 60
VB Soup to NutsBranching and Looping - video missing4/2/2007Ron Cundiff 60
VB Soup to NutsBasic Debugging - video missing4/9/2007Ron Cundiff 60
VB Soup to NutsArrays and Collections4/16/2007Ron Cundiff 43
VB Soup to NutsException Handling4/23/2007Ron Cundiff 55
VB Soup to NutsDelegates and Events4/30/2007Ron Cundiff 32
VB Soup to NutsInheritance and Polymorphism - video missing5/7/2007Ron Cundiff 60
VB Soup to NutsVisual Basic and the Web5/14/2007Ron Cundiff 68
VB Soup to NutsCustom Web Controls5/21/2007Ron Cundiff 73
VB Soup to NutsVisual Basic and Windows Applications5/22/2007Ron Cundiff 68
VB Soup to Nuts Custom Windows Forms Controls5/29/2007Ron Cundiff 67
VB Soup to NutsCreating and Manipulating Strings6/4/2007Ron Cundiff 68
VB Soup to NutsVisual Basic and SQL Server 20056/6/2007Ron Cundiff 62
VB Soup to Nuts Visual Basic Application Deployment Options6/18/2007Ron Cundiff 53
VB Soup to Nuts Building a Multi-Tier Business Application6/25/2007Ron Cundiff 62
   Total 1251

Modern Software Visual Basic VB

Views:

Video Sub Category

NOTE:-  To view a video, click on the title. To update time watched, please login. (The Microsoft videos are totally free, but they  do require that you register with them to view the videos and you also have to use Internet Explorer browser, instead of Firefox, Safari, etc.)





SeriesTitleDatePresenterMin
Modern Software Dev in VBProgram Execution in the 21st Century2/3/2004Joe Hummel 124
Modern Software Dev in VBOOP and Class Design2/10/2004Joe Hummel 118
Modern Software Dev in VBWorking with Classes and Class Libraries2/17/2004Joe Hummel 113
Modern Software Dev in VBWinForms: What's New in GUI Development2/24/2004Joe Hummel 81
Modern Software Dev in VBDefensive Programming3/2/2004Joe Hummel 90
Modern Software Dev in VBDatabases I: Relational Database Design, SQL, and Stored Procedures3/16/2004Joe Hummel 90
Modern Software Dev in VBDatabases II: DB Programming with ADO.NET3/23/2004Joe Hummel 90
Modern Software Dev in VBInterfaces3/31/2004Joe Hummel 90
Modern Software Dev in VBInheritance4/6/2004Joe Hummel 90
Modern Software Dev in VBDatabases II - Data and Business Tier4/15/2004Joe Hummel 90
Modern Software Dev in VBComponent-Based Programming4/20/2004Joe Hummel 90
Modern Software Dev in VBApplication Design and Deployment4/28/2004Joe Hummel 90
Modern Software Dev in VBDistributed Programming: Remoting vs Web Services5/4/2004Joe Hummel 90
Modern Software Dev in VBConcurrent Programming: Delegates and Multi-threading5/11/2004Joe Hummel 90
Modern Software Dev in VBSoftware Practices Today: Best Practices and Patterns5/18/2004Joe Hummel 90
   Total 1426




Become a Fan

visual studio learn