2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
19 using System.Threading.Tasks;
21 namespace Tizen.Network.WiFi
24 /// A manager class which allows applications to connect to a Wireless Local Area Network (WLAN) and to transfer data over the network.<br>
25 /// The Wi-Fi Manager enables your application to activate and deactivate a local Wi-Fi device, and to connect to a WLAN network in the infrastructure mode.
27 static public class WiFiManager
30 /// The local MAC address.
32 static public string MacAddress
36 return WiFiManagerImpl.Instance.MacAddress;
41 /// The name of the network interface.
43 static public string InterfaceName
47 return WiFiManagerImpl.Instance.InterfaceName;
52 /// The network connection state.
54 static public WiFiConnectionState ConnectionState
58 return WiFiManagerImpl.Instance.ConnectionState;
63 /// A property to Check whether Wi-Fi is activated.
65 static public bool IsActive
69 return WiFiManagerImpl.Instance.IsActive;
74 /// DeviceStateChanged is raised when the device state is changed.
76 static public event EventHandler<DeviceStateChangedEventArgs> DeviceStateChanged
80 WiFiManagerImpl.Instance.DeviceStateChanged += value;
84 WiFiManagerImpl.Instance.DeviceStateChanged -= value;
89 /// ConnectionStateChanged is raised when the connection state is changed.
91 static public event EventHandler<ConnectionStateChangedEventArgs> ConnectionStateChanged
95 WiFiManagerImpl.Instance.ConnectionStateChanged += value;
99 WiFiManagerImpl.Instance.ConnectionStateChanged -= value;
104 /// RssiLevelChanged is raised when the RSSI of connected Wi-Fi is changed.
106 static public event EventHandler<RssiLevelChangedEventArgs> RssiLevelChanged
110 WiFiManagerImpl.Instance.RssiLevelChanged += value;
114 WiFiManagerImpl.Instance.RssiLevelChanged -= value;
119 /// BackgroundScanFinished is raised when the background scan is finished.
120 /// The background scan starts automatically when wifi is activated. The callback will be invoked periodically.
122 static public event EventHandler BackgroundScanFinished
126 WiFiManagerImpl.Instance.BackgroundScanFinished += value;
130 WiFiManagerImpl.Instance.BackgroundScanFinished -= value;
135 /// Gets the result of the scan.
137 /// <returns> A list of WiFiAP objects.</returns>
138 static public IEnumerable<WiFiAP> GetFoundAPs()
140 return WiFiManagerImpl.Instance.GetFoundAPs();
144 /// Gets the result of specific AP scan.
146 /// <returns> A list contains the WiFiAP objects.</returns>
147 static public IEnumerable<WiFiAP> GetFoundSpecificAPs()
149 return WiFiManagerImpl.Instance.GetFoundSpecificAPs();
153 /// Gets the list of wifi configurations.
155 /// <returns>A list contains the WiFiConfiguration objects.</returns>
156 static public IEnumerable<WiFiConfiguration> GetWiFiConfigurations()
158 return WiFiManagerImpl.Instance.GetWiFiConfigurations();
162 /// Saves Wi-Fi configuration of access point.
164 /// <param name="configuration">The configuration to be stored</param>
165 static public void SaveWiFiConfiguration(WiFiConfiguration configuration)
167 WiFiManagerImpl.Instance.SaveWiFiNetworkConfiguration(configuration);
171 /// Gets the object of the connected WiFiAP.
173 /// <returns> The connected wifi access point(AP) information.</returns>
174 static public WiFiAP GetConnectedAP()
176 return WiFiManagerImpl.Instance.GetConnectedAP();
180 /// Activates Wi-Fi asynchronously.
182 /// <returns> A task indicating whether the Activate method is done or not.</returns>
183 static public Task ActivateAsync()
185 return WiFiManagerImpl.Instance.ActivateAsync();
189 /// Activates Wi-Fi asynchronously and displays Wi-Fi picker (popup) when Wi-Fi is not automatically connected.
191 /// <returns> A task indicating whether the ActivateWithPicker method is done or not.</returns>
192 static public Task ActivateWithPickerAsync()
194 return WiFiManagerImpl.Instance.ActivateWithWiFiPickerTestedAsync();
198 /// Deactivates Wi-Fi asynchronously.
200 /// <returns> A task indicating whether the Deactivate method is done or not.</returns>
201 static public Task DeactivateAsync()
203 return WiFiManagerImpl.Instance.DeactivateAsync();
207 /// Starts scan asynchronously.
209 /// <returns> A task indicating whether the Scan method is done or not.</returns>
210 static public Task ScanAsync()
212 return WiFiManagerImpl.Instance.ScanAsync();
216 /// Starts specific access point scan, asynchronously.
218 /// <returns> A task indicating whether the ScanSpecificAP method is done or not.</returns>
219 /// <param name="essid">The essid of hidden ap</param>
220 static public Task ScanSpecificAPAsync(string essid)
222 return WiFiManagerImpl.Instance.ScanSpecificAPAsync(essid);