Shop OBEX P1 Docs P2 Docs Learn Events
receiving SMS from the Wavecom and the BS2p supposedly receives the SMS. — Parallax Forums

receiving SMS from the Wavecom and the BS2p supposedly receives the SMS.

ice-egozice-egoz Posts: 55
edited 2004-08-13 06:52 in BASIC Stamp
Hi. U must have figured out that adila and me are in the same group.
Hi. Her's was the sending of SMS, mine's the receiving of a reply message-> 'Shut Down'
So for me, I shud use the AT-commands--> "AT+CMGR=1"

serout 13,9600,[noparse][[/noparse]AT+CMGR=1]·· ' is this able to read the sms? and the readings> done in BS2p/modem?
·········································· ' know that commands are sent to the modem, so the data is·opened in the ·········································· 'modem? lets say that the message is "Shut Down". I need to extract that
········································· ·'message. so how do i go abt extracting? I need to use that message to do some
···········································'comparing in the BS2p.
output wud probably look like this-->
+CMGR: “REC UNREAD”,”0146290800”,
”98/10/01,18 :22 :11+00”,<CR><LF>
Shut Down

I doubt that the wiring is a problem over here, cos Im using the Pins 14 and 13. Pin 13 will be to receive the message. Pin 14 will be to send out the AT-commands.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I need all ya guidance Masters. [noparse]:)[/noparse]

Comments

  • dk_akjdk_akj Posts: 37
    edited 2004-08-12 05:51
    hi Ice.

    Please try this. It works for me.



    SMSMsg VAR Byte(9)

    readsms:

    serout 13,9600,[noparse][[/noparse]"AT+CMGR=1",CR,LF] ' read sms stored on index 1
    pause 1000 ' giv the modem time to think.....

    SERIN 14, 9600,Bad_Data,65000,readsms , [noparse][[/noparse]WAIT("Shut d" ), STR SMSmsg\8 ] ' listen on pin 14 until "Shut d" is recived. if not received within 10 seconds it tryes again.

    ' a sms with the text "Shut d" is received.



    serout 13,9600,[noparse][[/noparse]"AT+CMGD=1",CR,LF] ' delete sms stored on index 1 (if the sms is not deleted the next sms comming wil be stored in index 2 and so on)
    goto readsms ' wait for a new SMS

    Bad_Data:
    DEBUG "Parity error",CR,LF


    //akj
  • ice-egozice-egoz Posts: 55
    edited 2004-08-12 07:09
    HI. Therefore the data is stored in byte array·format so now I need to compare that input data to text. Is that possible? This is wat I have done-->

    checking:
    IF (SMSMsg = "Shut Down") THEN shutDown················· ' does this comparison works?

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    shutDown:············ ' Off the Alarm
    'sirenPin LOW··········· ' Put Siren to LOW/%00
    ·GOTO secMessage····· ' Go to reply owner 2nd time


    secMessage:············· '2nd msg to owner informing about succesful switching off the alarm
    · SEROUT toModem, baud, [noparse][[/noparse]"AT"]
    · DEBUG "AT"

    · SEROUT toModem, baud, [noparse][[/noparse]CR,LF]
    · DEBUG CR,LF
    · PAUSE pauses


    · SEROUT toModem, baud, [noparse][[/noparse]"AT+CMGF=1"]·········· 'Assign Text Mode
    · DEBUG "AT+CMGF=1"

    · SEROUT toModem, baud, [noparse][[/noparse]CR,LF]
    · DEBUG CR,LF···················· ' Carraige Return ot 'Enter'
    · PAUSE pauses

    · 'AT+CMGS=90225042[noparse][[/noparse]ENTER]
    · SEROUT toModem, baud, [noparse][[/noparse]"AT+CMGS"]············ 'Send 2nd Message to Owner
    · DEBUG "AT+CMGS"

    · SEROUT toModem, baud, [noparse][[/noparse]61]
    · DEBUG 61····································· 'ASCII Equivalent for =

    · SEROUT toModem, baud, [noparse][[/noparse]"91918287"]············ 'Liling's number
    · DEBUG "91918287"······························ 'dest(Liling) mobile no

    · SEROUT toModem, baud, [noparse][[/noparse]CR,LF]
    · DEBUG CR,LF
    · PAUSE pauses

    · '>MSG^Z
    · SEROUT toModem, baud, [noparse][[/noparse]"Alarm Off Successful"]·········· 'MSG Successful.
    · DEBUG "Alarm off Successful"···························· 'msg
    · SEROUT toModem, baud, [noparse][[/noparse]26]
    · DEBUG 26
    · PAUSE pauses

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I need all ya guidance Masters. [noparse]:)[/noparse]
  • dk_akjdk_akj Posts: 37
    edited 2004-08-12 08:11
    You cant't compare to strings with = , you'll have to do it byte by byte.

    Let me explain this againg:
    debug "wait for shutdown",cr,lf
    SERIN 14, 9600,Bad_Data,25000,readsms , [noparse][[/noparse]WAIT("Shut d" ), STR SMSmsg\8 ]
    debug "Shutdown received from modem",cr,lf

    Above statement listens on pin 14, 9600 baud.
    The wait statement tells the SERIN command not to continue before the text "Shut d" is received. (Wait statement can only have 6 chars, therefore onle "Shut d" and not "Shut down).

    If SERIN not receives a string within 10 seconds it goes to the "funktion" readsms (se example in my first post)

    Debug output will now be:
    wait for shutdown
    wait for shutdown
    wait for shutdown
    wait for shutdown
    wait for shutdown
    Shutdown received from modem

    In this way you dont have to compare strings, The SERIN command does it all for you.

    //akj
  • ice-egozice-egoz Posts: 55
    edited 2004-08-13 01:43
    hi. the thing is I need to do a comparison of strings cos that will go into another new label.

    IF (SMSMsg="Shut Down") THEN secMsg

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I need all ya guidance Masters. [noparse]:)[/noparse]
  • dk_akjdk_akj Posts: 37
    edited 2004-08-13 05:28
    Ice,

    You don't understand me.....

    1: readsms:
    2:
    3: ' read sms index 1
    4: SEROUT toModem, baud, [noparse][[/noparse]"AT+CMGR=1",CR,LF]
    5:
    6: ' give the modem time to think
    7: pause 1000
    8:
    9: debug "wait for shutdown",cr,lf
    10: SERIN 14, 9600,Bad_Data,25000,readsms , [noparse][[/noparse]WAIT("Shut d" ), STR SMSmsg\8 ]
    11:
    12: debug "Shutdown received from modem",cr,lf
    13: gosub DoWhatTo

    This is all you need, you will never reach line 12 if the text "Shut d" is not received from the modem.

    Have you tried the code ??

    //akj
  • ice-egozice-egoz Posts: 55
    edited 2004-08-13 06:40
    Yup. ok I got u. I need to run my code to the BS2p. Does it still go to the BS2p when there is a command serin?? It stopped at that stage.

    And for above i need to check the string. what if there are missing spaces or the alphabets are wrongly capitalised? does this affect for going to gosub?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I need all ya guidance Masters. [noparse]:)[/noparse]
  • ice-egozice-egoz Posts: 55
    edited 2004-08-13 06:41
    i also need to have a flow control so that the modem waits for sms to be read?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I need all ya guidance Masters. [noparse]:)[/noparse]
  • ice-egozice-egoz Posts: 55
    edited 2004-08-13 06:52
    This is my program. There is a shortcoming to this. It keeps repeating "AT+CMGR=1". Do i need to use flow-control?

    thruModem CON 14
    toModem CON 15
    flowControl CON 13
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    'Constants''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Baud CON 16624 '8-bit, no-parity, inverted
    pauses CON 2000
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    'Variables''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    serData VAR Byte(9)
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    GOTO readSMS

    readSMS:····· 'Read Message
    SEROUT toModem, Baud, [noparse][[/noparse]"AT+CMGR=1",CR,LF]··· 'Read Message = "Shut Down"
    DEBUG "AT+CMGR=1"
    PAUSE 2000
    'SEROUT toModem, Baud, [noparse][[/noparse]CR,LF]
    'DEBUG CR,LF

    SERIN thruModem\flowControl, Baud,Bad_Data,10000,readSMS, [noparse][[/noparse]WAIT("Shut d"), STR serData\8]·· 'the data is saved in serData as WORD
    DEBUG "serData"

    Bad_Data:
    DEBUG "Parity error",CR,LF


    SEROUT toModem, Baud, [noparse][[/noparse]"AT+CMGD=1",CR,LF]···· 'delete message after getting in the data
    DEBUG "AT+CMGD=1"
    'SEROUT toModem, Baud, [noparse][[/noparse]CR,LF]
    'DEBUG CR,LF

    GOTO checking


    ''''''''''''''''''''''''''''''''something--> Data'''''''''''''''''''''''''''''''''''''''''''''''''''''''
    checking:
    'IF (serData = true ) THEN shutDown
    ·GOTO shutDown
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    shutDown:············ ' Off the Alarm
    'sirenPin LOW··········· ' Put Siren to LOW/%00
    ·GOTO secMessage····· ' Go to reply owner 2nd time


    secMessage:············· '2nd msg to owner informing about succesful switching off the alarm
    · SEROUT toModem, baud, [noparse][[/noparse]"AT"]
    · DEBUG "AT"

    · SEROUT toModem, baud, [noparse][[/noparse]CR,LF]
    · DEBUG CR,LF
    · PAUSE pauses


    · SEROUT toModem, baud, [noparse][[/noparse]"AT+CMGF=1"]·········· 'Assign Text Mode
    · DEBUG "AT+CMGF=1"

    · SEROUT toModem, baud, [noparse][[/noparse]CR,LF]
    · DEBUG CR,LF···················· ' Carraige Return ot 'Enter'
    · PAUSE pauses

    · 'AT+CMGS=90225042[noparse][[/noparse]ENTER]
    · SEROUT toModem, baud, [noparse][[/noparse]"AT+CMGS"]············ 'Send 2nd Message to Owner
    · DEBUG "AT+CMGS"

    · SEROUT toModem, baud, [noparse][[/noparse]61]
    · DEBUG 61····································· 'ASCII Equivalent for =

    · SEROUT toModem, baud, [noparse][[/noparse]"90225042"]············ 'Liling's number
    · DEBUG "91918287"······························ 'dest(Liling) mobile no

    · SEROUT toModem, baud, [noparse][[/noparse]CR,LF]
    · DEBUG CR,LF
    · PAUSE pauses

    · '>MSG^Z
    · SEROUT toModem, baud, [noparse][[/noparse]"Alarm Off Successful"]·········· 'MSG Successful.
    · DEBUG "Alarm off Successful"···························· 'msg
    · SEROUT toModem, baud, [noparse][[/noparse]26]
    · DEBUG 26
    · PAUSE pauses

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I need all ya guidance Masters. [noparse]:)[/noparse]
Sign In or Register to comment.