Sets the parameters for the secondary standard (non-secure) fallback RTCU Communication Hub connection on NX32L devices. This has the same effect as setting the Fallback parameters via Device: Network: RTCU Communication Hub settings or by using the legacy sockSetGWParm function.
Fallback is used when the primary Server connection cannot be used, for example because of a secure connection or certificate problem. It is also used when the Server configuration is disabled. Use rchConfigSet to configure the primary Server connection.
The changes will take effect at the next call to rchOpen or at device reset. (e.g. by using boardReset).
Input:
enable : BOOL
True to enable fallback connection, false to disable.
address : STRING (Max 41 characters)
The IP address or symbolic name of the server.
port : DINT (default 5001)
The IP port the device should use to connect to the server.
loginkey : STRING (Max 8 characters)
The key (password) the device should use to connect to the server.
MaxConnectionAttempt : INT (default 3)
Max number of connection attempts before the network media reconnects.
MaxSendReqAttempt : INT (default 5)
Max number of send-request attempts before send fails.
ResponseTimeout : INT (default 45)
Time waiting for response in seconds.
AliveFreq : DINT (default 300)
Frequency for sending self-transactions in seconds.
The purpose of the self-transaction is to ensure a healthy two-way communication channel over the server.
For applications that are only sending data from the device to the server, this frequency can safely be increased.
Setting the value to zero will disable the self-transactions completely.
CryptKey : PTR
The key used to encrypt communication with the server.
If this parameter is not set (CryptKey set to 0), then the encryption key is not changed.
Returns:INT
0
|
- Success.
|
1
|
- String too long.
|
Declaration:
FUNCTION rchFallbackSet;
VAR_INPUT
enable : BOOL;
address : STRING;
port : DINT := 5001;
loginkey : STRING;
MaxConnectionAttempt : INT := 3;
MaxSendReqAttempt : INT := 5;
ResponseTimeout : INT := 45;
AliveFreq : DINT := 300;
CryptKey : PTR;
END_VAR;
Example:
INCLUDE rtcu.inc
PROGRAM test;
VAR
mobileParm : netGetMobileParam;
rchParm : rchFallbackGet;
parmReset : BOOL := FALSE;
CryptKey : ARRAY[1..16] OF SINT;
END_VAR;
mobileParm();
rchParm();
IF mobileParm.IP <> 0 OR mobileParm.SubnetMask <> 0 OR mobileParm.Gateway <> 0 OR
mobileParm.DNS1 <> 0 OR mobileParm.DNS2 <> 0 OR mobileParm.Authenticate <> 0 OR
strCompare(str1 := mobileParm.Username, str2 := "") <> 0 OR
strCompare(str1 := mobileParm.Password, str2 := "") <> 0 OR
strCompare(str1 := mobileParm.APN, str2 := "internet") <> 0 THEN
netSetMobileParam(APN := "internet");
parmReset := TRUE;
END_IF;
IF NOT rchParm.enabled OR rchParm.port <> 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.address, str2 := "gw.rtcu.dk") <> 0 OR
strCompare(str1 := rchParm.loginkey, str2 := "AABBCCDD") <> 0 THEN
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;
rchFallbackSet(enable := TRUE, address := "gw.rtcu.dk", port := 5001, loginkey := "AABBCCDD", CryptKey := ADDR(CryptKey));
parmReset := TRUE;
END_IF;
IF parmReset THEN
boardReset();
END_IF;
gsmPower(power := TRUE);
netOpen(iface := 1);
BEGIN
...
END;
END_PROGRAM;
|