sockSetTCPIPParm (Function) (obsolete)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

1.00 / 1.00.00


Sets TCP/IP-specific parameters for making connection via mobile networks. It has the same effect as setting the parameters via Device: Network: Network Settings or netSetMobileParam.

 

The device must be reset before the changes can take effect (for example by using boardReset).
 
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 netSetMobileParam.

 

 

Input:

IP : DINT (default 0)

The IP address of the device (normally set by negotiation).

 

SubnetMask : DINT (default 0)

The Subnet mask of the device (normally set by negotiation).

 

Gateway : DINT (default 0)

The TCP/IP gateway the device must use (normally set by negotiation).

 

DNS1 : DINT (default 0)

The first Domain Name Server the device should use to look up symbolic names (normally set by negotiation).

 

DNS2 : DINT (default 0)

The second Domain Name Server the device should use to look up symbolic names (normally set by negotiation).

 

Username : STRING (Max 33 characters)

The user name the device should use in order to connect to the mobile network.

 

Password : STRING (Max 33 characters)

The password the device should use in order to connect to the mobile network.

 

APN : STRING (Max 33 characters)

The APN the device should use in order to connect to the mobile network.

 

Authenticate : INT (default 3)

The PPP authentication type:

0

- None.

1

- PAP.

2

- CHAP.

3

- PAP/CHAP.

 

 

Returns:

None.

 

Declaration:

FUNCTION sockSetTCPIPParm;
VAR_INPUT
  // general TCP/IP parameters:
  IP           : DINT := 0;     // IP address of this device (typically set when negotiating)
  SubnetMask   : DINT := 0;     // subnet mask (typically set when negotiating)
  Gateway     : DINT := 0;     // gateway-address (typically set when negotiating)
  DNS1         : DINT := 0;     // DNS-address 1 (typically set when negotiating)
  DNS2         : DINT := 0;     // DNS-address 2 (typically set when negotiating)
  Alive       : DINT := 0;     // keep alive in seconds.(0=disabled) (NOT USED)
 
  // PPP parameters:
  Username     : STRING;       // username (max 33 char).
  Password     : STRING;       // password (max 33 char).
 
  // Dialup/mobile network parameters:
  APN         : STRING;       // APN (MAX 33 char)
  Authenticate : INT;         // Authentication type. 0=none, 1=PAP, 2=CHAP, 3=PAP/CHAP.
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  gprsParm : sockGetTCPIPParm;
  gwParm   : sockGetGWParm;
  parmReset : BOOL := FALSE;
  CryptKey : ARRAY[1..16] OF SINT;
END_VAR;
 
// Check mobile network and Gateway settings
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
  // Set APN and keep the default values for the others
  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
  // 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
  sockSetGWParm(GWEnabled := TRUE, GWIP := "gw.rtcu.dk", GWPort := 5001, GWKey := "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;