[Connection][WiFi] Use TizenSynchronizationContext.Post for asynchronous methods...
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.WiFi / Tizen.Network.WiFi / WiFiAP.cs
index c10ca57..71ec452 100755 (executable)
  */
 
 using System;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+using Tizen.Applications;
 
 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>
+    /// <since_tizen> 3 </since_tizen>
     public class WiFiAP : IDisposable
     {
         private IntPtr _apHandle = IntPtr.Zero;
+        private Dictionary<IntPtr, Interop.WiFi.VoidCallback> _callback_map = new Dictionary<IntPtr, Interop.WiFi.VoidCallback>();
+        private static Dictionary<IntPtr, Interop.WiFi.VoidCallback> s_callbackMap = new Dictionary<IntPtr, Interop.WiFi.VoidCallback>();
+        private int _requestId = 0;
+        private static int s_requestId = 0;
         private WiFiNetwork _network;
         private WiFiSecurity _security;
-        private bool disposed = false;
+        private bool _disposed = false;
+
+        private TizenSynchronizationContext context = new TizenSynchronizationContext();
+        private static TizenSynchronizationContext s_context = new TizenSynchronizationContext();
 
         /// <summary>
-        /// The network information of the access point(AP).
+        /// The network information of the access point (AP).
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>The WiFiNetwork instance containing the network information of the AP.</value>
         public WiFiNetwork NetworkInformation
         {
             get
@@ -38,9 +51,12 @@ namespace Tizen.Network.WiFi
                 return _network;
             }
         }
+
         /// <summary>
-        /// The security information of the access point(AP).
+        /// The security information of the access point (AP).
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>The WiFiSecurity instance containing security information of the AP.</value>
         public WiFiSecurity SecurityInformation
         {
             get
@@ -55,32 +71,59 @@ 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>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="essid">The Extended Service Set Identifier of the access point.</param>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="ArgumentNullException">Thrown when the ESSID is passed as null.</exception>
+        /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when the system is out of memory.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
         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="hidden">The value to set hidden AP</param>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="essid">The Extended Service Set Identifier of the access point.</param>
+        /// <param name="hidden">The value to set a hidden AP.</param>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="ArgumentNullException">Thrown when the ESSID is passed as null.</exception>
+        /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when the system is out of memory.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
         public WiFiAP(string essid, bool hidden)
         {
             createHandle(essid, hidden);
             Initialize();
         }
 
+        /// <summary>
+        /// Destroy the WiFiAP object
+        /// </summary>
         ~WiFiAP()
         {
             Dispose(false);
         }
 
+        /// <summary>
+        /// A method to destroy the managed WiFiAP objects.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public void Dispose()
         {
             Dispose(true);
@@ -89,60 +132,461 @@ namespace Tizen.Network.WiFi
 
         private void Dispose(bool disposing)
         {
-            if (disposed)
+            if (_disposed)
                 return;
 
             if (disposing)
             {
-                _network.Dispose();
-                _security.Dispose();
                 Interop.WiFi.AP.Destroy(_apHandle);
                 _apHandle = IntPtr.Zero;
             }
-            disposed = true;
+            _disposed = true;
         }
 
         private void createHandle(string id, bool hidden)
         {
             int ret = -1;
+            if (id == null)
+            {
+                throw new ArgumentNullException("Essid is null");
+            }
+
             if (hidden)
             {
-                ret = Interop.WiFi.AP.CreateHiddenAP(WiFiManagerImpl.Instance.GetHandle(), id, out _apHandle);
+                ret = Interop.WiFi.AP.CreateHiddenAP(WiFiManagerImpl.Instance.GetSafeHandle(), id, out _apHandle);
             }
+
             else
             {
-                ret = Interop.WiFi.AP.Create(WiFiManagerImpl.Instance.GetHandle(), id, out _apHandle);
+                ret = Interop.WiFi.AP.Create(WiFiManagerImpl.Instance.GetSafeHandle(), id, out _apHandle);
             }
 
             if (ret != (int)WiFiError.None)
             {
                 Log.Error(Globals.LogTag, "Failed to create handle, Error - " + (WiFiError)ret);
-                WiFiErrorFactory.ThrowWiFiException(ret);
+                WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle());
             }
         }
 
         private void Initialize()
         {
-            _network = new WiFiNetwork(_apHandle);
-            _security = new WiFiSecurity(_apHandle);
+            Interop.WiFi.SafeWiFiAPHandle apHandle = new Interop.WiFi.SafeWiFiAPHandle(_apHandle);
+            _network = new WiFiNetwork(apHandle);
+            _security = new WiFiSecurity(apHandle);
         }
 
         /// <summary>
         /// Refreshes the access point information.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="ObjectDisposedException">Thrown when the object instance is disposed or released.</exception>
+        /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
         public void Refresh()
         {
+            Log.Debug(Globals.LogTag, "Refresh");
+            if (_disposed)
+            {
+                throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)");
+            }
             int ret = Interop.WiFi.AP.Refresh(_apHandle);
             if (ret != (int)WiFiError.None)
             {
                 Log.Error(Globals.LogTag, "Failed to refresh ap handle, Error - " + (WiFiError)ret);
-                WiFiErrorFactory.ThrowWiFiException(ret, _apHandle);
+                WiFiErrorFactory.ThrowWiFiException(ret, _apHandle, "http://tizen.org/privilege/network.get");
+            }
+        }
+
+        /// <summary>
+        /// Connects the access point asynchronously.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns> A task indicating whether the connect method is done or not.</returns>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <privilege>http://tizen.org/privilege/network.set</privilege>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="ObjectDisposedException">Thrown when the object instance is disposed or released.</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when the system is out of memory.</exception>
+        /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
+        public Task ConnectAsync()
+        {
+            Log.Info(Globals.LogTag, "ConnectAsync");
+            if (_disposed)
+            {
+                throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)");
+            }
+            TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+            IntPtr id;
+            lock (_callback_map)
+            {
+                id = (IntPtr)_requestId++;
+                _callback_map[id] = (error, key) =>
+                {
+                    Log.Info(Globals.LogTag, "ConnectAsync done " + (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));
+                    }
+                    else
+                    {
+                        task.SetResult(true);
+                    }
+                    lock (_callback_map)
+                    {
+                        _callback_map.Remove(key);
+                    }
+                };
+            }
+
+            context.Post((x) =>
+            {
+                Log.Info(Globals.LogTag, "Interop.WiFi.Connect");
+                int ret = Interop.WiFi.Connect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
+                if (ret != (int)WiFiError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
+                    WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+                }
+            }, null);
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Connects the access point with the WPS asynchronously.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="info">A WpsInfo instance which is type of WpsPbcInfo or WpsPinInfo.</param>
+        /// <returns>A task indicating whether the ConnectWps method is done or not.</returns>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="ObjectDisposedException">Thrown when the object instance is disposed or released.</exception>
+        /// <exception cref="ArgumentNullException">Thrown when the WpsPinInfo object is constructed with a null pin.</exception>
+        /// <exception cref="ArgumentOutOfRangeException">Thrown when the WpsPinInfo object is constructed with a pin which is an empty string or more than 7 characters.</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when the system is out of memory.</exception>
+        /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
+        public Task ConnectWpsAsync(WpsInfo info)
+        {
+            Log.Info(Globals.LogTag, "ConnectWpsAsync");
+            if (_disposed)
+            {
+                throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)");
+            }
+            TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+            IntPtr id;
+            lock (_callback_map)
+            {
+                id = (IntPtr)_requestId++;
+                _callback_map[id] = (error, key) =>
+                {
+                    Log.Info(Globals.LogTag, "ConnectWpsAsync done");
+                    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));
+                    }
+                    else
+                    {
+                        task.SetResult(true);
+                    }
+                    lock (_callback_map)
+                    {
+                        _callback_map.Remove(key);
+                    }
+                };
+            }
+
+            context.Post((x) =>
+            {
+                int ret = -1;
+                if (info.GetType() == typeof(WpsPbcInfo))
+                {
+                    Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPb");
+                    ret = Interop.WiFi.ConnectByWpsPbc(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
+                }
+                else if (info.GetType() == typeof(WpsPinInfo))
+                {
+                    WpsPinInfo pinInfo = (WpsPinInfo)info;
+                    if (pinInfo.GetWpsPin() == null)
+                    {
+                        throw new ArgumentNullException("Wps pin should not be null");
+                    }
+
+                    if (pinInfo.GetWpsPin().Length == 0 || pinInfo.GetWpsPin().Length > 8)
+                    {
+                        throw new ArgumentOutOfRangeException("Wps pin should not be empty or more than 7 characters");
+                    }
+
+                    Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPin");
+                    ret = Interop.WiFi.ConnectByWpsPin(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, pinInfo.GetWpsPin(), _callback_map[id], id);
+                }
+
+                if (ret != (int)WiFiError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
+                    WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+                }
+            }, null);
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Connects the access point with WPS without SSID asynchronously.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="info">A WpsInfo instance which is of type WpsPbcInfo or WpsPinInfo.</param>
+        /// <returns>A task which contains Connected access point information.</returns>
+        /// <remarks>
+        /// If WpsPinInfo is used, its object has to be constructed with a pin which must be 4 or 8 characters long.
+        /// </remarks>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <privilege>http://tizen.org/privilege/network.set</privilege>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+        /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="ArgumentNullException">Thrown when the WpsPinInfo object is constructed with a null pin.</exception>
+        /// <exception cref="ArgumentOutOfRangeException">Thrown when the WpsPinInfo object is constructed with a pin which is not of 4 or 8 characters long.</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when the system is out of memory.</exception>
+        /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
+        public static Task<WiFiAP> ConnectWpsWithoutSsidAsync(WpsInfo info)
+        {
+            Log.Info(Globals.LogTag, "ConnectWpsWithoutSsidAsync");
+            TaskCompletionSource<WiFiAP> task = new TaskCompletionSource<WiFiAP>();
+            IntPtr id;
+            lock (s_callbackMap)
+            {
+                id = (IntPtr)s_requestId++;
+                s_callbackMap[id] = (error, key) =>
+                {
+                    Log.Info(Globals.LogTag, "ConnectWpsWithoutSsidAsync done");
+                    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));
+                    }
+                    else
+                    {
+                        WiFiAP ap = WiFiManagerImpl.Instance.GetConnectedAP();
+                        task.SetResult(ap);
+                    }
+                    lock (s_callbackMap)
+                    {
+                        s_callbackMap.Remove(key);
+                    }
+                };
+            }
+
+            s_context.Post((x) =>
+            {
+                int ret = -1;
+                if (info.GetType() == typeof(WpsPbcInfo))
+                {
+                    Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPbcWithoutSsid");
+                    ret = Interop.WiFi.ConnectByWpsPbcWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), s_callbackMap[id], id);
+                }
+                else if (info.GetType() == typeof(WpsPinInfo))
+                {
+                    WpsPinInfo pinInfo = (WpsPinInfo)info;
+                    if (pinInfo.GetWpsPin() == null)
+                    {
+                        throw new ArgumentNullException("Wps pin should not be null");
+                    }
+
+                    if (pinInfo.GetWpsPin().Length != 4 && pinInfo.GetWpsPin().Length != 8)
+                    {
+                        throw new ArgumentOutOfRangeException("Wps pin should be of 4 or 8 characters long");
+                    }
+
+                    Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPinWithoutSsid");
+                    ret = Interop.WiFi.ConnectByWpsPinWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), pinInfo.GetWpsPin(), s_callbackMap[id], id);
+                }
+
+                if (ret != (int)WiFiError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret);
+                    WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle());
+                }
+            }, null);
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Disconnects the access point asynchronously.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns> A task indicating whether the disconnect method is done or not.</returns>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <privilege>http://tizen.org/privilege/network.set</privilege>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="ObjectDisposedException">Thrown when the object instance is disposed or released.</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when the system is out of memory.</exception>
+        /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
+        public Task DisconnectAsync()
+        {
+            Log.Debug(Globals.LogTag, "DisconnectAsync");
+            if (_disposed)
+            {
+                throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)");
+            }
+            TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+            IntPtr id;
+            lock (_callback_map)
+            {
+                id = (IntPtr)_requestId++;
+                _callback_map[id] = (error, key) =>
+                {
+                    Log.Info(Globals.LogTag, "DisconnectAsync done");
+                    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));
+                    }
+                    else
+                    {
+                        task.SetResult(true);
+                    }
+                    lock (_callback_map)
+                    {
+                        _callback_map.Remove(key);
+                    }
+                };
+            }
+
+            context.Post((x) =>
+            {
+                Log.Info(Globals.LogTag, "Interop.WiFi.Disconnect");
+                int ret = Interop.WiFi.Disconnect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id);
+                if (ret != (int)WiFiError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to disconnect wifi, Error - " + (WiFiError)ret);
+                    WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+                }
+            }, null);
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Deletes the information of a stored access point and disconnects it when the AP is connected.
+        /// If an AP is connected, then the connection information will be stored. This information is used when a connection to that AP is established automatically.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="ObjectDisposedException">Thrown when the object instance is disposed or released.</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when the system is out of memory.</exception>
+        /// <exception cref="ArgumentException">Thrown when the method failed due to an invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
+        public void ForgetAP()
+        {
+            Log.Debug(Globals.LogTag, "ForgetAP");
+            if (_disposed)
+            {
+                throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)");
+            }
+            int ret = Interop.WiFi.RemoveAP(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle);
+            if (ret != (int)WiFiError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to forget AP, Error - " + (WiFiError)ret);
+                WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+            }
+        }
+
+        /// <summary>
+        /// Update the information of a stored access point.
+        /// When a AP information is changed, the change will not be applied until this method is called.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <privilege>http://tizen.org/privilege/network.profile</privilege>
+        /// <privilege>http://tizen.org/privilege/network.get</privilege>
+        /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
+        /// <exception cref="ObjectDisposedException">Thrown when the object instance is disposed or released.</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when the system is out of memory.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the method failed due to an invalid operation.</exception>
+        public void Update()
+        {
+            Log.Debug(Globals.LogTag, "Update");
+            if (_disposed)
+            {
+                throw new ObjectDisposedException("Invalid AP instance (Object may have been disposed or released)");
             }
+            int ret = Interop.WiFi.UpdateAP(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle);
+            if (ret != (int)WiFiError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to update AP, Error - " + (WiFiError)ret);
+                WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle);
+            }
+        }
+   }
+
+    /// <summary>
+    /// An abstract class which is used to represent the WPS information of the access point.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public abstract class WpsInfo
+    {
+    }
+
+    /// <summary>
+    /// A class which is used to represent WPS PBC information of the access point.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class WpsPbcInfo : WpsInfo
+    {
+    }
+
+    /// <summary>
+    /// A class which is used to represent WPS PIN information of the access point.
+    /// </summary>
+    /// <since_tizen> 3 </since_tizen>
+    public class WpsPinInfo : WpsInfo
+    {
+        private string _pin;
+
+        private WpsPinInfo()
+        {
+        }
+
+        /// <summary>
+        /// A public constructor which instantiates WpsPinInfo class with the given pin.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <param name="pin">WPS Pin of the access point.</param>
+        /// <remarks>
+        /// Pin should not be null or empty. It should be of less than 8 characters.
+        /// </remarks>
+        public WpsPinInfo(string pin)
+        {
+            _pin = pin;
         }
 
-        internal IntPtr GetHandle()
+        internal string GetWpsPin()
         {
-            return _apHandle;
+            return _pin;
         }
     }
 }