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


Closed Thread
Results 1 to 12 of 12

Hybrid View

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

    Default

    but responding to SMS is not working in my program.
    This is quite simple providing that your modem is capable to hand text format (if you have only PDU format then you need to convert text to PDU first)

    Code:
    AT+CMGS=+39xxxxxxxxxxxx,13
    where +39 = international prefix for Italy (you will change as needed)
    xxxxxxxxxxxx = phone number you will send the sms.

    Immediatly after having sent this AT command you go listening the modem :

    answer should be: ">"

    When you receive this character then you sent your text (max 160 chars) terminating with 26

    HSEROUT ["This is my test",26] and you have sent your message.

    If you don't receive ">" within 5 seconds you must abort the command sending: HSEROUT [27] and repeat the command.

    Hope it will help you.

    Al.
    All progress began with an idea

  2. #2
    Join Date
    May 2009
    Posts
    13

    Thumbs up thanks

    Thank You im now testing it

    Quote Originally Posted by aratti View Post
    This is quite simple providing that your modem is capable to hand text format (if you have only PDU format then you need to convert text to PDU first)

    Code:
    AT+CMGS=+39xxxxxxxxxxxx,13
    where +39 = international prefix for Italy (you will change as needed)
    xxxxxxxxxxxx = phone number you will send the sms.

    Immediatly after having sent this AT command you go listening the modem :

    answer should be: ">"

    When you receive this character then you sent your text (max 160 chars) terminating with 26

    HSEROUT ["This is my test",26] and you have sent your message.

    If you don't receive ">" within 5 seconds you must abort the command sending: HSEROUT [27] and repeat the command.

    Hope it will help you.

    Al.

  3. #3
    Join Date
    May 2009
    Posts
    13

    Unhappy I just need to repply to a SMS

    I just need to know how to repply when a message received by the GSM Modam. It is great if i can repply only to a message from a specific number

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825

    Default

    If you want to answer to a received sms, then decode the message and grab the number of the sender, use it to reply with the same method as per previuos post.

    Al.
    All progress began with an idea

  5. #5
    Join Date
    May 2009
    Posts
    13

    Exclamation Thank You Very much, But I have more probd

    I have another problem in reading sms to a variable. Can u please let me know the code sequence to read sms in to a variable. (I am just a beginner to PIC programming). I know how to send AT command to read SMS but my problem is in getting Modem responces in to a variable.

  6. #6
    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 10:59.
    All progress began with an idea

  7. #7
    Join Date
    May 2009
    Posts
    13

    Smile Thanks aratti

    Thanks aratti. You so kind. Ill check your codes.

Similar Threads

  1. Problem with SMS IO Controller
    By dario.costa in forum GSM
    Replies: 4
    Last Post: - 30th November 2009, 07:04
  2. Replies: 288
    Last Post: - 25th August 2008, 16:53
  3. Reading a SMS to an array
    By KA5MAL in forum GSM
    Replies: 3
    Last Post: - 17th June 2008, 17:24
  4. Rs485 Using Hserin/hserout
    By koossa in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 31st January 2008, 09: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