BASIC - ONSMS GOTO Command Label Call Issue and Other Logic Questions

We have a Flexy 201 using a GSM connection with an FLB 3202 card. Based on the instructions of the SMS reception with eWON post in the section labeled «Wake up» an eWON by SMS I can do the following

SMS reception with eWON

«Wake up» an eWON by SMS

A SMS can be used to «wake up» the eWON GSM/GPRS to establish a connection to the Internet. The script shown hereunder will send out a mail after the SMS reception.

The scheduled mail will then activate the outgoing connection to the Internet as configured in the Outgoing Connection settings of the eWON. (Contents example of of the received SMS = Connect).

The «LogEvent» function is used to track the action done by SMS.

 InitSection:
    ONSMS "Goto HSms"
    HSms:
        a% = Getsys Prg,"SmsRead"
        If (a%<>0) Then
            f$ = Getsys Prg,"smsfrom"
            a$ = Getsys Prg,"smsmsg"
            If a$ = "Connect" Then
                Sendmail "MyMail@abc.be","","eWON Wake up by SMS","The eWON online IP address is: [$dtSV$seOnlineIpAddr]"
                LOGEVENT "eWON Wake up by SMS from GSM number: " + f$, 120
            ENDIF
            Goto Hsms
        Endif
    End

I’ve Tried

What I’ve done is make some minor adjustments to the script from the post to accommodate in our environment. We’d like this functionality to work so if ever needed we can send a text to the SIM phone number try to wake up the GSM network for data connection, but it seems the GOTO call label function errors out and I cannot figure it out.

Here’s what I’m using so tell me if you see anything incorrect with this configuration

  1. I put the below code in the Init Section

    ONSMS "GOTO SMSWake"

  2. I created a new script section named SMSWake and put the below code in it

     a% = Getsys Prg,"SmsRead"
     IF (a%<>0) THEN
         f$ = Getsys Prg,"smsfrom"
         a$ = Getsys Prg,"smsmsg"
         IF a$ = "Wake" THEN
             Sendmail "MyEmailAddress@gmail.com","","eWON Wake up by SMS","The eWON online IP address is: [$dtSV$seOnlineIpAddr]"
             LOGEVENT "eWON Wake up by SMS from GSM number: " + f$, 120
         ENDIF
         GOTO SMSWake
     ENDIF
     END
    
  3. Now all I do is send the phone number registered on the eWON’s GSM SIM card a text message with the word “Wake” and I can see it log an error when it runs stating “label/function not found (27) : GOTO SMSWake

I’ve attached the entire program.bas file but from the eWON https download naming convention and I did remove my legit email address beforehand though. $dtPG.txt (2.7 KB)


Questions

  1. What am I doing wrong here to make this logic not be able to find the SMSWake routine?

  2. Based on the logic in the “SMSWake” routine, does the value “Wake” in the line IF a$ = "wake" THEN actually get the content of the text body that you send per the Getsys Prg,"SmsRead" setting the a$ variable?

    • If I send a text message to the GSM SIM number with a different word (not “Wake”), it also triggers the ONSMS but the label call still fails so that’s why I ask
  3. In the “SMSWake” routine where the line reads GOTO SMSWake just above the last ENDIF, is that really what it’s supposed to do with the GOTO?

    • I guess I figured the ONSMS triggers the call to the routine per that event it sees, so I wasn’t sure why the GOTO SMSWake was there but I may be interpreting the code wrong since I’m a BASIC novice.

@PJ_IOT

Alright a bit of information here so bear with me.

1. What am I doing wrong here to make this not logic not be able to find the SMSWake routine?.

   a. In your SMSWake script, you are missing the line: SMSWake: which actually denotes the
name of the subroutine. Right before this line: a% = Getsys Prg,“SmsRead” paste in the statement
SMSWake:


SMSWake:
a% = Getsys Prg,"SmsRead"
IF (a%<>0) THEN
    f$ = Getsys Prg,"smsfrom"
    a$ = Getsys Prg,"smsmsg"
    IF a$ = "wake" THEN
        Sendmail "MyEmailAddress@gmail.com","","eWON Wake up by SMS","The eWON online IP address is: [$dtSV$seOnlineIpAddr]"
        LOGEVENT "eWON Wake up by SMS from GSM number: " + f$, 120
    ENDIF
    GOTO SMSWake
ENDIF
END

2. _Based on the logic in the “SMSWake” routine, does the value “Wake” in the line IF a$ = "wake" THEN actually get the content of the text body that you send per the Getsys Prg,"SmsRead" setting the a$ variable?_

    a. The line a$ = Getsys Prg,“smsmsg” is what is actually extracting the “wake” from the message. It is going to be case sensitive however so you will want to ensure to add additional logic to check for Wake, wake etc, etc.
    Am I following this question correctly? Correct me if I am misunderstanding.


3. In the “SMSWake” routine where the line reads GOTO SMSWake just above the last ENDIF, is that really what it’s supposed to do with the GOTO?

    a. Yes that line is in fact supposed to issue a GOTO back to the top. This is essentially the basic       equivalent of a recursive function. As we do not know how many messages were sent, this function is     cycling until we have no more valid SMS messages to read. This allows us to send say 3 messages in     sequence and confirm they are all appropriately read.

Does this clarify? Please confirm if I am misunderstanding anything.

1 Like

Check, check, check, plus another check on all of this.

I guess the label of the routine you are calling is pretty important to have in the code. :laughing: Not sure how I overlooked that but I think the I got confused with the new script section I created or something but of course it’s be a simple fix. Duoh!!

The rest answers those questions I had as well but I was going to ask about case sensitivity but didn’t so thank you for that bit as well.