[WiFi][TCSACR-116] Add a new API WiFiAP.Update
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.WiFi / Tizen.Network.WiFi / WiFiNetwork.cs
index 896c497..d77be57 100755 (executable)
@@ -25,6 +25,7 @@ namespace Tizen.Network.WiFi
     /// <summary>
     /// A class for managing the Wi-Fi network information.
     /// </summary>
+    /// <since_tizen> 3 </since_tizen>
     public class WiFiNetwork
     {
         private Interop.WiFi.SafeWiFiAPHandle _apHandle;
@@ -33,9 +34,10 @@ namespace Tizen.Network.WiFi
         private string _essid;
 
         /// <summary>
-        /// The Extended Service Set Identifier(ESSID).
+        /// The Extended Service Set Identifier (ESSID).
         /// </summary>
-        /// <value>Essid of the WiFi.</value>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>ESSID of the Wi-Fi.</value>
         public string Essid
         {
             get
@@ -59,9 +61,10 @@ namespace Tizen.Network.WiFi
         }
 
         /// <summary>
-        /// The Basic Service Set Identifier(BSSID).
+        /// The Basic Service Set Identifier (BSSID).
         /// </summary>
-        /// <value>Bssid of the WiFi.</value>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>BSSID of the Wi-Fi.</value>
         public string Bssid
         {
             get
@@ -78,8 +81,9 @@ namespace Tizen.Network.WiFi
         }
 
         /// <summary>
-        /// The address informaiton for IPv4.
+        /// The address information for IPv4.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         /// <value>IP address information for IPv4 type.</value>
         public IAddressInformation IPv4Setting
         {
@@ -90,8 +94,9 @@ namespace Tizen.Network.WiFi
         }
 
         /// <summary>
-        /// The address ainformation for IPv6.
+        /// The address information for IPv6.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         /// <value>IP address information for IPv6 type.</value>
         public IAddressInformation IPv6Setting
         {
@@ -104,10 +109,11 @@ namespace Tizen.Network.WiFi
         /// <summary>
         /// The proxy address.
         /// </summary>
-        /// <value>Represents proxy address of WiFi.</value>
-        /// <exception cref="NotSupportedException">Thrown while setting this property when WiFi is not supported.</exception>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Represents the proxy address of the Wi-Fi.</value>
+        /// <exception cref="NotSupportedException">Thrown while setting this property when Wi-Fi is not supported.</exception>
         /// <exception cref="ArgumentException">Thrown while setting this property due to an invalid parameter.</exception>
-        /// <exception cref="InvalidOperationException">Thrown while setting this value due to invalid operation.</exception>
+        /// <exception cref="InvalidOperationException">Thrown while setting this value due to an invalid operation.</exception>
         public string ProxyAddress
         {
             get
@@ -133,12 +139,13 @@ namespace Tizen.Network.WiFi
         }
 
         /// <summary>
-        /// The proxy type(IPv6).
+        /// The proxy type (IPv6).
         /// </summary>
-        /// <value>Represents proxy type of WiFi.</value>
-        /// <exception cref="NotSupportedException">Thrown while setting this property when WiFi is not supported.</exception>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Represents the proxy type of the Wi-Fi.</value>
+        /// <exception cref="NotSupportedException">Thrown while setting this property when Wi-Fi is not supported.</exception>
         /// <exception cref="ArgumentException">Thrown while setting this property due to an invalid parameter.</exception>
-        /// <exception cref="InvalidOperationException">Thrown while setting this value due to invalid operation.</exception>
+        /// <exception cref="InvalidOperationException">Thrown while setting this value due to an invalid operation.</exception>
         public WiFiProxyType ProxyType
         {
             get
@@ -163,8 +170,9 @@ namespace Tizen.Network.WiFi
         }
 
         /// <summary>
-        /// The frequency band(MHz).
+        /// The frequency band (MHz).
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         /// <value>Represents the frequency band value.</value>
         public int Frequency
         {
@@ -181,10 +189,11 @@ namespace Tizen.Network.WiFi
         }
 
         /// <summary>
-        /// The Received signal strength indication(RSSI).
+        /// The received signal strength indicator (RSSI).
         /// </summary>
-        /// <value>Represents Rssi level of WiFi.</value>
-        public WiFiRssiLevel Rssi
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Represents RSSI of Wi-Fi (dbm).</value>
+        public int Rssi
         {
             get
             {
@@ -194,6 +203,27 @@ namespace Tizen.Network.WiFi
                 {
                     Log.Error(Globals.LogTag, "Failed to get rssi, Error - " + (WiFiError)ret);
                 }
+                return rssi;
+            }
+        }
+
+        /// <summary>
+        /// The Received signal strength indication(RSSI).
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        /// <value>Represents Rssi level of WiFi.</value>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="NotSupportedException">Thrown while setting this property when WiFi is not supported.</exception>
+        public WiFiRssiLevel RssiLevel
+        {
+            get
+            {
+                int rssi;
+                int ret = Interop.WiFi.AP.GetRssiLevel(_apHandle, out rssi);
+                if (ret != (int)WiFiError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get rssi level, Error - " + (WiFiError)ret);
+                }
                 return (WiFiRssiLevel)rssi;
             }
         }
@@ -201,7 +231,8 @@ namespace Tizen.Network.WiFi
         /// <summary>
         /// The max speed (Mbps).
         /// </summary>
-        /// <value>Represents max speed value.</value>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Represents the max speed value.</value>
         public int MaxSpeed
         {
             get
@@ -217,9 +248,10 @@ namespace Tizen.Network.WiFi
         }
 
         /// <summary>
-        /// A property to check whether the access point is favorite or not.
+        /// A property to check whether the access point is favorite or not.
         /// </summary>
-        /// <value>Boolean value to check if the access point is favorite or not.</value>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Boolean value to check if the access point is a favorite or not.</value>
         public bool IsFavorite
         {
             get
@@ -235,9 +267,10 @@ namespace Tizen.Network.WiFi
         }
 
         /// <summary>
-        /// A property to check whether the access point is passpoint or not.
+        /// A property to check whether the access point is passpoint or not.
         /// </summary>
-        /// <value>Boolean value to check if the access point is passpoint or not.</value>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Boolean value to check if the access point is a passpoint or not.</value>
         public bool IsPasspoint
         {
             get
@@ -256,7 +289,8 @@ namespace Tizen.Network.WiFi
         /// <summary>
         /// The connection state.
         /// </summary>
-        /// <value>Represents the connection state of WiFi.</value>
+        /// <since_tizen> 3 </since_tizen>
+        /// <value>Represents the connection state of the Wi-Fi.</value>
         public WiFiConnectionState ConnectionState
         {
             get
@@ -271,6 +305,43 @@ namespace Tizen.Network.WiFi
             }
         }
 
+        /// <summary>
+        /// Gets all IPv6 addresses of the access point.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
+        /// <returns>A list of IPv6 addresses of the access point.</returns>
+        /// <feature>http://tizen.org/feature/network.wifi</feature>
+        /// <exception cref="NotSupportedException">Thrown when the Wi-Fi is not supported.</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 IEnumerable<System.Net.IPAddress> GetAllIPv6Addresses()
+        {
+            Log.Debug(Globals.LogTag, "GetAllIPv6Addresses");
+            List<System.Net.IPAddress> ipList = new List<System.Net.IPAddress>();
+            Interop.WiFi.HandleCallback callback = (IntPtr ipv6Address, IntPtr userData) =>
+            {
+                if (ipv6Address != IntPtr.Zero)
+                {
+                    string ipv6 = Marshal.PtrToStringAnsi(ipv6Address);
+                    if (ipv6.Length == 0)
+                        ipList.Add(System.Net.IPAddress.Parse("::"));
+                    else
+                        ipList.Add(System.Net.IPAddress.Parse(ipv6));
+                    return true;
+                }
+                return false;
+            };
+
+            int ret = Interop.WiFi.AP.GetAllIPv6Addresses(_apHandle, callback, IntPtr.Zero);
+            if (ret != (int)WiFiError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to get all IPv6 addresses, Error - " + (WiFiError)ret);
+                WiFiErrorFactory.ThrowWiFiException(ret, _apHandle.DangerousGetHandle());
+            }
+
+            return ipList;
+        }
+
         internal WiFiNetwork(Interop.WiFi.SafeWiFiAPHandle apHandle)
         {
             _apHandle = apHandle;