INCLUDE rtcu.inc
VAR_OUTPUT
outputs : ARRAY[1..8] OF BOOL;
connected : BOOL;
END_VAR;
VAR
sms : gsmIncomingSMS;
extract : strGetValues;
END_VAR;
PROGRAM ReceiveSMS;
gsmPower(power:=ON);
BEGIN
sms();
connected := gsmConnected();
IF sms.status > 0 THEN
extract(format:="ON \1", str:=sms.message);
IF extract.match AND extract.v1 >= 1 AND extract.v1 <= 8 THEN
outputs[extract.v1] := ON;
END_IF;
extract(format:="OFF \1", str:=sms.message);
IF extract.match AND extract.v1 >= 1 AND extract.v1 <= 8 THEN
outputs[extract.v1] := OFF;
END_IF;
DebugMsg(message:=strConcat(str1:="Message received from ", str2:=sms.phonenumber));
DebugMsg(message:=strConcat(str1:="Message is ", str2:=sms.message));
END_IF;
END;
END_PROGRAM;
|