netSetMonitorParam (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

4.70 / 1.30.00


This function will set the parameters for the network monitor service.

The parameters for the network monitoring service are non-volatile and therefore need only to be set once. Parameters take effect after a device resets (by using, for example, the boardReset function).

The parameter set by netSetMonitorParam can be read by using netGetMonitorParam.

 

Use of the network monitoring service is recommended on network connections where the Gateway is not in use. When using the Gateway, the health of the connection is automatically monitored with the periodic self-transaction.

 

Network monitor service

The network monitor is a service which will monitor the health of one or more network connections, and will automatically take the necessary recovery actions required to reestablish service.

The network monitor will periodically check the health using one of the following methods:

 

0. Disabled

No monitoring of the connection health will occur. When the monitoring is disabled there is no dependencies on DNS or PING servers in the network environment.
For networks where there are no APN present, it is recommended to use the monitoring in the RTCU Gateway or enable the ICMP PING monitoring.
Disabling the monitoring will have the same effect as setting $DNS=0 in the Network Settings dialog.
 

1. A DNS lookup.

In this case, the monitor will perform a domain name look up, first on the primary DNS server, and if this fails because the DNS server did not respond, it will try again on the secondary DNS server (if present).

The DNS server IP addresses will be derived from the network information.

 

2. A ICMP PING.

In this case, the monitor will send an ICMP PING to the primary server, and if the fails, then again on the secondary server (if present).

The primary and secondary servers used, must be set by the application.

 

The gprsSetMonitorParm function sets the parameters for the mobile network, but, unlike the netSetMonitorParam function, is limited to using the DNS lookup method of health check.

 

 

Input:

iface : SINT (default 1)

The network interface. 1 = Mobile network, 2 = LAN network, etc. (See Network)

Please note that X32, NX32 and NX32L devices only support monitoring of the mobile network.

 

Enabled : BOOL

Enable/Disable monitoring of the network connection.

 

method : SINT (default 1)

The method used to check the health of the connection. (See above)

1 = DNS lookup, 2 = Ping address.

 

MaxAttempt : INT (1..60, default 3)

Maximum number of failed health check attempts before the necessary recovery actions are initiated.

Recommended is 3 times.

 

AliveFreq : DINT (30..60000 seconds, default 300)

The number of seconds between successful health checks.

Recommended alive-frequency is 300 seconds.

 

ping1 : DINT

The IP address of the primary server. (only used by ping)

 

ping2 : DINT

The IP address of the secondary server. (only used by ping)

 

 

Returns:

1

- Success.

0

- Interface not available or not supported.

-1

- Illegal network interface.

-2

- Illegal method.

-3

- Illegal parameter.

 

 

Declaration:

FUNCTION netSetMonitorParam;
VAR_INPUT
  iface      : SINT := 1;
  Enabled    : BOOL;
  method     : SINT := 1;
  MaxAttempt : INT  := 3;
  AliveFreq  : DINT := 300;
  ping1      : DINT;
  ping2      : DINT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  monitor : netGetMonitorParam;
END_VAR;
 
// Check settings
monitor(iface := _NET_IFACE_CELLULAR);
IF NOT monitor.Enabled OR monitor.method <> 1 OR monitor.MaxAttempt <> 3 OR monitor.AliveFreq <> 180 THEN
  // Set network monitor parameters
  netSetMonitorParam(iface:=_NET_IFACE_CELLULAR, Enabled := TRUE, method := 1, MaxAttempt := 3, AliveFreq := 180);
  boardReset();
END_IF;
 
// Turn on power to the GSM module
gsmPower(power := ON);
gprsOpen();
 
BEGIN
  ...
END;
END_PROGRAM;