gwGetMedia (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

5.12 / 1.62.00


This function reads the media used to connect to the RTCU Communication Hub.

This function works similarly to rchInterfaceGet.

 

 

Output:

media : SINT

Media to use for connecting to the RTCU Communication Hub.

0

- Mobile network

1

- Local network media (Ethernet).

2

- Local network media (USB Ethernet)

3

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

 

Returns: INT

1

- Success

0

- Not supported

-1

- Error reading media

 

Declaration:

FUNCTION gwGetMedia : INT;
VAR_INPUT
  media : ACCESS 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 gateway media?
gwGetMedia(media := gw_media);
IF gw_media = 0 AND eth THEN
  // Select media
  gwSetMedia(media := 1); // Use ethernet
ELSIF gw_media = 1 AND NOT eth THEN
  // Select media
  gwSetMedia(media := 0); // Use GPRS
END_IF;
 
END;
END_PROGRAM;