SMS reception with eWON

eWON equipped with a GSM/GPRS modem is able to receive SMS.

To treat the received SMS, the «ONSMS» function has to be used in conjunction with the «getsys prg,"SmsRead"» function. The following information fields can then be extracted from

every received SMS :

  • smsFrom: String holding the phone number of the sender
  • smsDate: String holding the Date of SMS reception
  • smsMsg: String holding the SMS message

Every time the «getsys prg,"SmsRead"» function is used the SMS will be read and deleted from the Sim card.

Sending an SMS receipt to the SMS sender

The script shown hereunder will read every SMS and send a SMS back to the SMS sender. The SMS will contain the SMS contents of the received SMS.

InitSection:
	ONSMS "Goto HSms"
	HSms:
		a% = getsys prg,"SmsRead"
		if (a%<>0) then
			s% = s%+1
			print "SMS Nr: ";s%
			f$ = getsys prg,"smsfrom"
			print "From: ";f$
			print getsys prg,"smsdate"
			a$ = getsys prg,"smsmsg"
			print "Message: ";a$
			b$ = f$+",gsm,0"
			c$ = "Received message: "+a$
			sendsms b$,c$
			goto HSms
		endif
	end

Setting the value of a Tag by SMS

The script shown hereunder will set the value of the Tag «Var1» to the value received by the SMS. (Contents example of of the received SMS = 1234). 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"
			Var1@ = Val(a$)
			LOGEVENT "Value of Tag Var1@ changed to:" + a$ + " by GSM number: " + f$, 120
			Goto Hsms
		Endif
	End

 Alarm acknowledge by SMS

The script shown hereunder will acknowledge the alarm of the Tag contained in the SMS message. (Contents example of of the received SMS = Var1). 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"
			SETSYS PRG,"RESUMENEXT",1
			ALMACK a$,""
			e% = Getsys Prg,"LSTERR"
			IF e% = -1 Then
				LOGEVENT "Acknowledge of alarm " + a$ + " by GSM number: " + f$, 120
			Else
				IF e% = 4 Then
					LOGEVENT "Alarm acknowledge failed because specified Tag is unknown (SMS Content:" + a$ + " , SMS Nr: " + f$ + ")", 120
				Else
					LOGEVENT "Alarm acknowledge failed. (SMS Content: " + a$ + " , SMS Nr: " + f$ + ")", 120
				Endif
			Endif
			SETSYS PRG,"LSTERR",-1
			SETSYS PRG,"RESUMENEXT",0
			Goto HSms
		Endif
	End 

«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