netGetAPParam (Functionblock)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

1.50.00


netGetAPParam will read out the parameters for a wireless network previously set from the RTCU M2M Studio or by the netSetAPParam function.

 

The format of an IP address is the same as returned by the sockGetLocalIP function.

 

 

Output:

SSID : STRING

The SSID of the wireless network.

 

Security : INT

The type of security used by the wireless network. Use the netGetAPSecurity function to get the security configuration.

0

None

None

1

WPA/WPA2 PSK

netWLANSecurityWPA

 

Country : STRING

The country code where the device operates.

The ISO 3166-1 standard is used for the country code, as f.ex. 'DK' for Denmark.

 

Address : DINT

The IP address of the device.

 

Subnet : DINT

The Subnet mask of the device.

 

Hidden : BOOL

Whether the SSID is broadcast.

 

Chnl : SINT

The channel used for communication.

 

 

Declaration:

FUNCTION_BLOCK netGetAPParam;
VAR_OUTPUT
   SSID           : STRING;
   Security       : INT;
   Country        : STRING;
   Address        : DINT;
   Subnet         : DINT;
   Hidden         : BOOL;
   Chnl           : SINT;
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;