Please tell me how to reply by SMS for a received SMS


Results 1 to 12 of 12

Threaded View

  1. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825

    Default

    I know how to send AT command to read SMS but my problem is in getting Modem responces in to a variable.
    First of all you have to connect your phone to your PC using HYPER TERMINAL and with the proper AT command obtain the complete string of one sms.

    Once the sms is on the screen you have to identify a starter (a number of characters at the begining of the string that never changes) very likely your phone will begin the string with the word "UNREAD", if this is case you can use this as a starter. You have also to identify the portions of the string that you need, count the character position (commencing from the last character of the starter) and the number of characters you will need. (For instance you will need the phone number of the sender and some part of the message. So count how many characters you have to skip from the end of the starter and the begining of the phone number, and from the end of the phone number to the begining of your text. Remember that space is one character)

    Once you have these informations, you will know the dimension of your byte arrays to contain the portion of string that you have selected and two numbers "n1" and "n2" which are the characters to skip to reach the portion of string that interest you.

    Code:
    ArrayNum     Var  BYTE [15]  ' here I assume the the phone number of the sender is 15 characters long. if shorter or longer adjust the array 
    
    ArrayTxt      Var  BYTE [50] ' here I assume that the sms text that interest you is 50 characters long. If your requirement is longer or shorter adjust the array

    Now, to fill your array, you send the AT command for reading your sms, and immediatly afterwards


    Code:
    HSEROUT ["AT^SMGR=1",13]  
    HSERIN 2000, NoSms,[WAIT("UNREAD"), Skip n1, Str ArrayNum\15, Skip n2,str ArrayTxt\50]
    If no sms are present, hserin will timeout to the label NoSms after 2 seconds, so include this label in your code.

    If the program doesn't jump to label NoSms then ArryNum will contain the phone number of the sender and ArrayTxt will contain the message.

    You can check ArrayNum and see if the answer can be sent or not. A simpler way to avoid to answer to the wrong message is to include a password within the text you send and check only the text. (In this case you don't need ArrayNum)

    If you need more help, you better tell me what you want to do.

    Al.
    Last edited by aratti; - 8th August 2009 at 11:59.
    All progress began with an idea

Similar Threads

  1. Problem with SMS IO Controller
    By dario.costa in forum GSM
    Replies: 4
    Last Post: - 30th November 2009, 08:04
  2. Replies: 288
    Last Post: - 25th August 2008, 17:53
  3. Reading a SMS to an array
    By KA5MAL in forum GSM
    Replies: 3
    Last Post: - 17th June 2008, 18:24
  4. Rs485 Using Hserin/hserout
    By koossa in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 31st January 2008, 10:42

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts