netGetAPSecurity (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

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

Firmware version:

1.42.00


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

 

The function is usually called after calling netGetAPParam function block.

 

 

Output:

sec_config : PTR

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

 

 

Returns: INT

0

- Success.

2

- Not a valid security structure

3

- Unknown security configuration / Not matching requested security

4

- Missing security structure

 

 

Declaration:

FUNCTION netGetAPSecurity : INT;
VAR_INPUT
  sec_config     : MANDATORY PTR;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR
  wpa_psk  : netWLANSecurityWPA;
  net      : netGetAPParam;
END_VAR;
 
FUNCTION ap_set;
VAR
  rc       : INT;
END_VAR;
 
  // Setup security
  wpa_psk.phrase  := "passphrase";
 
  // Setup WLAN network
  rc := netSetAPParam(
                      ssid        := "SSID"
                      ,hidden     := FALSE
                      ,chnl       := 1
                      ,sec_config := ADDR(wpa_psk)
                      ,Address    := sockIPFromName(str := "192.168.1.1")
                      ,Subnet     := sockIPFromName(str := "255.255.255.0")
                     );
  DebugFmt(message := "netSetAPParam=    \1", v1 := rc);
END_FUNCTION;
 
FUNCTION ap_show;
  net();
  DebugMsg(message := " SSID=         " + net.ssid);
  IF net.security = 0 THEN
    DebugMsg(message := " Security=     None");
  ELSIF net.security = 1 THEN
    DebugFmt(message := " Security=     WPA/WPA2 PSK");
    netGetAPSecurity(sec_config := ADDR(wpa_psk));
    DebugMsg(message := "   phrase=         " + wpa_psk.phrase);
  ELSE
    DebugFmt(message := " Security=     Unknown (\1)", v1 := net.security);
  END_IF;
  DebugMsg(message := " Network=      IPv4");
  DebugMsg(message := "   Address=        " + sockIPToName(ip := net.Address));
  DebugMsg(message := "   Subnet=         " + sockIPToName(ip := net.Subnet));
END_FUNCTION;
 
PROGRAM example;
 
ap_set();
ap_show();
 
BEGIN
// ...
END;
END_PROGRAM;