
|
//----------------------------------------------------------------------------
// Receive SMS.vpl, created 2000-08-06 11:14
// This program allows control of 8 outputs by sending a SMS-message
// to the RTCU unit. "ON" followed by a number in the interval 1..8 activates
// the specified output.
// "OFF" followed by a number in the interval 1..8 deactivates the specified
// output.
//----------------------------------------------------------------------------
INCLUDE rtcu.inc
VAR_OUTPUT
outputs : ARRAY[1..8] OF BOOL; | All 8 outputs
connected : BOOL; | Connected to a GSM basestation.
END_VAR;
VAR
sms : gsmIncomingSMS; // Receives incoming SMS messages
extract : strGetValues; // Matching of strings
END_VAR;
PROGRAM ReceiveSMS;
// The next code will only be executed once after the program starts
gsmPower(power:=ON);
BEGIN
sms();
connected := gsmConnected();
IF sms.status > 0 THEN
// Message received
// Check if it is a "ON" message
extract(format:="ON \1", str:=sms.message);
IF extract.match THEN
outputs[extract.v1] := ON;
END_IF;
// Check if it is a "OFF" message
extract(format:="OFF \1", str:=sms.message);
IF extract.match THEN
outputs[extract.v1] := OFF;
END_IF;
END_IF;
END;
END_PROGRAM;
|
|