C

WlanInfoScriptInterface Class

The WlanInfoScriptInterface class enables you to emulate wireless LAN connections. More...

Header: #include <WlanInfoScriptInterface>

Public Types

enum StateWrap { Connected, Disconnected, Unknown }

Properties

Public Functions

QString macAddress() const
QString name() const
int signalStrength() const
StateWrap state() const

Public Slots

void setMacAddress(const QString &)
void setName(const QString &)
void setSignalStrength(int )
void setState(StateWrap )

Detailed Description

The WlanInfoScriptInterface class enables you to emulate wireless LAN connections.

You can use the functions in the class to specify the network name, signal strength, media access control (MAC) address of the WLAN access point, and state of the WLAN connection (whether the device is connected or disconnected).

The WlanInfoScriptInterface class is exposed as sysinfo.wlan.

Emulating Weakening Signals

For example, the following script emulates a weakening signal. First, it uses the signalStrength property to set the signal strength to 100 percent. Second, it reduces the signal strength by 5 percent 10 times. Finally, it uses the macAddress property to set the MAC address of the WLAN access point to "ab:cd:ef:11:22:33".

var i = 0;

sysinfo.wlan.signalStrength = 100;

while (i < 10)
{
    var signal = sysinfo.wlan.signalStrength;
    signal = signal - 5;
    sysinfo.wlan.signalStrength = signal;

    print ("Reduced signal strength to:" + signal);

    i++;
    yield(2000);
}

sysinfo.wlan.macAddress = "ab:cd:ef:11:22:33";

Emulating Roaming

The following script emulates roaming. First, it sets the state property to Disconnected to disconnect from the access point. Second, it waits for one second, before using the name property to change the access point name. Finally, it waits for another second, and then sets the state property to Connected to reconnect to the new access point.

sysinfo.wlan.state = sysinfo.wlan.Disconnected;
yield(1000);
sysinfo.wlan.name = sysinfo.wlan.name + "_new";
yield(1000);
sysinfo.wlan.state = sysinfo.wlan.Connected;

Member Type Documentation

enum WlanInfoScriptInterface::StateWrap

This enum value describes the state of the WLAN connection.

ConstantValueDescription
WlanInfoScriptInterface::ConnectedQNetworkInfo::HomeNetworkDevice is connected to a WLAN access point.
WlanInfoScriptInterface::DisconnectedQNetworkInfo::NoNetworkAvailableDevice is disconnected from a WLAN access point.
WlanInfoScriptInterface::UnknownQNetworkInfo::UnknownStatusWLAN connection status is not known.

Property Documentation

macAddress : QString

This property holds the MAC address of the WLAN access point.

Returns an empty string if the MAC address is not available or if an error occurs.

Access functions:

QString macAddress() const
void setMacAddress(const QString &)

name : QString

This property holds the service set identifier (SSID) of the WLAN.

Returns an empty string if the SSID is not available or if an error occurs.

Access functions:

QString name() const
void setName(const QString &)

signalStrength : int

This property holds the the strength of the network signal.

Returns a value from 0 to 100 using linear scaling. Returns -1 if the signal strength is not available or if an error occurs.

Access functions:

int signalStrength() const
void setSignalStrength(int )

state : StateWrap

This property holds the state of the WLAN connection.

Access functions:

StateWrap state() const
void setState(StateWrap )

Available under certain Qt licenses.
Find out more.