[Web device API] add additional tutorial for NFC HCE.
authorjk.pu <jk.pu@samsung.com>
Tue, 1 Dec 2015 10:40:22 +0000 (19:40 +0900)
committerjk.pu <jk.pu@samsung.com>
Tue, 1 Dec 2015 12:10:50 +0000 (21:10 +0900)
Change-Id: I463aa1d0efa962de4814ced38232446db63c598c
Signed-off-by: jk.pu <jk.pu@samsung.com>
org.tizen.guides/html/web/tizen/communication/nfc_w.htm
org.tizen.tutorials/html/web/tizen/communication/nfc_tutorial_w.htm

index d2873d3..4e9d877 100644 (file)
@@ -78,7 +78,9 @@
    </tbody>
   </table>
   <p>You can launch NFC applications based on the NDEF message content using the <a href="../application/application_w.htm#controls">application control</a> functionalities. For example, if the application control with the <span style="font-family: Courier New,Courier,monospace">http://tizen.org/appcontrol/operation/nfc/wellknown</span> operation is defined in the <span style="font-family: Courier New,Courier,monospace">config.xml</span> file and an NFC-enabled device reads an NFC tag or receives an NDEF message whose first NDEF record has a record type (<span style="font-family: Courier New,Courier,monospace">tnf</span> value) set as <span style="font-family: Courier New,Courier,monospace">NFC_RECORD_TNF_WELL_KNOWN</span>, the NFC application is launched.</p>
-<p>NFC applications can also be launched by the transaction of the card emulation functionality. NFC devices can communicate with point of sales (POS) terminals using the card emulation functionality to, for example, make a payment. If the application control with the <span style="font-family: Courier New,Courier,monospace">http://tizen.org/appcontrol/operation/nfc/transaction</span> operation is defined in the <span style="font-family: Courier New,Courier,monospace">config.xml</span> file and a transaction caused by the card emulation functionality occurs, the NFC application is launched.</p>
+<p>NFC applications can also be launched by the transaction of the card emulation functionality. NFC devices can communicate with point of sales (POS) terminals using the card emulation functionality to, for example, make a payment. If the application control with the <span style="font-family: Courier New,Courier,monospace">http://tizen.org/appcontrol/operation/nfc/transaction</span> or <span style="font-family: Courier New,Courier,monospace">http://tizen.org/appcontrol/operation/nfc/off_host_apdu_service</span> operation is defined in the <span style="font-family: Courier New,Courier,monospace">config.xml</span> file and a secure element transaction occurs, the NFC application is launched.</p>
+<p>NFC applications can also be launched by the transaction of the HCE functionality. NFC application can communicate with point of sales (POS) terminals using the HCE functionality to, for example, make a payment. If the application control with the <span style="font-family: Courier New,Courier,monospace">http://tizen.org/appcontrol/operation/nfc/host_apdu_service</span> operation is defined in the <span style="font-family: Courier New,Courier,monospace">config.xml</span> file and a HCE transaction occurs, the NFC application is launched.</p>
+<p>The system sends the <span style="font-family: Courier New,Courier,monospace">http://tizen.org/appcontrol/operation/nfc/card_emulation/default_changed</span> application control event when the default wallet is changed. For example, in <strong>Setting &gt; NFC &gt; Set Default Wallet App</strong>, if the default wallet is changed, an application control with this operation is sent to the selected application (wallet).</p>
 <p>The following table lists the NFC operations, scheme and mime.</p>
   <table border="1">
    <caption>
@@ -87,7 +89,7 @@
    <tbody>
     <tr>
      <th>Operation</th>
-     <th>Scheme</th>
+     <th>URI scheme </th>
      <th>MIME</th>
     </tr>
     <tr>
 </ul>     </td>
      <td><span style="font-family: Courier New,Courier,monospace">NULL</span></td>
     </tr>
+    <tr>
+     <td><span style="font-family: Courier New,Courier,monospace">http://tizen.org/appcontrol/operation/nfc/card_emulation/host_apdu_service</span></td>
+     <td><span style="font-family: Courier New,Courier,monospace">NULL</span></td>
+     <td><span style="font-family: Courier New,Courier,monospace">NULL</span></td>
+    </tr>
+    <tr>
+     <td><span style="font-family: Courier New,Courier,monospace">http://tizen.org/appcontrol/operation/nfc/card_emulation/off_host_apdu_service</span></td>
+     <td><span style="font-family: Courier New,Courier,monospace">NULL</span></td>
+     <td><span style="font-family: Courier New,Courier,monospace">NULL</span></td>
+    </tr>
+        <tr>
+     <td><span style="font-family: Courier New,Courier,monospace">http://tizen.org/appcontrol/operation/nfc/card_emulation/default_changed</span></td>
+     <td><span style="font-family: Courier New,Courier,monospace">NULL</span></td>
+     <td><span style="font-family: Courier New,Courier,monospace">NULL</span></td>
+    </tr>
    </tbody>
   </table>
   <p>* The <span style="font-family: Courier New,Courier,monospace">&lt;protocol_code&gt;</span> and <span style="font-family: Courier New,Courier,monospace">&lt;scheme&gt;</span> must be in sync. See <a href="http://members.nfc-forum.org/apps/group_public/document.php?document_id=5078" target="_blank">NFCForum-TS-RTD_URI_1.0</a> and NFC RTD (Record Type Definition) documentation on the NFC forum.</p>
@@ -181,4 +198,4 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga
 </script>
 
 </body>
-</html>
\ No newline at end of file
+</html>
index 8aa79fa..7cdad48 100644 (file)
@@ -262,6 +262,54 @@ adapter.cardEmulationMode = &quot;OFF&quot;;
 
 <p>Learning how to detect NFC HCE (host-based card emulation) events and manage AID (Application ID) is a basic NFC management skill:</p>
 <ol>
+<li><p>Specify an <span style="font-family: Courier New,Courier,monospace;">AID</span> value for receiving HCE transaction events:</p>
+<ol type="a">
+<li>
+<p>To tell the platform which AID groups are requested by application, a metadata element must be included in the config.xml file:</p>
+<pre class="prettyprint">
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;widget xmlns:tizen=&quot;http://tizen.org/ns/wdigets&quot; xmlns=&quot;http://www.w3.org/ns/widgets&quot;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id="http://yourdomain/basicapp"&quot; version=&quot;1.0.0&quot; viewmodes=&quot;maximized&quot; &gt;
+&nbsp;&nbsp;&nbsp;&lt;profile name=&quot;wearable&quot; /&gt;
+&nbsp;&nbsp;&nbsp;&lt;tizen:application id=&quot;ZmAk4fxZWY.basicapp&quot; package=&quot;ZmAk4fxZWY&quot; required_version=&quot;2.3.1&quot;/&gt;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;icon src=icon.png&quot;/&gt;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;name&gt;basicapp&lt;/name&gt;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;metadata key=&quot;http://tizen.org/metadata/nfc_cardemulation&quot;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value=&quot;/res/wgt/wallet.xml&quot;/&gt;
+&lt;/widget&gt;
+</pre>
+<ul><li>The <span style="font-family: Courier New,Courier,monospace;">metadata</span> element must contain the <span style="font-family: Courier New,Courier,monospace;">key</span> and <span style="font-family: Courier New,Courier,monospace;">value</span> attributes.</li>
+<li>The <span style="font-family: Courier New,Courier,monospace;">key</span> attribute must be <span style="font-family: Courier New,Courier,monospace;">http://tizen.org/metadata/nfc_cardemulation</span>.</li>
+<li>The <span style="font-family: Courier New,Courier,monospace;">value</span> attribute must contain the AID XML file path.
+<p>The <span style="font-family: Courier New,Courier,monospace;">value</span> attribute is a relative path starting from the application root path.</p></li>
+</ul>
+</li>
+<li><p>The metadata element points to an AID XML file. The following is an example of the file with an AID declaration:</p>
+<pre class="prettyprint">
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;application name=&quot;ZmAk4fxZWY.basicapp&quot;&gt;
+&nbsp;&nbsp;&nbsp;&lt;wallet&gt;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;aid-group category=&quot;payment&quot;&gt;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;aid aid=&quot;325041592E5359532E4444463031&quot;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;se_type=&quot;hce&quot; unlock=&quot;false&quot; power=&quot;sleep&quot;/&gt;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/aid-group&gt;
+&nbsp;&nbsp;&nbsp;&lt;/wallet&gt;
+&lt;/application&gt;
+</pre>
+<ul><li>The <span style="font-family: Courier New,Courier,monospace;">application</span> element must contain a <span style="font-family: Courier New,Courier,monospace;">name</span> attribute with an application name.</li>
+<li>The <span style="font-family: Courier New,Courier,monospace;">application</span> element must contain one or more <span style="font-family: Courier New,Courier,monospace;">wallet</span> element, each of which must contain one or more <span style="font-family: Courier New,Courier,monospace;">aid-group</span> element. </li>
+<li>The <span style="font-family: Courier New,Courier,monospace;">aid-group</span> element is required to contain a <span style="font-family: Courier New,Courier,monospace;">category</span> attribute with the <span style="font-family: Courier New,Courier,monospace;">payment</span> or <span style="font-family: Courier New,Courier,monospace;">other</span> value.</li>
+<li>Each <span style="font-family: Courier New,Courier,monospace;">aid-group</span> element must contain one or more <span style="font-family: Courier New,Courier,monospace;">aid</span> element, each of which contains a single AID. The <span style="font-family: Courier New,Courier,monospace;">aid-group</span> can have as many <span style="font-family: Courier New,Courier,monospace;">aid</span> elements as you want.</li>
+<li>The <span style="font-family: Courier New,Courier,monospace;">aid</span> element must contain the <span style="font-family: Courier New,Courier,monospace;">aid</span>, <span style="font-family: Courier New,Courier,monospace;">se_type</span>, <span style="font-family: Courier New,Courier,monospace;">unlock</span>, and <span style="font-family: Courier New,Courier,monospace;">power</span> attributes.</li>
+<li>The <span style="font-family: Courier New,Courier,monospace;">se_type</span> attribute must contain <span style="font-family: Courier New,Courier,monospace;">hce</span>, <span style="font-family: Courier New,Courier,monospace;">ese</span>, or <span style="font-family: Courier New,Courier,monospace;">uicc</span>. The <span style="font-family: Courier New,Courier,monospace;">se_type</span> value can be added later.</li>
+<li>The <span style="font-family: Courier New,Courier,monospace;">unlock</span> attribute must contain one of the following:
+<ul><li><span style="font-family: Courier New,Courier,monospace;">true</span>: The card cannot work when the device is locked.</li>
+<li><span style="font-family: Courier New,Courier,monospace;">false</span>: The card can work when the device is locked.</li></ul></li>
+<li>The <span style="font-family: Courier New,Courier,monospace;">power</span> must contain one of the following:
+<ul><li><span style="font-family: Courier New,Courier,monospace;">on</span>: The card can work when the device is on.</li>
+<li><span style="font-family: Courier New,Courier,monospace;">off</span>: The card can work when the device is off.</li>
+<li><span style="font-family: Courier New,Courier,monospace;">sleep</span>: The card can work when the device is in the sleep mode.</li></ul></li>
+</ul></li></ol>
 <li><p>Declare the required variables and obtain the <span style="font-family: Courier New,Courier,monospace">NFCAdapter</span> object (in <a href="../../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/nfc.html#NFCAdapter">mobile</a> and <a href="../../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/nfc.html#NFCAdapter">wearable</a> applications) using the <span style="font-family: Courier New,Courier,monospace">getDefaultAdapter()</span> method of the <span style="font-family: Courier New,Courier,monospace">NFCManager</span> interface (in <a href="../../../../../org.tizen.web.apireference/html/device_api/mobile/tizen/nfc.html#NFCManager">mobile</a> and <a href="../../../../../org.tizen.web.apireference/html/device_api/wearable/tizen/nfc.html#NFCManager">wearable</a> applications).</p>
 <p>To enable NFC card emulation, change the value of the <span style="font-family: Courier New,Courier,monospace">cardEmulationMode</span> attribute.</p>
 <pre class="prettyprint">
@@ -270,8 +318,18 @@ var adapter = tizen.nfc.getDefaultAdapter();
 
 adapter.cardEmulationMode = &quot;ALWAYS_ON&quot;;
 </pre></li>
-<li>Use the <span style="font-family: Courier New,Courier,monospace">addHCEEventListener()</span> method of the <span style="font-family: Courier New,Courier,monospace">NFCAdapter</span> interface to register a listener to detect the HCE event:
+<li><p>To detect the HCE event, use the <span style="font-family: Courier New,Courier,monospace">addHCEEventListener()</span> method of the <span style="font-family: Courier New,Courier,monospace">NFCAdapter</span> interface to register a listener.</p> <p>Use the <span style="font-family: Courier New,Courier,monospace">sendHostAPDUResponse()</span> method of the <span style="font-family: Courier New,Courier,monospace">NFCAdapter</span> interface to send a host APDU (Application Protocol Data Unit is defined in the ISO/IEC 7816-4 specification) response to a Contactless Front-end.</p>
 <pre class="prettyprint">
+var successCB = function()
+{
+&nbsp;&nbsp;&nbsp;console.log(&quot;Sending APDU response was successful.&quot;);
+};
+
+var errorCB = function()
+{
+&nbsp;&nbsp;&nbsp;console.log(&quot;Sending APDU response failed.&quot;);
+};
+
 hceListenerId = adapter.addHCEEventListener(function(event_data)
 {
 &nbsp;&nbsp;&nbsp;if (event_data.eventType ==&quot;ACTIVATED&quot;)
@@ -285,31 +343,11 @@ hceListenerId = adapter.addHCEEventListener(function(event_data)
 &nbsp;&nbsp;&nbsp;else if (event_data.eventType ==&quot;APDU_RECEIVED&quot;)
 &nbsp;&nbsp;&nbsp;{
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(&quot;APDU received&quot;);
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var apdu_response= [0x00,0xA4,0x04,0x00,0x04,0x11,0x12, 0x13, 0x14];
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adapter.sendHostAPDUResponse(apdu_response, successCB, errorCB);
 &nbsp;&nbsp;&nbsp;}
 });
 </pre></li>
-<li>Use the <span style="font-family: Courier New,Courier,monospace">sendHostAPDUResponse()</span> method of the <span style="font-family: Courier New,Courier,monospace">NFCAdapter</span> interface to send a host APDU (Application Protocol Data Unit is defined in the ISO/IEC 7816-4 specification) response to a Contactless Front-end:
-<pre class="prettyprint">
-try 
-{
-&nbsp;&nbsp;&nbsp;var successCB = function() 
-&nbsp;&nbsp;&nbsp;{
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(&quot;Sending APDU response was successful.&quot;);
-&nbsp;&nbsp;&nbsp;};
-
-&nbsp;&nbsp;&nbsp;var errorCB = function() 
-&nbsp;&nbsp;&nbsp;{
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(&quot;Sending APDU response failed.&quot;);
-&nbsp;&nbsp;&nbsp;};
-
-&nbsp;&nbsp;&nbsp;var apdu_response= [0x00,0xA4,0x04,0x00,0x04,0x11,0x12, 0x13, 0x14];
-&nbsp;&nbsp;&nbsp;adapter.sendHostAPDUResponse(apdu_response, successCB, errorCB);
-} 
-catch (err) 
-{
-&nbsp;&nbsp;&nbsp;console.log(err.name + &quot;:&quot; + err.message);
-}
-</pre></li>
  <li>To register an AID for a specific category and secure element type, use the <span style="font-family: Courier New,Courier,monospace">registerAID()</span> method of the <span style="font-family: Courier New,Courier,monospace">NFCAdapter</span> interface:
 <pre class="prettyprint">
 try 
@@ -367,15 +405,15 @@ adapter.cardEmulationMode = &quot;OFF&quot;;
 <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">\r
-var _gaq = _gaq || [];\r
-_gaq.push(['_setAccount', 'UA-25976949-1']);\r
-_gaq.push(['_trackPageview']);\r
-(function() {\r
-var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\r
-ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\r
-var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\r
-})();\r
+  <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>