diff options
17 files changed, 312 insertions, 243 deletions
diff --git a/Tizen.Network.WiFi/Interop/Interop.WiFi.cs b/Tizen.Network.WiFi/Interop/Interop.WiFi.cs index df0d49b..6a94c07 100755 --- a/Tizen.Network.WiFi/Interop/Interop.WiFi.cs +++ b/Tizen.Network.WiFi/Interop/Interop.WiFi.cs @@ -186,7 +186,7 @@ internal static partial class Interop [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_get_eap_private_key_file")] internal static extern int GetEapPrivateKeyFile(IntPtr ap, out IntPtr file); [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_set_eap_private_key_info")] - internal static extern int SetEapPrivateKeyInfo(IntPtr ap, string file, string password); + internal static extern int SetEapPrivateKeyFile(IntPtr ap, string file, string password); [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_get_eap_type")] internal static extern int GetEapType(IntPtr ap, out int eapType); [DllImport(Libraries.WiFi, EntryPoint = "wifi_manager_ap_set_eap_type")] diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/ConnectionStateChangedEventArgs.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/ConnectionStateChangedEventArgs.cs index 2850edf..fee5ca8 100644..100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/ConnectionStateChangedEventArgs.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/ConnectionStateChangedEventArgs.cs @@ -31,6 +31,7 @@ namespace Tizen.Network.WiFi _state = s; _ap = new WiFiAP(_apHandle); } + /// <summary> /// The wifi connection state. /// </summary> @@ -41,6 +42,7 @@ namespace Tizen.Network.WiFi return _state; } } + /// <summary> /// The access point /// </summary> diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/IWiFiEap.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/IWiFiEap.cs index 5556be4..ebf21ed 100644..100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/IWiFiEap.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/IWiFiEap.cs @@ -27,12 +27,14 @@ namespace Tizen.Network.WiFi /// The file path of CA Certificate of EAP. /// </summary> string CaCertificationFile { get; set; } + /// <summary> /// The EAP type of wifi. /// </summary> WiFiEapType EapType { get; set; } + /// <summary> - /// The type of EAP phase2 authentication of Wi-Fi. + /// The type of EAP phase2 authentication of Wi-Fi. /// </summary> WiFiAuthenticationType AuthenticationType { get; set; } } //WiFiEap diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/RssiLevelChangedEventArgs.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/RssiLevelChangedEventArgs.cs index 41d0e98..25c1941 100644..100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/RssiLevelChangedEventArgs.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/RssiLevelChangedEventArgs.cs @@ -29,6 +29,7 @@ namespace Tizen.Network.WiFi { _level = l; } + /// <summary> /// The wifi RSSI level. /// </summary> diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs index c10ca57..e18b7d4 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs @@ -15,15 +15,19 @@ */ using System; +using System.Threading.Tasks; +using System.Collections.Generic; namespace Tizen.Network.WiFi { /// <summary> - /// A class for manager the network information of the access point(AP). It allows applications to manager network informaiton. + /// A class for managing the network information of the access point(AP). /// </summary> public class WiFiAP : IDisposable { private IntPtr _apHandle = IntPtr.Zero; + private Dictionary<IntPtr, Interop.WiFi.VoidCallback> _callback_map = new Dictionary<IntPtr, Interop.WiFi.VoidCallback>(); + private int _requestId = 0; private WiFiNetwork _network; private WiFiSecurity _security; private bool disposed = false; @@ -38,6 +42,7 @@ namespace Tizen.Network.WiFi return _network; } } + /// <summary> /// The security information of the access point(AP). /// </summary> @@ -55,20 +60,22 @@ namespace Tizen.Network.WiFi _apHandle = handle; Initialize(); } + /// <summary> - /// Creates a object for the access point. + /// Creates an object for the access point. /// </summary> - /// <param name="essid">The ESSID (Extended Service Set Identifier) can be UTF-8 encoded </param> + /// <param name="essid">The Extended Service Set Identifier of the access point.</param> public WiFiAP(string essid) { Log.Debug(Globals.LogTag, "New WiFiAP. Essid: " + essid); createHandle(essid, true); Initialize(); } + /// <summary> - /// Creates a object for the hidden access point. + /// Creates an object for the hidden access point. /// </summary> - /// <param name="essid">The ESSID (Extended Service Set Identifier) can be UTF-8 encoded </param> + /// <param name="essid">The Extended Service Set Identifier of the access point.</param> /// <param name="hidden">The value to set hidden AP</param> public WiFiAP(string essid, bool hidden) { @@ -81,6 +88,9 @@ namespace Tizen.Network.WiFi Dispose(false); } + /// <summary> + /// A method to destroy the managed WiFiAP objects. + /// </summary> public void Dispose() { Dispose(true); @@ -144,5 +154,160 @@ namespace Tizen.Network.WiFi { return _apHandle; } + + /// <summary> + /// Connects the access point asynchronously. + /// </summary> + /// <returns> A task indicating whether the Connect method is done or not.</returns> + public Task ConnectAsync() + { + TaskCompletionSource<bool> task = new TaskCompletionSource<bool>(); + IntPtr id; + lock (_callback_map) + { + id = (IntPtr)_requestId++; + _callback_map[id] = (error, key) => + { + Log.Debug(Globals.LogTag, "Connecting finished : " + (WiFiError)error); + if (error != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Error occurs during WiFi connecting, " + (WiFiError)error); + task.SetException(new InvalidOperationException("Error occurs during WiFi connecting, " + (WiFiError)error)); + } + task.SetResult(true); + lock (_callback_map) + { + _callback_map.Remove(key); + } + }; + } + int ret = Interop.WiFi.Connect(WiFiManagerImpl.Instance.GetHandle(), _apHandle, _callback_map[id], id); + if (ret != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret); + } + return task.Task; + } + + /// <summary> + /// Connects the access point with WPS PBC asynchronously. + /// </summary> + /// <returns> A task indicating whether the ConnectByWpsPbs method is done or not.</returns> + public Task ConnectByWpsPbcAsync() + { + TaskCompletionSource<bool> task = new TaskCompletionSource<bool>(); + IntPtr id; + lock (_callback_map) + { + id = (IntPtr)_requestId++; + _callback_map[id] = (error, key) => + { + Log.Debug(Globals.LogTag, "Connecting by WPS PBC finished"); + if (error != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Error occurs during WiFi connecting, " + (WiFiError)error); + task.SetException(new InvalidOperationException("Error occurs during WiFi connecting, " + (WiFiError)error)); + } + task.SetResult(true); + lock (_callback_map) + { + _callback_map.Remove(key); + } + }; + } + int ret = Interop.WiFi.ConnectByWpsPbc(WiFiManagerImpl.Instance.GetHandle(), _apHandle, _callback_map[id], id); + if (ret != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret); + } + return task.Task; + } + + /// <summary> + /// Connects the access point with WPS PIN asynchronously. + /// </summary> + /// <returns> A task indicating whether the ConnectByWpsPin method is done or not.</returns> + /// <param name="pin">The WPS PIN is a non-null string with length greater than 0 and less than or equal to 8.</param> + public Task ConnectByWpsPinAsync(string pin) + { + TaskCompletionSource<bool> task = new TaskCompletionSource<bool>(); + IntPtr id; + lock (_callback_map) + { + id = (IntPtr)_requestId++; + _callback_map[id] = (error, key) => + { + Log.Debug(Globals.LogTag, "Connecting by WPS PIN finished"); + if (error != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Error occurs during WiFi connecting, " + (WiFiError)error); + task.SetException(new InvalidOperationException("Error occurs during WiFi connecting, " + (WiFiError)error)); + } + task.SetResult(true); + lock (_callback_map) + { + _callback_map.Remove(key); + } + }; + } + int ret = Interop.WiFi.ConnectByWpsPin(WiFiManagerImpl.Instance.GetHandle(), _apHandle, pin, _callback_map[id], id); + if (ret != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret); + } + return task.Task; + } + + /// <summary> + /// Disconnects the access point asynchronously. + /// </summary> + /// <returns> A task indicating whether the Disconnect method is done or not.</returns> + public Task DisconnectAsync() + { + TaskCompletionSource<bool> task = new TaskCompletionSource<bool>(); + IntPtr id; + lock (_callback_map) + { + id = (IntPtr)_requestId++; + _callback_map[id] = (error, key) => + { + Log.Debug(Globals.LogTag, "Disconnecting finished"); + if (error != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Error occurs during WiFi disconnecting, " + (WiFiError)error); + task.SetException(new InvalidOperationException("Error occurs during WiFi disconnecting, " + (WiFiError)error)); + } + task.SetResult(true); + lock (_callback_map) + { + _callback_map.Remove(key); + } + }; + } + int ret = Interop.WiFi.Disconnect(WiFiManagerImpl.Instance.GetHandle(), _apHandle, _callback_map[id], id); + if (ret != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Failed to disconnect wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret); + } + return task.Task; + } + + /// <summary> + /// Deletes the information of stored access point and disconnects it when it is connected.<br> + /// If an AP is connected, then connection information will be stored. This information is used when a connection to that AP is established automatically. + /// </summary> + public void RemoveAP() + { + int ret = Interop.WiFi.RemoveAP(WiFiManagerImpl.Instance.GetHandle(), _apHandle); + if (ret != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Failed to remove with AP, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret); + } + } } } diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs index a41ba81..5c1e388 100644..100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs @@ -80,6 +80,7 @@ namespace Tizen.Network.WiFi } } } + public System.Net.IPAddress Dns2 { get @@ -105,6 +106,7 @@ namespace Tizen.Network.WiFi } } } + public System.Net.IPAddress Gateway { get @@ -130,6 +132,7 @@ namespace Tizen.Network.WiFi } } } + public System.Net.IPAddress SubnetMask { get @@ -155,6 +158,7 @@ namespace Tizen.Network.WiFi } } } + public System.Net.IPAddress IP { get @@ -180,6 +184,7 @@ namespace Tizen.Network.WiFi } } } + public IPConfigType IPConfigType { get diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs index aa0033f..e2d67d0 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs @@ -23,7 +23,7 @@ using Tizen.Network.Connection; namespace Tizen.Network.WiFi { /// <summary> - /// A class for managing the configuration of Wi-Fi. It allows applications to manage the configuration information of Wi-Fi. + /// A class for managing the configuration of Wi-Fi. /// </summary> public class WiFiConfiguration : IDisposable { @@ -48,10 +48,11 @@ namespace Tizen.Network.WiFi return Marshal.PtrToStringAnsi(strPtr); } } + /// <summary> /// The security type of access point(AP). /// </summary> - public WiFiSecureType SecurityType + public WiFiSecurityType SecurityType { get { @@ -61,9 +62,10 @@ namespace Tizen.Network.WiFi { Log.Error(Globals.LogTag, "Failed to get security type, Error - " + (WiFiError)ret); } - return (WiFiSecureType)type; + return (WiFiSecurityType)type; } } + /// <summary> /// The proxy address. /// </summary> @@ -90,6 +92,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// A property check whether the access point(AP) is hidden or not. /// </summary> @@ -114,6 +117,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The EAP Configuration. /// </summary> @@ -131,7 +135,13 @@ namespace Tizen.Network.WiFi _eapConfig = new WiFiEapConfiguration(_configHandle); } - public WiFiConfiguration(string name, string passPhrase, WiFiSecureType type) + /// <summary> + /// Creates a WiFiConfiguration object with the given name, passphrase and securetype. + /// </summary> + /// <param name="name">Name of the WiFi.</param> + /// <param name="passPhrase">Password to access the WiFi.</param> + /// <param name="type">Security type of the WiFi.</param> + public WiFiConfiguration(string name, string passPhrase, WiFiSecurityType type) { int ret = Interop.WiFi.Config.Create(WiFiManagerImpl.Instance.GetHandle(), name, passPhrase, (int)type, out _configHandle); if (ret != (int)WiFiError.None) @@ -146,6 +156,9 @@ namespace Tizen.Network.WiFi Dispose(false); } + /// <summary> + /// A method to destroy the managed objects in WiFiConfiguration. + /// </summary> public void Dispose() { Dispose(true); diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEap.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEap.cs index 3a8e354..325e5f9 100644..100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEap.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEap.cs @@ -24,8 +24,7 @@ using System.Runtime.InteropServices; namespace Tizen.Network.WiFi { /// <summary> - /// A class for managing the EAP information of access point(AP). It allows applications to manager EAP information. - /// This class is not intended to create instance directly from applications. + /// A class for managing the EAP information of access point(AP). /// </summary> public class WiFiEap : IWiFiEap, IDisposable { @@ -59,6 +58,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The EAP type of wifi. /// </summary> @@ -85,6 +85,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The type of EAP phase2 authentication of Wi-Fi. /// </summary> @@ -122,6 +123,9 @@ namespace Tizen.Network.WiFi Dispose(false); } + /// <summary> + /// A method to destroy the managed objects in WiFiEap. + /// </summary> public void Dispose() { Dispose(true); @@ -162,12 +166,12 @@ namespace Tizen.Network.WiFi /// </summary> /// <param name="privateKeyFile">The file path of private key.</param> /// <param name="password">The password.</param> - public void SetPrivateKeyInfo(string privateKeyFile, string password) + public void SetPrivateKeyFile(string privateKeyFile, string password) { - int ret = Interop.WiFi.AP.SetEapPrivateKeyInfo(_apHandle, privateKeyFile, password); + int ret = Interop.WiFi.AP.SetEapPrivateKeyFile(_apHandle, privateKeyFile, password); if (ret != (int)WiFiError.None) { - Log.Error(Globals.LogTag, "Failed to set private key info, Error - " + (WiFiError)ret); + Log.Error(Globals.LogTag, "Failed to set private key file, Error - " + (WiFiError)ret); WiFiErrorFactory.ThrowWiFiException(ret, _apHandle); } } @@ -206,7 +210,7 @@ namespace Tizen.Network.WiFi /// Gets the username of EAP passphrase. /// </summary> /// <returns>The user name</returns> - public string GetEapPassphraseUserName() + public string GetUserName() { IntPtr strptr; bool passwordSet; @@ -218,11 +222,12 @@ namespace Tizen.Network.WiFi } return Marshal.PtrToStringAnsi(strptr); } + /// <summary> - /// Returns whether the password is set for not set. + /// Returns whether the password is set or not. /// </summary> - /// <returns>ture if password is set, otherwise flase if password is not set.</returns> - public bool IsEapPassphrasePasswordSet() + /// <returns>True if password is set, false if password is not set.</returns> + public bool IsPasswordSet() { IntPtr strptr; bool passwordSet; @@ -236,18 +241,29 @@ namespace Tizen.Network.WiFi } /// <summary> - /// Sets the passphrase of EAP. - /// You can set one of user_name and password as NULL.<br> - /// In this case, the value of a parameter which is set as NULL will be the previous value. But it is not allowed that both user_name and password are set as NULL. + /// Sets the user name of EAP. /// </summary> /// <param name="userName">The user name</param> + public void SetUserName(string userName) + { + int ret = Interop.WiFi.AP.SetEapPassphrase(_apHandle, userName, null); + if (ret != (int)WiFiError.None) + { + Log.Error(Globals.LogTag, "Failed to set username, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, _apHandle); + } + } + + /// <summary> + /// Sets the password of EAP. + /// </summary> /// <param name="password">The password</param> - public void SetEapPassphrase(string userName, string password) + public void SetPassword(string password) { - int ret = Interop.WiFi.AP.SetEapPassphrase(_apHandle, userName, password); + int ret = Interop.WiFi.AP.SetEapPassphrase(_apHandle, null, password); if (ret != (int)WiFiError.None) { - Log.Error(Globals.LogTag, "Failed to set passphrase, Error - " + (WiFiError)ret); + Log.Error(Globals.LogTag, "Failed to set password, Error - " + (WiFiError)ret); WiFiErrorFactory.ThrowWiFiException(ret, _apHandle); } } diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEapConfiguration.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEapConfiguration.cs index 2a2175b..2235453 100644..100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEapConfiguration.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEapConfiguration.cs @@ -21,7 +21,6 @@ namespace Tizen.Network.WiFi { /// <summary> /// A class for managing the EAP configuration. - /// This class is not intended to create instance directly from applications. /// </summary> public class WiFiEapConfiguration : IWiFiEap, IDisposable { @@ -54,6 +53,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The EAP type of wifi. /// </summary> @@ -80,6 +80,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The type of EAP phase2 authentication of Wi-Fi. /// </summary> @@ -106,6 +107,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The anonymous identity of access point(AP). /// </summary> @@ -133,6 +135,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The identity of access point(AP). /// </summary> @@ -160,6 +163,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The subject match of access point(AP). /// </summary> @@ -198,6 +202,9 @@ namespace Tizen.Network.WiFi Dispose(false); } + /// <summary> + /// A method to destroy the managed objects in WiFiEapConfiguration. + /// </summary> public void Dispose() { Dispose(true); @@ -232,6 +239,7 @@ namespace Tizen.Network.WiFi } return Marshal.PtrToStringAnsi(strPtr); } + /// <summary> /// Sets access point client cert file to configuration. /// </summary> diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEnumerations.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEnumerations.cs index 1f36d92..c012961 100644..100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEnumerations.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiEnumerations.cs @@ -44,6 +44,7 @@ namespace Tizen.Network.WiFi /// </summary> Aka = 4 } + /// <summary> /// Enumeration for Wi-Fi RSSI level. /// </summary> @@ -70,6 +71,7 @@ namespace Tizen.Network.WiFi /// </summary> Level4 = 4 } + /// <summary> /// Enumeration for Wi-Fi connection state. /// </summary> @@ -96,6 +98,7 @@ namespace Tizen.Network.WiFi /// </summary> Connected = 3 } + /// <summary> /// Enumeration for Wi-Fi device state. /// </summary> @@ -110,6 +113,7 @@ namespace Tizen.Network.WiFi /// </summary> Activated = 1 } + /// <summary> /// Enumeration for Wi-Fi proxy type. /// </summary> @@ -128,6 +132,7 @@ namespace Tizen.Network.WiFi /// </summary> Manual = 2 } + /// <summary> /// Enumeration for Wi-Fi authentication type. /// </summary> diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiErrorFactory.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiErrorFactory.cs index 687f154..93e9f57 100644..100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiErrorFactory.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiErrorFactory.cs @@ -80,6 +80,5 @@ namespace Tizen.Network.WiFi throw new InvalidOperationException(err.ToString()); } } - } } diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs index f4e69a8..5767956 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManager.cs @@ -36,6 +36,7 @@ namespace Tizen.Network.WiFi return WiFiManagerImpl.Instance.MacAddress; } } + /// <summary> /// The name of the network interface. /// </summary> @@ -46,8 +47,9 @@ namespace Tizen.Network.WiFi return WiFiManagerImpl.Instance.InterfaceName; } } + /// <summary> - /// The networtk connection state. + /// The network connection state. /// </summary> static public WiFiConnectionState ConnectionState { @@ -56,6 +58,7 @@ namespace Tizen.Network.WiFi return WiFiManagerImpl.Instance.ConnectionState; } } + /// <summary> /// A property to Check whether Wi-Fi is activated. /// </summary> @@ -68,7 +71,7 @@ namespace Tizen.Network.WiFi } /// <summary> - /// (event) DeviceStateChanged is raised when the device state is changed. + /// DeviceStateChanged is raised when the device state is changed. /// </summary> static public event EventHandler<DeviceStateChangedEventArgs> DeviceStateChanged { @@ -81,8 +84,9 @@ namespace Tizen.Network.WiFi WiFiManagerImpl.Instance.DeviceStateChanged -= value; } } + /// <summary> - /// (event) ConnectionStateChanged is rasied when the connection state is changed. + /// ConnectionStateChanged is raised when the connection state is changed. /// </summary> static public event EventHandler<ConnectionStateChangedEventArgs> ConnectionStateChanged { @@ -95,8 +99,9 @@ namespace Tizen.Network.WiFi WiFiManagerImpl.Instance.ConnectionStateChanged -= value; } } + /// <summary> - /// (event) RssiLevelChanged is rasied when the RSSI of connected Wi-Fi is changed. + /// RssiLevelChanged is raised when the RSSI of connected Wi-Fi is changed. /// </summary> static public event EventHandler<RssiLevelChangedEventArgs> RssiLevelChanged { @@ -109,8 +114,9 @@ namespace Tizen.Network.WiFi WiFiManagerImpl.Instance.RssiLevelChanged -= value; } } + /// <summary> - /// (event) BackgroundScanFinished is rasied when the background scan is finished. + /// BackgroundScanFinished is raised when the background scan is finished. /// The background scan starts automatically when wifi is activated. The callback will be invoked periodically. /// </summary> static public event EventHandler BackgroundScanFinished @@ -124,132 +130,96 @@ namespace Tizen.Network.WiFi WiFiManagerImpl.Instance.BackgroundScanFinished -= value; } } + /// <summary> - /// Gets the result of the scan asynchronously. + /// Gets the result of the scan. /// </summary> - /// <returns> A task contains the lisf for WiFiAPInformation objects.</returns> + /// <returns> A list of WiFiAP objects.</returns> static public IEnumerable<WiFiAP> GetFoundAPs() { return WiFiManagerImpl.Instance.GetFoundAPs(); } + /// <summary> - /// Gets the result of specific ap scan asynchronously. + /// Gets the result of specific AP scan. /// </summary> - /// <returns> A task contains the WiFiAPInformation object.</returns> + /// <returns> A list contains the WiFiAP objects.</returns> static public IEnumerable<WiFiAP> GetFoundSpecificAPs() { return WiFiManagerImpl.Instance.GetFoundSpecificAPs(); } + /// <summary> - /// Gets the list of wifi configuration. + /// Gets the list of wifi configurations. /// </summary> - /// <returns>A task contains the lisf for WiFiConfiguration objects.</returns> + /// <returns>A list contains the WiFiConfiguration objects.</returns> static public IEnumerable<WiFiConfiguration> GetWiFiConfigurations() { return WiFiManagerImpl.Instance.GetWiFiConfigurations(); } + /// <summary> /// Saves Wi-Fi configuration of access point. /// </summary> /// <param name="configuration">The configuration to be stored</param> - static public void SaveWiFiNetworkConfiguration(WiFiConfiguration configuration) + static public void SaveWiFiConfiguration(WiFiConfiguration configuration) { WiFiManagerImpl.Instance.SaveWiFiNetworkConfiguration(configuration); } + /// <summary> - /// Gets the handle of the connected access point. + /// Gets the object of the connected WiFiAP. /// </summary> /// <returns> The connected wifi access point(AP) information.</returns> static public WiFiAP GetConnectedAP() { return WiFiManagerImpl.Instance.GetConnectedAP(); } - /// <summary> - /// Deletes the information of stored access point and disconnects it when it connected.<br> - /// If an AP is connected, then connection information will be stored. This information is used when a connection to that AP is established automatically. - /// </summary> - /// <param name="ap">The access point to be removed</param> - static public void RemoveAP(WiFiAP ap) - { - WiFiManagerImpl.Instance.RemoveAP(ap); - } + /// <summary> /// Activates Wi-Fi asynchronously. /// </summary> - /// <returns> A task indicates whether the Activate method is done or not.</returns> + /// <returns> A task indicating whether the Activate method is done or not.</returns> static public Task ActivateAsync() { return WiFiManagerImpl.Instance.ActivateAsync(); } + /// <summary> /// Activates Wi-Fi asynchronously and displays Wi-Fi picker (popup) when Wi-Fi is not automatically connected. /// </summary> - /// <returns> A task indicates whether the ActivateWithPickerTested method is done or not.</returns> - static public Task ActivateWithPickerTestedAsync() + /// <returns> A task indicating whether the ActivateWithPicker method is done or not.</returns> + static public Task ActivateWithPickerAsync() { return WiFiManagerImpl.Instance.ActivateWithWiFiPickerTestedAsync(); } + /// <summary> /// Deactivates Wi-Fi asynchronously. /// </summary> - /// <returns> A task indicates whether the Deactivate method is done or not.</returns> + /// <returns> A task indicating whether the Deactivate method is done or not.</returns> static public Task DeactivateAsync() { return WiFiManagerImpl.Instance.DeactivateAsync(); } + /// <summary> /// Starts scan asynchronously. /// </summary> - /// <returns> A task indicates whether the Scan method is done or not.</returns> + /// <returns> A task indicating whether the Scan method is done or not.</returns> static public Task ScanAsync() { return WiFiManagerImpl.Instance.ScanAsync(); } + /// <summary> - /// Starts specific ap scan, asynchronously. + /// Starts specific access point scan, asynchronously. /// </summary> - /// <returns> A task contains WiFiAPInformation object.</returns> + /// <returns> A task indicating whether the ScanSpecificAP method is done or not.</returns> /// <param name="essid">The essid of hidden ap</param> static public Task ScanSpecificAPAsync(string essid) { return WiFiManagerImpl.Instance.ScanSpecificAPAsync(essid); } - /// <summary> - /// Connects the access point asynchronously. - /// </summary> - /// <param name="ap">The access point</param> - /// <returns> A task indicates whether the Connect method is done or not.</returns> - static public Task ConnectAsync(WiFiAP ap) - { - return WiFiManagerImpl.Instance.ConnectAsync(ap); - } - /// <summary> - /// Connects the access point with WPS PBC asynchronously. - /// </summary> - /// <returns> A task indicates whether the ConnectByWpsPbs method is done or not.</returns> - /// <param name="ap">The access point(AP)</param> - static public Task ConnectByWpsPbcAsync(WiFiAP ap) - { - return WiFiManagerImpl.Instance.ConnectByWpsPbcAsync(ap); - } - /// <summary> - /// Connects the access point with WPS PIN asynchronously. - /// </summary> - /// <returns> A task indicates whether the ConnectByWpsPin method is done or not.</returns> - /// <param name="ap">The access point(AP)</param> - /// <param name="pin">The WPS PIN is a non-NULL string with length greater than 0 and less than or equal to 8.</param> - static public Task ConnectByWpsPinAsync(WiFiAP ap, string pin) - { - Log.Debug(Globals.LogTag, "ConnectByWpsPinAsync"); - return WiFiManagerImpl.Instance.ConnectByWpsPinAsync(ap, pin); - } - /// <summary> - /// Disconnects the access point asynchronously. - /// </summary> - /// <returns> A task indicates whether the Disconnect method is done or not.</returns> - static public Task DisconnectAsync(WiFiAP ap) - { - return WiFiManagerImpl.Instance.DisconnectAsync(ap); - } } } diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs index 715ace2..7cc4baa 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs @@ -99,6 +99,7 @@ namespace Tizen.Network.WiFi return _macAddress; } } + internal string InterfaceName { get @@ -113,6 +114,7 @@ namespace Tizen.Network.WiFi return name; } } + internal WiFiConnectionState ConnectionState { get @@ -127,6 +129,7 @@ namespace Tizen.Network.WiFi return (WiFiConnectionState)state; } } + internal bool IsActive { get @@ -323,17 +326,6 @@ namespace Tizen.Network.WiFi return ap; } - internal void RemoveAP(WiFiAP ap) - { - IntPtr apHandle = ap.GetHandle(); - int ret = Interop.WiFi.RemoveAP(GetHandle(), apHandle); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to remove with AP, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); - } - } - internal Task ActivateAsync() { TaskCompletionSource<bool> task = new TaskCompletionSource<bool>(); @@ -488,133 +480,5 @@ namespace Tizen.Network.WiFi } return task.Task; } - - internal Task ConnectAsync(WiFiAP ap) - { - TaskCompletionSource<bool> task = new TaskCompletionSource<bool>(); - IntPtr id; - lock (_callback_map) - { - id = (IntPtr)_requestId++; - _callback_map[id] = (error, key) => - { - Log.Debug(Globals.LogTag, "Connecting finished : " + (WiFiError)error); - if (error != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Error occurs during WiFi connecting, " + (WiFiError)error); - task.SetException(new InvalidOperationException("Error occurs during WiFi connecting, " + (WiFiError)error)); - } - task.SetResult(true); - lock (_callback_map) - { - _callback_map.Remove(key); - } - }; - } - IntPtr apHandle = ap.GetHandle(); - int ret = Interop.WiFi.Connect(GetHandle(), apHandle, _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); - } - return task.Task; - } - - internal Task DisconnectAsync(WiFiAP ap) - { - TaskCompletionSource<bool> task = new TaskCompletionSource<bool>(); - IntPtr id; - lock (_callback_map) - { - id = (IntPtr)_requestId++; - _callback_map[id] = (error, key) => - { - Log.Debug(Globals.LogTag, "Disconnecting finished"); - if (error != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Error occurs during WiFi disconnecting, " + (WiFiError)error); - task.SetException(new InvalidOperationException("Error occurs during WiFi disconnecting, " + (WiFiError)error)); - } - task.SetResult(true); - lock (_callback_map) - { - _callback_map.Remove(key); - } - }; - } - IntPtr apHandle = ap.GetHandle(); - int ret = Interop.WiFi.Disconnect(GetHandle(), apHandle, _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to disconnect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); - } - return task.Task; - } - - internal Task ConnectByWpsPbcAsync(WiFiAP ap) - { - TaskCompletionSource<bool> task = new TaskCompletionSource<bool>(); - IntPtr id; - lock (_callback_map) - { - id = (IntPtr)_requestId++; - _callback_map[id] = (error, key) => - { - Log.Debug(Globals.LogTag, "Connecting by WPS PBC finished"); - if (error != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Error occurs during WiFi connecting, " + (WiFiError)error); - task.SetException(new InvalidOperationException("Error occurs during WiFi connecting, " + (WiFiError)error)); - } - task.SetResult(true); - lock (_callback_map) - { - _callback_map.Remove(key); - } - }; - } - IntPtr apHandle = ap.GetHandle(); - int ret = Interop.WiFi.ConnectByWpsPbc(GetHandle(), apHandle, _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); - } - return task.Task; - } - - internal Task ConnectByWpsPinAsync(WiFiAP ap, string pin) - { - TaskCompletionSource<bool> task = new TaskCompletionSource<bool>(); - IntPtr id; - lock (_callback_map) - { - id = (IntPtr)_requestId++; - _callback_map[id] = (error, key) => - { - Log.Debug(Globals.LogTag, "Connecting by WPS PIN finished"); - if (error != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Error occurs during WiFi connecting, " + (WiFiError)error); - task.SetException(new InvalidOperationException("Error occurs during WiFi connecting, " + (WiFiError)error)); - } - task.SetResult(true); - lock (_callback_map) - { - _callback_map.Remove(key); - } - }; - } - IntPtr apHandle = ap.GetHandle(); - int ret = Interop.WiFi.ConnectByWpsPin(GetHandle(), apHandle, pin, _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret); - } - return task.Task; - } } } diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs index 94c6b05..d98ed81 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs @@ -23,8 +23,7 @@ using Tizen.Network.Connection; namespace Tizen.Network.WiFi { /// <summary> - /// A class for managing the Wi-Fi information. It allows applications to manager network information. - /// This class is not intended to create instance directly from applications. + /// A class for managing the Wi-Fi network information. /// </summary> public class WiFiNetwork : IDisposable { @@ -58,6 +57,7 @@ namespace Tizen.Network.WiFi return _essid; } } + /// <summary> /// The Basic Service Set Identifier(BSSID). /// </summary> @@ -75,6 +75,7 @@ namespace Tizen.Network.WiFi return Marshal.PtrToStringAnsi(strPtr); } } + /// <summary> /// The address informaiton for IPv4. /// </summary> @@ -85,6 +86,7 @@ namespace Tizen.Network.WiFi return _ipv4; } } + /// <summary> /// The address ainformation for IPv6. /// </summary> @@ -95,6 +97,7 @@ namespace Tizen.Network.WiFi return _ipv6; } } + /// <summary> /// The proxy address. /// </summary> @@ -120,6 +123,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The proxy type(IPv6). /// </summary> @@ -144,6 +148,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The frequency band(MHz). /// </summary> @@ -160,10 +165,11 @@ namespace Tizen.Network.WiFi return freq; } } + /// <summary> /// The Received signal strength indication(RSSI). /// </summary> - public int Rssi + public WiFiRssiLevel Rssi { get { @@ -173,11 +179,12 @@ namespace Tizen.Network.WiFi { Log.Error(Globals.LogTag, "Failed to get rssi, Error - " + (WiFiError)ret); } - return rssi; + return (WiFiRssiLevel)rssi; } } + /// <summary> - /// Rhe max speed (Mbps). + /// The max speed (Mbps). /// </summary> public int MaxSpeed { @@ -192,6 +199,7 @@ namespace Tizen.Network.WiFi return maxSpeed; } } + /// <summary> /// A property to check whether the access point is favorite or not. /// </summary> @@ -208,6 +216,7 @@ namespace Tizen.Network.WiFi return isFavorite; } } + /// <summary> /// A property to check whether the access point is passpoint or not. /// </summary> @@ -225,6 +234,7 @@ namespace Tizen.Network.WiFi return isPasspoint; } } + /// <summary> /// The connection state. /// </summary> @@ -262,6 +272,9 @@ namespace Tizen.Network.WiFi Dispose(false); } + /// <summary> + /// A method to destroy managed WiFiNetwork objects. + /// </summary> public void Dispose() { Dispose(true); diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs index e8cd8ed..2a5693c 100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs @@ -29,6 +29,7 @@ namespace Tizen.Network.WiFi handler(sender, e); } } + internal static void SafeInvoke<T>(this EventHandler<T> evt, object sender, T e) where T : EventArgs { var handler = evt; diff --git a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiSecurity.cs b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiSecurity.cs index 17a9821..cdd395e 100644..100755 --- a/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiSecurity.cs +++ b/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiSecurity.cs @@ -20,8 +20,7 @@ using Tizen.Network.Connection; namespace Tizen.Network.WiFi { /// <summary> - /// A class for managing the security information. It allows applications to manager security information. - /// This class is not intended to create instance directly from applications. + /// A class for managing the WiFi security information. /// </summary> public class WiFiSecurity : IDisposable { @@ -32,7 +31,7 @@ namespace Tizen.Network.WiFi /// <summary> /// The type of Wi-Fi security. /// </summary> - public WiFiSecureType SecurityType + public WiFiSecurityType SecurityType { get { @@ -43,7 +42,7 @@ namespace Tizen.Network.WiFi Log.Error(Globals.LogTag, "Failed to get security type, Error - " + (WiFiError)ret); WiFiErrorFactory.ThrowWiFiException(ret); } - return (WiFiSecureType)type; + return (WiFiSecurityType)type; } set { @@ -55,6 +54,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The type of Wi-Fi encryption /// </summary> @@ -81,6 +81,7 @@ namespace Tizen.Network.WiFi } } } + /// <summary> /// The EAP information /// </summary> @@ -109,6 +110,7 @@ namespace Tizen.Network.WiFi return required; } } + /// <summary> /// A property to check whether the Wi-Fi Protected Setup(WPS) is supported or not. /// </summary> @@ -138,6 +140,9 @@ namespace Tizen.Network.WiFi Dispose(false); } + /// <summary> + /// A method to destroy managed WiFiSecurity objects. + /// </summary> public void Dispose() { Dispose(true); diff --git a/packaging/csapi-network-wifi.spec b/packaging/csapi-network-wifi.spec index 02fa6b9..bac3d8e 100755 --- a/packaging/csapi-network-wifi.spec +++ b/packaging/csapi-network-wifi.spec @@ -1,6 +1,6 @@ Name: csapi-network-wifi Summary: Tizen Wi-Fi API for C# -Version: 1.0.6 +Version: 1.0.7 Release: 1 Group: Development/Libraries License: Apache-2.0 |