netGetSignalLevel (Function)

Top  Previous  Next

Architecture:

NX32 / NX32L

Device support:

All

Firmware version:

1.00 / 1.00.00


netGetSignalLevel will return the signal strength for a connected network interface.

The returned value will either be the real signal strength (expressed in dBm) or as a percentage (between 0 and 100), depending of the value of the "dbm" input parameter.

Please note that the signal level is logarithmic in nature and that the value in percentage is just a linear representation of the real signal level from the lowest to the highest level. 10 dB (which is 10 times the RF power) of extra signal will only give an extra percentage reading of 16.

 

The range of the real signal level depends on the type of interface:

Interface type

Lowest

Highest

Mobile

-113 dBm

-51 dBm

WLAN

-100 dBm

-40 dBm

LAN (Simulated values)

-100 dBm

-40 dBm

 

 

Input:

iface : SINT

The network interface to read configuration for. 1 = Mobile network, 2 = LAN 1 network, etc. (See Network).

Note that the values for the LAN networks are simulated and are only included for completeness.

 

dbm : BOOL (default FALSE)

Set to true to get the level as the real signal strength in dBm, set to false to get it as a percentage.

 

Output:

ssid : STRING

The SSID of the network, if the network is WLAN.

 

level : SINT

The signal strength.

 

Returns: INT

1

- Success.

0

- Interface not available or not supported.

-1

- Invalid interface.

-2

- The network is not open.

-3

- Error

 

 

Declaration:

FUNCTION netGetSignalLevel : INT;
VAR_INPUT
  iface          : SINT;
  dbm            : BOOL := FALSE;
  ssid           : ACCESS STRING;
  level          : ACCESS SINT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  level : SINT;
  ssid  : STRING;
END_VAR;
 
BEGIN
  ...
  // Get signal level in % (from 0 to 100)
  netGetSignalLevel(iface := 4, dbm := FALSE, ssid := ssid, level := level);
  ...
END;
 
END_PROGRAM;