rchFallbackGet (Functionblock)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.54.00


rchFallbackGet will read out the fallback parameters for the RTCU Communication Hub, previously set from the RTCU IDE or by using the rchFallbackSet function.

 

 

Input:        

None

 

Output:

enabled : BOOL

True if fallback connection is enabled, false if not.

 

address : STRING

The IP address or symbolic name of the server.

 

port : DINT

The IP port the device should use to connect to the server.

 

loginkey : STRING

The key (password) the device should use to connect to the server.

 

MaxConnectionAttempt : INT

Max number of connection attempts before the network media reconnects.

 

MaxSendReqAttempt : INT

Max number of send-request attempts before send fails.

 

ResponseTimeout : INT

Time waiting for response in seconds.

 

AliveFreq : DINT

Frequency for sending self-transactions in seconds.

 

CryptKey[n] : SINT

The key used to encrypt communication with the server.

 

 

Declaration:

FUNCTION_BLOCK rchFallbackGet;
VAR_OUTPUT
  enabled              : BOOL;
  address              : STRING;
  port                 : DINT;
  loginkey             : STRING;
  MaxConnectionAttempt : INT;
  MaxSendReqAttempt    : INT;
  ResponseTimeout      : INT;
  AliveFreq            : DINT;
  CryptKey             : ARRAY[1..16] OF SINT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  gprsParm  : sockGetTCPIPParm;
  rchParm   : rchFallbackGet;
  parmReset : BOOL := FALSE;
  CryptKey  : ARRAY[1..16] OF SINT;
END_VAR;
 
// Check mobile network and RTCU Communication Hub settings
gprsParm();
rchParm();
IF gprsParm.IP <> 0 OR gprsParm.SubnetMask <> 0 OR gprsParm.Gateway <> 0 OR
  gprsParm.DNS1 <> 0 OR gprsParm.DNS2 <> 0 OR gprsParm.Authenticate <> 0 OR
  strCompare(str1 := gprsParm.Username, str2 := "") <> 0 OR
  strCompare(str1 := gprsParm.Password, str2 := "") <> 0 OR
  strCompare(str1 := gprsParm.APN, str2 := "internet") <> 0 THEN
  // Set APN and keep the default values for the others
  sockSetTCPIPParm(APN := "internet");
  parmReset := TRUE;
END_IF;
IF NOT rchParm.GWEnabled OR rchParm.GWPort <> 5001 OR rchParm.CryptKey[1] <> 0 OR
  rchParm.CryptKey[2] <> 0 OR rchParm.CryptKey[3] <> 0 OR rchParm.CryptKey[4] <> 0 OR
  rchParm.CryptKey[5] <> 0 OR rchParm.CryptKey[6] <> 0 OR rchParm.CryptKey[7] <> 0 OR
  rchParm.CryptKey[8] <> 0 OR rchParm.CryptKey[9] <> 0 OR rchParm.CryptKey[10] <> 0 OR
  rchParm.CryptKey[11] <> 0 OR rchParm.CryptKey[12] <> 0 OR rchParm.CryptKey[13] <> 0 OR
  rchParm.CryptKey[14] <> 0 OR rchParm.CryptKey[15] <> 0 OR rchParm.CryptKey[16] <> 0 OR
  strCompare(str1 := rchParm.GWIP, str2 := "gw.rtcu.dk") <> 0 OR
  strCompare(str1 := rchParm.GWKey, str2 := "AABBCCDD") <> 0 THEN
  // Clear encryption key
  CryptKey[1] := 0;
  CryptKey[2] := 0;
  CryptKey[3] := 0;
  CryptKey[4] := 0;
  CryptKey[5] := 0;
  CryptKey[6] := 0;
  CryptKey[7] := 0;
  CryptKey[8] := 0;
  CryptKey[9] := 0;
  CryptKey[10] := 0;
  CryptKey[11] := 0;
  CryptKey[12] := 0;
  CryptKey[13] := 0;
  CryptKey[14] := 0;
  CryptKey[15] := 0;
  CryptKey[16] := 0;
  // Set Gateway parameters
  rchFallbackSet(enabled := TRUE, address := "gw.rtcu.dk", port := 5001, loginkey := "AABBCCDD", CryptKey := ADDR(CryptKey));
  parmReset := TRUE;
END_IF;
IF parmReset THEN
  // Reset device before the changes are used
  boardReset();
END_IF;
 
// Turn on power to the GSM module
gsmPower(power := TRUE);
gprsOpen();
 
BEGIN
  ...
END;
END_PROGRAM;