netGetWLANSecurity (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

NX-200, NX-400, NX-900, LX5

Firmware version:

1.00.00


netGetWLANSecurity will read out the security parameters for a wireless network previously set from the RTCU IDE or by the netSetWLANParam function.

 

The function is usually called after calling netGetWLANParam function block.

 

 

Input:

index : INT (1..10)

The index of the wireless network.

 

 

Output:

sec_config : PTR

The security configuration for the wireless network. The type of which is read by the netGetWLANParam function.

 

 

Returns: INT

0

- Success.

1

- Illegal wireless network index

2

- Not a valid security structure

3

- Unknown security configuration / Not matching requested security

4

- Missing security structure

 

 

Declaration:

FUNCTION netGetWLANSecurity : INT;
VAR_INPUT
  index          : INT;
  sec_config     : PTR;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR
  wpa_psk  : netWLANSecurityWPA;
  wlan     : netGetWLANParam;
END_VAR;
 
FUNCTION booltostr : STRING;
VAR_INPUT
  v : BOOL;
END_VAR;
IF v THEN booltostr := "Yes"; ELSE booltostr := "No"; END_IF;
END_FUNCTION;
 
FUNCTION wlan_set;
VAR
  rc       : INT;
END_VAR;
 
  // Setup security
  wpa_psk.phrase := "passphrase";
 
  // Setup WLAN network
  rc := netSetWLANParam(
                        index       := 1
                        ,ssid       := "SSID"
                        ,sec_config := ADDR(wpa_psk)
                        ,DHCP       := ON
                        ,AutoDNS    := ON
                      );
  DebugFmt(message := "netSetWLANParam=    \1", v1 := rc);
END_FUNCTION;
 
FUNCTION wlan_show;
VAR_INPUT
  index : INT := 1;
END_VAR;
 
  wlan(index := index);
  DebugMsg(message := " SSID=         " + wlan.ssid);
  IF wlan.security = 0 THEN
    DebugMsg(message := " Security=     None");
  ELSIF wlan.security = 1 THEN
    DebugFmt(message := " Security=     WPA/WPA2 PSK");
    netGetWLANSecurity(index := index, sec_config := ADDR(wpa_psk));
    DebugMsg(message := "   phrase=         " + wpa_psk.phrase);
  ELSE
    DebugFmt(message := " Security=     Unknown (\1)", v1 := wlan.security);
  END_IF;
  DebugMsg(message := " Network=      IPv4");
  DebugMsg(message := "   IP=             " + sockIPToName(ip := wlan.ip));
  DebugMsg(message := "   Subnet=         " + sockIPToName(ip := wlan.SubnetMask));
  DebugMsg(message := "   Gw=             " + sockIPToName(ip := wlan.Gateway));
  DebugMsg(message := "   DHCP=           " + booltostr(v := wlan.dhcp));
  DebugMsg(message := "   Auto DNS=       " + booltostr(v := wlan.AutoDNS));
  DebugMsg(message := "   DNS=            " + sockIPToName(ip := wlan.DNS1));
  DebugMsg(message := "   DNS=            " + sockIPToName(ip := wlan.DNS2));
END_FUNCTION;
 
PROGRAM test;
 
wlan_set();
wlan_show(index := 1);
 
BEGIN
 // ...
END;
END_PROGRAM;