Wi fi

State

Status

Declaration

getStatus()

Example

val state:WiFi.State
assertTrue(state.status.value == EnabledState.ENABLED)
// WiFi is enabled

Network connected

Declaration

getNetworkConnected()

Example

val state:WiFi.State
assertTrue(state.networkConnected.value == ConnectionState.CONNECTED)
// WiFi is connected

Network ssid

Declaration

getNetworkSSID()

Discussion

The network SSID

Example

val state:WiFi.State
assertTrue(state.networkSSID.value == "HOME")
// WiFi network name is 'HOME'

Network security

Declaration

getNetworkSecurity()

Example

val state:WiFi.State
assertTrue(state.networkSecurity.value == NetworkSecurity.WPA2_PERSONAL)
// WiFi network uses the WPA2-Personal algorithm

Password

Declaration

getPassword()

Discussion

The network password

Example

val state:WiFi.State
assertTrue(state.password.value == "great_secret12")
// WiFi network password is 'great_secret12'

Setters

Connect to network

Declaration

public ConnectToNetwork(String networkSSID, NetworkSecurity networkSecurity, @Nullable String password)

Example

val connectToNetwork = WiFi.ConnectToNetwork("HOME", NetworkSecurity.WPA2_PERSONAL, "great_secret12")    

Forget network

Declaration

public ForgetNetwork(String networkSSID)

Example

val forgetNetwork = WiFi.ForgetNetwork("HOME")    

Enable disable wi fi

Declaration

public EnableDisableWiFi(EnabledState status)

Example

val enableDisableWiFi = WiFi.EnableDisableWiFi(EnabledState.ENABLED)    

Getters

Get Wi-Fi property availability information

Declaration

public GetStateAvailability()
public GetStateAvailability(byte... propertyIdentifiers)

Example

// get all property availabilities
val getAvailability = GetStateAvailability()
// get status and networkConnected property availabilities
val getAvailabilityProperties = GetStateAvailability(0x01, 0x02)

Get Wi-Fi properties

Declaration

public GetState()
public GetState(byte... propertyIdentifiers)            

Example

// get all properties
val getState = GetState()
// get status and networkConnected properties
val getStateProperties = GetState(0x01, 0x02)