Add .NET Wi-Fi Guide 67/134067/2
authorEditor Lionbridge <TizenEditor.SEL@lionbridge.com>
Wed, 14 Jun 2017 10:53:48 +0000 (13:53 +0300)
committerEditor Lionbridge <TizenEditor.SEL@lionbridge.com>
Tue, 20 Jun 2017 11:19:08 +0000 (14:19 +0300)
Note that since the general structure of the .NET content is still
open, the new topic has not been added to any index files, and
there is no parent topic introducing the .NET guides.

Also, since there is no .NET AR content in git, all AR links lead
directly to TD.

PS2: Profile icon path fixed

Change-Id: Iee870e25ff1da8fce10dd4e453e578900d89b2f6

org.tizen.guides/html/dotnet/wifi.htm [new file with mode: 0644]

diff --git a/org.tizen.guides/html/dotnet/wifi.htm b/org.tizen.guides/html/dotnet/wifi.htm
new file mode 100644 (file)
index 0000000..265d315
--- /dev/null
@@ -0,0 +1,306 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+       <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+       <meta http-equiv="X-UA-Compatible" content="IE=9" />
+       <link rel="stylesheet" type="text/css" href="../css/styles.css" />
+       <link rel="stylesheet" type="text/css" href="../css/snippet.css" />
+       <script type="text/javascript" src="../scripts/snippet.js"></script>
+       <script type="text/javascript" src="../scripts/jquery.util.js" charset="utf-8"></script>
+       <script type="text/javascript" src="../scripts/common.js" charset="utf-8"></script>
+       <script type="text/javascript" src="../scripts/core.js" charset="utf-8"></script>
+       <script type="text/javascript" src="../scripts/search.js" charset="utf-8"></script>
+
+       <title>Wi-Fi</title>
+</head>
+
+<body onload="prettyPrint()" style="overflow: auto;">
+
+<div id="toc-navigation">
+       <div id="profile">
+               <p><img alt="Mobile C#" src="../images/mobile_s_cs.png"/> <img alt="TV C#" src="../images/tv_s_cs.png"/></p>
+       </div>
+       <div id="toc_border"><div id="toc">
+               <p class="toc-title">Dependencies</p>
+               <ul class="toc">
+                       <li>Tizen 4.0 and Higher for Mobile and TV</li>
+               </ul>
+               <p class="toc-title">Content</p>
+               <ul class="toc">
+                       <li><a href="#prerequisites">Prerequisites</a></li>
+                       <li><a href="#managing_events">Managing Events</a></li>
+                       <li><a href="#activating_wifi_device">Activating a Wi-Fi Device</a></li>
+                       <li><a href="#accesspoint_scan">Scanning for Access Points</a></li>
+                       <li><a href="#accesspoint_connect">Connecting to a Specific Access Point</a></li>
+                       <li><a href="#deactivating_wifi_device">Deactivating a Wi-Fi Device</a></li>
+
+               </ul>
+               <p class="toc-title">Related Info</p>
+               <ul class="toc">
+                       <li><a href="https://developer.tizen.org/dev-guide/csapi/namespaceTizen_1_1Network_1_1WiFi.html">Tizen.Network.WiFi Namespace</a></li>
+               </ul>
+       </div></div>
+</div>
+
+<div id="container"><div id="contents"><div class="content">
+
+<h1>Wi-Fi</h1>
+
+   <p>You can connect to a Wireless Local Area Network (WLAN) and transfer data over the network. The Wi-Fi Manager enables your application to activate and deactivate a local Wi-Fi device, and to scan for available access points.</p>
+   <p>The main features of the Tizen.Network.WiFi namespace include:</p>
+   <ul>
+   <li>Wi-Fi device management
+      <p>You can use the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Network_1_1WiFi_1_1WiFiManager.html">Tizen.Network.WiFi.WiFiManager</a> class to control aspects of your application's wireless connection. For example, you can <a href="#activating_wifi_device">activate</a> or <a href="#deactivating_wifi_device">deactivate</a> Wi-Fi, <a href="#managing_events">monitor connection state changes</a>, and <a href="#accesspoint_scan">scan for available access points</a>.</p>
+   </li>
+   <li>Access point management
+
+      <p>With the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Network_1_1WiFi_1_1WiFiAP.html">Tizen.Network.WiFi.WiFiAP</a> class, you can <a href="#accesspoint_connect">connect to a specific access point</a> and manage the Wi-Fi access point and security information:</p>
+         <ul>
+               <li>Access point details are instances of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Network_1_1WiFi_1_1WiFiNetwork.html">Tizen.Network.WiFi.WiFiNetwork</a> class, which allows you to retrieve various access point information, such as the SSID, frequency band and maximum speed of the access point.</li>
+               <li>Access point security details are instances of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Network_1_1WiFi_1_1WiFiSecurity.html">Tizen.Network.WiFi.WiFiSecurity</a> class, which allows you to retrieve security information, such as the used encryption type and whether WPS is supported.
+               <p>You can also obtain EAP information, which is encapsulated in the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Network_1_1WiFi_1_1WiFiEap.html">Tizen.Network.WiFi.WiFiEap</a> class.</p>
+
+               <p align="center" class="Table"><strong>Table: Access point EAP information</strong></p>
+               <table>
+<tbody>
+<tr>
+ <th>Information</th> <th>Description</th>
+</tr>
+ <tr>
+ <td>Authentication type</td> <td>Wi-Fi EAP phase2 authentication type</td>
+ </tr>
+ <tr>
+ <td>EAP type</td> <td>Wi-Fi EAP type</td>
+ </tr>
+ <tr>
+ <td>CA certificate</td> <td>EAP CA certificate (valid only if the EAP type is TLS)</td>
+ </tr>
+ <tr>
+ <td>Client certificate</td> <td>EAP client certificate (valid only if the EAP type is TLS)</td>
+ </tr>
+ <tr>
+ <td>Passphrase</td> <td>EAP passphrase (valid if the EAP type is PEAP or TTLS)</td>
+ </tr>
+ <tr>
+ <td>Private key file</td> <td>EAP private key file (valid only if the EAP type is TLS)</td>
+ </tr>
+</tbody>
+</table>
+
+               </li>
+         </ul>
+         <p>To create a <code>Tizen.Network.WiFi.WiFiAP</code> instance, use its constructor with the ESSID, or retrieve the instance from the <code>GetFoundAPs()</code> method of the <code>Tizen.Network.WiFi.WiFiManager</code> class.</p>
+   </li>
+   </ul>
+<p>The application uses the infrastructure mode to connect to a wireless local area network (WLAN). The infrastructure mode requires a wireless access point. To connect to a WLAN, the application client must be configured to use the same service set identifier (SSID) as the access point.</p>
+
+<div class="note">
+<strong>Note</strong>
+You can test Wi-Fi functionality on a target device only. The emulator does not support this feature.
+</div>
+
+<h2 id="prerequisites">Prerequisites</h2>
+   <p>To enable your application to use the Wi-Fi functionality:</p>
+   <ol>
+      <li>To use the <a href="https://developer.tizen.org/dev-guide/csapi/namespaceTizen_1_1Network_1_1WiFi.html">Tizen.Network.WiFi</a>
+         namespace, the application has to request permission by adding the following privileges to the <code>tizen-manifest.xml</code> file:
+<pre class="prettyprint">
+&lt;privileges&gt;
+   &lt;privilege&gt;http://tizen.org/privilege/network.get&lt;/privilege&gt;
+   &lt;privilege&gt;http://tizen.org/privilege/network.set&lt;/privilege&gt;
+   &lt;privilege&gt;http://tizen.org/privilege/network.profile&lt;/privilege&gt;
+&lt;/privileges&gt;
+</pre>
+      </li>
+         <li>To use the methods and properties of the <code>Tizen.Network.WiFi</code> namespace, include it in your application:
+<pre class="prettyprint">
+using Tizen.Network.WiFi;
+</pre>
+      </li>
+   </ol>
+
+
+<h2 id="managing_events">Managing Events</h2>
+   <p>To manage events related to Wi-Fi operations, use event handlers registered to the following events of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Network_1_1WiFi_1_1WiFiManager.html">Tizen.Network.WiFi.WiFiManager</a> class:</p>
+
+         <ul>
+            <li><code>DeviceStateChanged</code> is called when the device state changes (Wi-Fi is activated or deactivated).</li>
+                <li><code>ConnectionStateChanged</code> is called when the device access point connection state changes (connection to an access point is formed or lost).</li>
+                <li><code>RssiLevelChanged</code> is called when the RSSI of the connected Wi-Fi changes</li>
+                <li><code>BackgroundScanFinished</code> is called when a background scan has finished.</li>
+      </ul>
+         <p>To manage device and connection state events:</p>
+       <ol>
+      <li>Define event handlers:
+<pre class="prettyprint">
+public static void EventHandlerDeviceStateChanged(object sender, EventArgs e)
+{
+    Console.WriteLine("Device state: " + e.State);
+}
+public static void EventHandlerConnectionStateChanged(object sender, EventArgs e)
+{
+    Console.WriteLine("WiFi connection state: " + e.State);
+}
+</pre>
+      </li>
+         <li>Register the event handlers for the <code>DeviceStateChanged</code> and <code>ConnectionStateChanged</code> events of the <code>Tizen.Network.WiFi.WiFiManager</code> class:
+         <pre class="prettyprint">
+WiFiManager.DeviceStateChanged += EventHandlerDeviceStateChanged;
+
+WiFiManager.ConnectionStateChanged += EventHandlerConnectionStateChanged;
+</pre>
+      </li>
+         <li>When they are no longer needed, deregister the event handlers:
+<pre class="prettyprint">
+WiFiManager.DeviceStateChanged -= EventHandlerDeviceStateChanged;
+
+WiFiManager.ConnectionStateChanged -= EventHandlerConnectionStateChanged;
+</pre>
+      </li>
+   </ol>
+
+<h2 id="activating_wifi_device">Activating a Wi-Fi Device</h2>
+   <p>To activate a Wi-Fi local device and check the connection state:</p>
+   <ol>
+      <li>Activate a Wi-Fi device using the asynchronous <code>ActivateAsync()</code> method of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Network_1_1WiFi_1_1WiFiManager.html">Tizen.Network.WiFi.WiFiManager</a> class:
+<pre class="prettyprint">
+try
+{
+    await WiFiManager.ActivateAsync();
+</pre></li>
+         <li>Check whether the connection has been made by using the <code>IsActive</code> property of the <code>Tizen.Network.WiFi.WiFiManager</code> class:
+<pre class="prettyprint">
+    if (WiFiManager.IsActive)
+    {
+        Console.WriteLine("WiFi is activated");
+    }
+}
+catch (Exception e)
+{
+    Console.WriteLine("Exception occurred" + e.ToString());
+}
+</pre>
+      </li>
+   </ol>
+
+<h2 id="accesspoint_scan">Scanning for Access Points</h2>
+   <p>To scan nearby access points and get their details:</p>
+   <ol>
+      <li>Scan nearby access points using the <code>ScanAsync()</code> method of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Network_1_1WiFi_1_1WiFiManager.html">Tizen.Network.WiFi.WiFiManager</a> class:
+<pre class="prettyprint">
+try
+{
+    await WiFiManager.ScanAsync();
+</pre>
+</li>
+<li>Retrieve the scan results (the found access points) with the <code>GetFoundAPs()</code> method of the <code>Tizen.Network.WiFi.WiFiManager</code> class.
+<p>In this example, the application displays the name and connection state of each access point it finds. You can also get other information, such as the used frequency or the maximum speed the access point supports.</p>
+<pre class="prettyprint">
+    var apList = WiFiManager.GetFoundAPs();
+    foreach (var item in apList)
+    {
+        Console.WriteLine("AP name: " + item.NetworkInformation.Essid);
+        Console.WriteLine("Connection state: " + item.NetworkInformation.ConnectionState);
+    }
+}
+catch (Exception e)
+{
+    Console.WriteLine("Exception occurred" + e.ToString());
+}
+</pre>
+      </li>
+   </ol>
+
+<h2 id="accesspoint_connect">Connecting to a Specific Access Point</h2>
+   <p>To make a connection using a specific access point:</p>
+   <ol>
+      <li>Scan nearby access points using the <code>ScanAsync()</code> method of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Network_1_1WiFi_1_1WiFiManager.html">Tizen.Network.WiFi.WiFiManager</a> class, and select the one you want:
+<pre class="prettyprint">
+try
+{
+    string ap = "APName";
+    WiFiAP connectAP;
+    await WiFiManager.ScanAsync();
+    var apList = WiFiManager.GetFoundAPs();
+    foreach (var item in apList)
+    {
+        if (item.NetworkInformation.Essid == ap)
+        {
+            connectAP = item;
+            break;
+        }
+    }
+}
+catch (Exception e)
+{
+     Console.WriteLine("Exception occurred" + e.ToString());
+}
+</pre>
+      </li>
+         <li>Establish a connection with the selected access point:
+<pre class="prettyprint">
+try
+{
+    await connectAP.ConnectAsync();
+}
+catch (Exception e)
+{
+    Console.WriteLine("Exception occurred" + e.ToString());
+}
+</pre>
+      </li>
+         <li>Check whether the connection has been established successfully:
+<pre class="prettyprint">
+try
+{
+    WiFiAP connect = WiFiManager.GetConnectedAP();
+    if (connect.NetworkInformation.Essid == ap)
+    {
+        Console.WriteLine("Connection is successful");
+    }
+}
+catch (Exception e)
+{
+    Console.WriteLine("Exception occurred" + e.ToString());
+}
+</pre>
+      </li>
+   </ol>
+
+
+<h2 id="deactivating_wifi_device">Deactivating a Wi-Fi Device</h2>
+   <p>To deactivate Wi-Fi when it is no longer needed (or the application is exiting), use the asynchronous <code>DeactivateAsync()</code> method of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Network_1_1WiFi_1_1WiFiManager.html">Tizen.Network.WiFi.WiFiManager</a> class:</p>
+<pre class="prettyprint">
+try
+{
+    await WiFiManager.DeactivateAsync();
+}
+catch (Exception e)
+{
+    Console.WriteLine("Exception occurred" + e.ToString());
+}
+</pre>
+
+<script type="text/javascript" src="../scripts/jquery.zclip.min.js"></script>
+<script type="text/javascript" src="../scripts/showhide.js"></script>
+</div></div></div>
+
+<a class="top sms" href="#"><img src="../images/btn_top.gif" alt="Go to top" /></a>
+
+<div id="footer">
+<p class="footer">Except as noted, this content - excluding the Code Examples - is licensed under <a href="http://creativecommons.org/licenses/by/3.0/legalcode" target="_blank">Creative Commons Attribution 3.0</a> and all of the Code Examples contained herein are licensed under <a href="https://www.tizen.org/bsd-3-clause-license" target="_blank">BSD-3-Clause</a>.<br/>For details, see the <a href="https://www.tizen.org/content-license" target="_blank">Content License</a>.</p>
+</div>
+
+<script type="text/javascript">
+var _gaq = _gaq || [];
+_gaq.push(['_setAccount', 'UA-25976949-1']);
+_gaq.push(['_trackPageview']);
+(function() {
+var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+})();
+</script>
+
+</body>
+</html>