Home Contact us


Voice message



//----------------------------------------------------------------------------
// This program allows control of the 8 digital outputs by using
// voice response principle.
//----------------------------------------------------------------------------
INCLUDE rtcu.inc

// Next follows all the variables that can be configured via the configuration dialog
VAR_OUTPUT
  connected : BOOL| Connected to GSM Basestation.
  offhook   : BOOL| off-hook signal
  outputs   : ARRAY[1..8OF BOOL| Outputs we control
END_VAR;

VAR
  no      : INT;
  command : INT;
  state   : SINT := 1;
  incoming: gsmIncomingCall;
END_VAR;

PROGRAM SetOutput;

gsmPower(power:=ON);

BEGIN
  incoming();
  // Indicate if we are connected to a GSM Basestation
  connected := gsmConnected();

  CASE state OF
    1: // Waiting for incoming call:
    IF incoming.status > 0 THEN
      gsmAnswer();
      state:=2;
    END_IF;

    2: // Select output number:
    voiceTalk(message:="SelectOutNum.wav");
    no:=dtmfGetKey(timeout:=5000);
    IF no>=1 AND no<=8 THEN
      state:=3;
    END_IF;

    3: // Select on/off:
      voiceTalk(message:="SelectOnOff.wav");
      command:=dtmfGetKey(timeout:=5000);
      IF command=0 OR command=1 THEN
        outputs[no]:=BOOL(command);
        state:=2;
      ELSIF command=10 THEN
        state:=2;
      END_IF;
  END_CASE;


  // Are we still "online":
  offhook := gsmOffHook();

  // if the user has terminated the connection we go back 
  // to the initial state (waiting for call)
  IF NOT offhook THEN
    state:=1;
  END_IF;
END;

END_PROGRAM;