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 Cellular-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 Cellular 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);
    // Use "9999" as phonenumber, this will send the SMS to the RTCU M2M Studio
    // Use a "normal" number to send the message as a normal SMS message to
    // a mobile phone                               
    gsmSendSMS(phonenumber:="9999", message:=message_to_send);
    DebugMsg(message:=message_to_send);
  END_IF;
END;
END_PROGRAM;