rchInterfaceSet (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.54.00


This function temporarily changes the network interface used to connect to the RTCU Communication Hub.

This function works similarly to gwSetMedia.

The default network interface is cellular.

 

If a non-fallback server configuration is enabled, this function must be called after gwOpen to work.

 

Input:

iface : SINT (Default 1)

The network interface to use to connect to the server. (see Network for available interfaces)

 

Returns: INT

0

- Success.

1

- Iface not found.

 

Declaration:

FUNCTION rchInterfaceSet : INT;
VAR_INPUT
  iface : SINT := 1;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR_INPUT
  eth : BOOL;
END_VAR;
 
VAR_OUTPUT
  LED_GPRS : BOOL;
  LED_RCH : BOOL;
END_VAR;
 
PROGRAM example;
VAR
  rch_iface : SINT;
END_VAR;
 
  // Init cellular
  gsmPower(power := ON);
  netOpen(iface := 1);
 
  // Init Ethernet
  netOpen(iface := 2);
 
  DebugMsg(message:="Program running");
 
BEGIN
  LED_GPRS := netConnected(iface := 1);
  LED_RCH := gwConnected();
 
  // Change RCH interface?
  rchInterfaceGet(iface := rch_iface);
  IF rch_iface <> 2 AND eth THEN
    // Select interface
    rchInterfaceSet(iface := 2); // Use Ethernet
  ELSIF rch_iface <> 1 AND NOT eth THEN
    // Select interface
    rchInterfaceSet(iface := 1); // Use Cellular
END_IF;
 
END;
END_PROGRAM