Examples - Send SMS message

Top  Previous  Next

//-----------------------------------------------------------------------------
// Send SMS.vpl, created 2000-08-06 02:15
//
// This program will count the number of leading edges on a digital input.
// After each leading edge, a SMS message will be sent with information on
// the number of leading edges detected so far.
//-----------------------------------------------------------------------------
INCLUDE rtcu.inc
 
// Next follows all the variables that can be configured via the configuration dialog
VAR_INPUT
  input : BOOL R_EDGE;
END_VAR;
 
VAR_OUTPUT
  Connected : BOOL; | Connection to GSM-network.
END_VAR;
 
// Here follows the programs global variables
VAR
  edge_no         : INT := 0;
  message_to_send : STRING;
END_VAR;
 
PROGRAM Send_SMS;
// The next code will only be executed once after the program starts
// Controls power to the GSM module
gsmPower(power := ON);
 
BEGIN
  // Code from this point until END will be executed repeatedly
  Connected := gsmConnected();
 
  IF input THEN
     edge_no := edge_no + 1;
    // Send an SMS message
     message_to_send:=strFormat(format:="\1 leading edges detected",
                                v1:=edge_no);
    gsmSendSMS(phonenumber:="+44 1234 5678",
                message:=message_to_send);
  END_IF;
END;
 
END_PROGRAM;