gwSetMedia (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

1.10 / 1.00.00

Deprecated:

Use rchInterfaceSet instead.


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

This function works similarly to rchInterfaceSet.

 

The default media is Cellular network.

In case the device faults, it will try to connect to the RTCU Communication Hub using the media selected by this function.

 

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

 

 

Input:

media : SINT (0/1) (Default 0)

Media to use for connecting to the RTCU Communication Hub.

0

- Cellular network

1

- Local network media (Ethernet).

2

- Local network media (USB Ethernet)

3

- Wireless network media (built-in WLAN or USB WLAN)

 

Returns: INT

0

- Success.

1

- Media not found.

 

Declaration:

FUNCTION gwSetMedia : INT;
VAR_INPUT
   media : SINT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR_INPUT
   eth : BOOL;
END_VAR;
 
VAR_OUTPUT
   LED_GPRS : BOOL;
   LED_GW   : BOOL;
END_VAR;
 
PROGRAM EthernetTest;
VAR
   gw_media : SINT;
END_VAR;
 
   // Init GPRS
   gsmPower(power:=ON);
   gprsOpen();
 
   // Init Ethernet
   ethOpen();
 
   DebugMsg(message:="Program running");
 
BEGIN
   LED_GPRS := gprsConnected();
   LED_GW   := gwConnected();
 
   // Change RCH media?
   IF gw_media = 0 AND eth THEN
      // Select media
      gwSetMedia(media:=1);  // Use ethernet
      // Set curent media
      gw_media := 1;
   ELSIF gw_media = 1 AND NOT eth THEN
      // Select media
      gwSetMedia(media:=0);  // Use GPRS
      // Set curent media
      gw_media := 0;
  END_IF;
 
END;
END_PROGRAM;