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;
40 /// The name of the network interface.
42 static public string InterfaceName
46 return WiFiManagerImpl.Instance.InterfaceName;
50 /// The networtk connection state.
52 static public WiFiConnectionState ConnectionState
56 return WiFiManagerImpl.Instance.ConnectionState;
60 /// A property to Check whether Wi-Fi is activated.
62 static public bool IsActivated
66 return WiFiManagerImpl.Instance.IsActivated;
71 /// (event) DeviceStateChanged is raised when the device state is changed.
73 static public event EventHandler<DeviceStateChangedEventArgs> DeviceStateChanged
77 WiFiManagerImpl.Instance.DeviceStateChanged += value;
81 WiFiManagerImpl.Instance.DeviceStateChanged -= value;
85 /// (event) ConnectionStateChanged is rasied when the connection state is changed.
87 static public event EventHandler<ConnectionStateChangedEventArgs> ConnectionStateChanged
91 WiFiManagerImpl.Instance.ConnectionStateChanged += value;
95 WiFiManagerImpl.Instance.ConnectionStateChanged -= value;
99 /// (event) RssiLevelChanged is rasied when the RSSI of connected Wi-Fi is changed.
101 static public event EventHandler<RssiLevelChangedEventArgs> RssiLevelChanged
105 WiFiManagerImpl.Instance.RssiLevelChanged += value;
109 WiFiManagerImpl.Instance.RssiLevelChanged -= value;
113 /// (event) BackgroundScanFinished is rasied when the background scan is finished.
114 /// The background scan starts automatically when wifi is activated. The callback will be invoked periodically.
116 static public event EventHandler BackgroundScanFinished
120 WiFiManagerImpl.Instance.BackgroundScanFinished += value;
124 WiFiManagerImpl.Instance.BackgroundScanFinished -= value;
128 /// Gets the result of the scan asynchronously.
130 /// <returns> A task contains the lisf for WiFiApInformation objects.</returns>
131 static public IEnumerable<WiFiAp> GetFoundAps()
133 return WiFiManagerImpl.Instance.GetFoundAps();
136 /// Gets the result of specific ap scan asynchronously.
138 /// <returns> A task contains the WiFiApInformation object.</returns>
139 static public IEnumerable<WiFiAp> GetFoundSpecificAps()
141 return WiFiManagerImpl.Instance.GetFoundSpecificAps();
144 /// Gets the list of wifi configuration.
146 /// <returns>A task contains the lisf for WiFiConfiguration objects.</returns>
147 static public IEnumerable<WiFiConfiguration> GetWiFiConfigurations()
149 return WiFiManagerImpl.Instance.GetWiFiConfigurations();
152 /// Saves Wi-Fi configuration of access point.
154 /// <param name="configuration">The configuration to be stored</param>
155 static public void SaveWiFiNetworkConfiguration(WiFiConfiguration configuration)
157 WiFiManagerImpl.Instance.SaveWiFiNetworkConfiguration(configuration);
160 /// Gets the handle of the connected access point.
162 /// <returns> The connected wifi access point(AP) information.</returns>
163 static public WiFiAp GetConnectedAp()
165 return WiFiManagerImpl.Instance.GetConnectedAp();
168 /// Deletes the information of stored access point and disconnects it when it connected.<br>
169 /// If an AP is connected, then connection information will be stored. This information is used when a connection to that AP is established automatically.
171 /// <param name="ap">The access point to be removed</param>
172 static public void RemoveAP(WiFiAp ap)
174 WiFiManagerImpl.Instance.RemoveAp(ap);
177 /// Activates Wi-Fi asynchronously.
179 /// <returns> A task indicates whether the Activate method is done or not.</returns>
180 static public Task ActivateAsync()
182 return WiFiManagerImpl.Instance.ActivateAsync();
185 /// Activates Wi-Fi asynchronously and displays Wi-Fi picker (popup) when Wi-Fi is not automatically connected.
187 /// <returns> A task indicates whether the ActivateWithPickerTeated method is done or not.</returns>
188 static public Task ActivateWithPickerTeatedAsync()
190 return WiFiManagerImpl.Instance.ActivateWithWiFiPickerTestedAsync();
193 /// Deactivates Wi-Fi asynchronously.
195 /// <returns> A task indicates whether the Deactivate method is done or not.</returns>
196 static public Task DeactivateAsync()
198 return WiFiManagerImpl.Instance.DeactivateAsync();
201 /// Starts scan asynchronously.
203 /// <returns> A task indicates whether the Scan method is done or not.</returns>
204 static public Task ScanAsync()
206 return WiFiManagerImpl.Instance.ScanAsync();
209 /// Starts specific ap scan, asynchronously.
211 /// <returns> A task contains WiFiApInformation object.</returns>
212 /// <param name="essid">The essid of hidden ap</param>
213 static public Task ScanSpecificApAsync(string essid)
215 return WiFiManagerImpl.Instance.ScanSpecificApAsync(essid);
218 /// Connects the access point asynchronously.
220 /// <param name="ap">The access point</param>
221 /// <returns> A task indicates whether the Connect method is done or not.</returns>
222 static public Task ConnectAsync(WiFiAp ap)
224 return WiFiManagerImpl.Instance.ConnectAsync(ap);
227 /// Connects the access point with WPS PBC asynchronously.
229 /// <returns> A task indicates whether the ConnectByWpsPbs method is done or not.</returns>
230 /// <param name="ap">The access point(AP)</param>
231 static public Task ConnectByWpsPbcAsync(WiFiAp ap)
233 return WiFiManagerImpl.Instance.ConnectByWpsPbcAsync(ap);
236 /// Connects the access point with WPS PIN asynchronously.
238 /// <returns> A task indicates whether the ConnectByWpsPin method is done or not.</returns>
239 /// <param name="ap">The access point(AP)</param>
240 /// <param name="pin">The WPS PIN is a non-NULL string with length greater than 0 and less than or equal to 8.</param>
241 static public Task ConnectByWpsPinAsync(WiFiAp ap, string pin)
243 Log.Debug(Globals.LogTag, "ConnectByWpsPinAsync");
244 return WiFiManagerImpl.Instance.ConnectByWpsPinAsync(ap, pin);
247 /// Disconnects the access point asynchronously.
249 /// <returns> A task indicates whether the Disconnect method is done or not.</returns>
250 static public Task DisconnectAsync(WiFiAp ap)
252 return WiFiManagerImpl.Instance.DisconnectAsync(ap);