rchAutoConnectSet (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.54.00


This function controls whether a connection to the RTCU Communication Hub will be opened automatically using the primary server configuration.

 

The changes will take effect at device reset. (e.g. by using boardReset).

To change the fallback configuration, use rchFallbackSet or SockSetGWParm.

 

Input:

enable : BOOL (default TRUE)

Enable or disable auto connect.

 

Returns: INT

1

- Success.

0

- Not supported.

 

Declaration:

FUNCTION rchAutoConnectSet : INT;
VAR_INPUT
  enable : BOOL;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
  parm  : rchConfigGet;
  reset : BOOL := FALSE;
END_VAR;
 
// Check the RTCU Communication Hub settings
parm();
IF NOT rchAutoConnectGet() THEN
  rchAutoConnectSet(enable := ON);
  reset := TRUE;
END_IF;
IF NOT parm.enabled OR parm.secure OR parm.port <> 5001 OR
  parm.CryptKey[1] <> 0 OR parm.CryptKey[2] <> 0 OR
  parm.CryptKey[3] <> 0 OR parm.CryptKey[4] <> 0 OR
  parm.CryptKey[5] <> 0 OR parm.CryptKey[6] <> 0 OR
  parm.CryptKey[7] <> 0 OR parm.CryptKey[8] <> 0 OR
  parm.CryptKey[9] <> 0 OR parm.CryptKey[10] <> 0 OR
  parm.CryptKey[11] <> 0 OR parm.CryptKey[12] <> 0 OR
  parm.CryptKey[13] <> 0 OR parm.CryptKey[14] <> 0 OR
  parm.CryptKey[15] <> 0 OR parm.CryptKey[16] <> 0 OR
  parm.iface <> 2 OR strCompare(str1 := parm.address, str2 := "gw.rtcu.dk") <> 0 OR
  strCompare(str1 := parm.loginkey, str2 := "AABBCCDD") <> 0 THEN
  // Update settings
  rchConfigSet(enable := TRUE,
              address := "gw.rtcu.dk",
              port := 5001,
              iface := 2,
              loginkey := "AABBCCDD",
              secure := FALSE);
  reset := TRUE;
END_IF;
IF reset THEN
  // Reset device before the changes are used
  boardReset();
END_IF;
 
// Start network
netOpen(iface := 2);
 
BEGIN
END;
END_PROGRAM;