sockGetTCPIPParm will read out the TCP/IP parameters previously set from the RTCU IDE or using by the sockSetTCPIPParm or netSetMobileParam functions.
Note: The IP address byte order for this function is ddd.ccc.bbb.aaa which is reversed compared to the standard format.
This function is obsolete and it is recommended to use netGetMobileParam.
Input:
None.
Output:
IP : DINT
The IP address of the device.
SubnetMask : DINT
The Subnet mask of the device.
Gateway : DINT
The TCP/IP gateway the device uses.
DNS1 : DINT
The first Domain Name Server the device uses to look up symbolic names.
DNS2 : DINT
The second Domain Name Server the device uses to look up symbolic names.
Username : STRING
The user name the device uses in order to connect to the mobile network.
Password : STRING
The password the device uses in order to connect to the mobile network.
APN : STRING
The APN the device uses in order to connect to the mobile network.
Authenticate : INT
The PPP authentication type:
0
|
- None.
|
1
|
- PAP.
|
2
|
- CHAP.
|
3
|
- PAP/CHAP.
|
Declaration:
FUNCTION_BLOCK sockGetTCPIPParm;
VAR_OUTPUT
IP : DINT;
SubnetMask : DINT;
Gateway : DINT;
DNS1 : DINT;
DNS2 : DINT;
Username : STRING;
Password : STRING;
APN : STRING;
Authenticate : INT;
END_VAR;
Example:
INCLUDE rtcu.inc
PROGRAM test;
VAR
gprsParm : sockGetTCPIPParm;
gwParm : sockGetGWParm;
parmReset : BOOL := FALSE;
CryptKey : ARRAY[1..16] OF SINT;
END_VAR;
gprsParm();
gwParm();
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
sockSetTCPIPParm(APN := "internet");
parmReset := TRUE;
END_IF;
IF NOT gwParm.GWEnabled OR gwParm.GWPort <> 5001 OR gwParm.CryptKey[1] <> 0 OR
gwParm.CryptKey[2] <> 0 OR gwParm.CryptKey[3] <> 0 OR gwParm.CryptKey[4] <> 0 OR
gwParm.CryptKey[5] <> 0 OR gwParm.CryptKey[6] <> 0 OR gwParm.CryptKey[7] <> 0 OR
gwParm.CryptKey[8] <> 0 OR gwParm.CryptKey[9] <> 0 OR gwParm.CryptKey[10] <> 0 OR
gwParm.CryptKey[11] <> 0 OR gwParm.CryptKey[12] <> 0 OR gwParm.CryptKey[13] <> 0 OR
gwParm.CryptKey[14] <> 0 OR gwParm.CryptKey[15] <> 0 OR gwParm.CryptKey[16] <> 0 OR
strCompare(str1 := gwParm.GWIP, str2 := "gw.rtcu.dk") <> 0 OR
strCompare(str1 := gwParm.GWKey, 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;
sockSetGWParm(GWEnabled := TRUE, GWIP := "gw.rtcu.dk", GWPort := 5001, GWKey := "AABBCCDD", CryptKey := ADDR(CryptKey));
parmReset := TRUE;
END_IF;
IF parmReset THEN
boardReset();
END_IF;
gsmPower(power := TRUE);
gprsOpen();
BEGIN
...
END;
END_PROGRAM;
|