netSetMobileParam (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

4.34 / 1.00.00


Sets TCP/IP-specific parameters for establishing connections over the mobile network interface. It has the same effect as setting the parameters via Device: Network: Network Settings.

 

The mobile network interface must be closed and opened again before the changes can take effect if already opened (see also netClose / netOpen).

 

The format of an IP address is the same as returned by the sockGetLocalIP function.

 

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).

 

Authenticate : INT (Default 3)

Authentication type:

0 = None.

1 = PAP

2 = CHAP

3 = PAP/CHAP

 

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.

 

Returns: INT

0

- Success.

2

- String too long.

 

 

Declaration:

FUNCTION netSetMobileParam : INT;
VAR_INPUT
  IP             : DINT := 0;
  SubnetMask     : DINT := 0;
  Gateway        : DINT := 0;
  DNS1           : DINT := 0;
  DNS2           : DINT := 0;
  Username       : STRING;
  Password       : STRING;
  APN            : STRING;
  Authenticate   : INT  := 3;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  mobileParam  : netGetMobileParam;
END_VAR;
 
mobileParam();
IF NOT (mobileParam.IP = 0 AND mobileParam.SubnetMask = 0 AND mobileParam.Gateway = 0 AND
  mobileParam.DNS1 = 0 AND mobileParam.DNS2 = 0 AND mobileParam.Authenticate = 3 AND
  mobileParam.Username = "" AND mobileParam.Password = "" AND mobileParam.APN = "internet") THEN
  // Set APN and keep the default values for the others
  netSetMobileParam(APN := "internet");
END_IF;
 
// Turn on power to the GSM module
gsmPower(power := ON);
netOpen(iface := 1);
BEGIN
 
 // ...
 
END;
 
END_PROGRAM;