<div class="brief">
Sets the power of an NFC adapter to either an on state or an off state.
</div>
-<div class="deprecated"><p><font color="red"><i><b>Deprecated.</b>
+<p class="deprecated"><b>Deprecated.</b>
Deprecated since 2.3. Instead, let the user turn NFC on/off through the Settings application. See the <a href="../../../../../org.tizen.tutorials/html/web/tizen/network/nfc_tutorial_w.htm#Managing_NFC_Conn">Managing NFC</a> Tutorial.
- </i></font></p></div>
+ </p>
<div class="synopsis"><pre class="signature prettyprint">void setPowered(boolean state, optional <a href="tizen.html#SuccessCallback">SuccessCallback</a>? successCallback, optional <a href="tizen.html#ErrorCallback">ErrorCallback</a>? errorCallback);
</pre></div>
<p><span class="version">
console.log("Sending APDU reponse failed.");
};
- var apdu_response= [0x00,0xA4,0x04,0x00,0x04,0x11,0x12, 0x13, 0x14]; //set apdu response.
+ var classOfInstruction = 0x00; // No SM or no SM indication
+ var instructionCode = 0xA4; //Select File
+ var firstParam = 0x04; //Direct selection by DF name
+ var secondParam = 0x00; // First record
+ var dataFieldLength = 0x03; // Variable length 1 or 3 bytes
+ var bytes = [ 0x20, 0x21, 0x22]; // Variable length equal to dataFieldLength
+ var maxBytesExpected = 0x02; // Maximum bytes in answer
+
+ var apdu_response= [ classOfInstruction, instructionCode, firstParam, secondParam] + bytes + [ maxBytesExpected ]; //set apdu response.
adapter.sendHostAPDUResponse(apdu_response, successCB, errorCB) ;
} catch (err) {
console.log(err.name + ": " + err.message);
</ul>
</li></ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ var successCB = function(aids) {
+ var arrayLength = aids.length;
+ for (var i = 0; i arrayLength; i++) {
+ console.log("Get AID category was successful.");
+ console.log("AID type is " + aids[i].type);
+ console.log("AID is " + aids[i].aid);
+ console.log("AID isReadOnly is " + aids[i].readOnly);
+ }
+ };
+
+ var errorCB = function() {
+ console.log("Get AID category failed.");
+ };
+
+ adapter.getAIDsForCategory("HCE", "PAYMENT", successCB, errorCB) ;
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
</ul>
</li></ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ var successCB = function(ndefMessage) {
+ console.log("Message read was successful.");
+ for( var i = 0; i ndefMessage.recordCount; ++i){
+ console.log("Message record " + i + "tnf: " + ndefMessage.records[i].tnf);
+ console.log("Message record " + i + "tnf: " + ndefMessage.records[i].tnf);
+ console.log("Message record type " + ndefMessage.records[i].type.toString());
+ ...
+ }
+ };
+
+ var errorCB = function() {
+ console.log("Message read failed.");
+ };
+
+ nfcTag.readNDEF(successCB, errorCB) ;
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
<dt class="method" id="NFCTag::writeNDEF">
<a class="backward-compatibility-anchor" name="::NFC::NFCTag::writeNDEF"></a><code><b><span class="methodName">writeNDEF</span></b></code>
</ul>
</li></ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ var successCB = function() {
+ console.log("Message write was successful.");
+ }
+ };
+
+ var errorCB = function() {
+ console.log("Message write failed.");
+ };
+
+
+ var record = new tizen.NDEFRecordText("Hi!", "en-GB");
+ var message = new tizen.NDEFMessage([record]);
+
+ nfcTag.writeNDEF(message, successCB, errorCB) ;
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
<dt class="method" id="NFCTag::transceive">
<a class="backward-compatibility-anchor" name="::NFC::NFCTag::transceive"></a><code><b><span class="methodName">transceive</span></b></code>
</ul>
</li></ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ var successCB = function(data) {
+ console.log("Message write was successful.");
+ console.log("Response is " + data.toString());
+ }
+ };
+
+ var errorCB = function() {
+ console.log("Message write failed.");
+ };
+
+ var message = [0x30, 0x00, 0x02, 0xa8]; // READ command for MIFARE tags
+
+ nfcTag.transceive(message, successCB, errorCB) ;
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
</ul>
</li></ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ peerListener = {
+ onattach: function (peer) {
+ var record = new tizen.NDEFRecordText("sendNDEF-test", 'en-US');
+ var message = new tizen.NDEFMessage([record]);
+ returned = peer.sendNDEF(ndefMessage);
+ },
+ ondetach: t.step_func(function () {
+ adapter.unsetPeerListener();
+ }
+ };
+
+ adapter.setPeerListener(peerListener);
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
Since: </span>
1.0
</p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+ var record = new tizen.NDEFRecordText("Hi!", "en-GB");
+ var tempMessage = new tizen.NDEFMessage([record]);
+ var rawData = tempMessage.toByte();
+
+ var message = new tizen.NDEFMessage(rawData);
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
<div class="constructors">
<h4 id="NDEFMessage::constructor">Constructors</h4>
<dl>
Since: </span>
1.0
</p>
-</li>
<div class="example">
-<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
-// prepare two NDEFRecords:
-var myRecordURI = new tizen.NDEFRecordURI("https://www.tizen.org/");
-var myRecordTextPlain = new tizen.NDEFRecordMedia("text/plain", [116, 105, 122, 101, 110]);
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ // prepare two NDEFRecords:
+ var myRecordURI = new tizen.NDEFRecordURI("https://www.tizen.org/");
+ var myRecordTextPlain = new tizen.NDEFRecordMedia("text/plain", [116, 105, 122, 101, 110]);
-// create a NDEFMessage composed of two NDEFRecords:
-var myMessage = new NDEFMessage([myRecordURI, myRecordTextPlain]);
-</pre>
+ // create a NDEFMessage composed of two NDEFRecords:
+ var myMessage = new NDEFMessage([myRecordURI, myRecordTextPlain]);
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
</div>
+</li>
</ul>
</div>
<div class="methods">
Since: </span>
1.0
</p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+ var recordBytes = [217, 1, 2, 3, 202, 219, 218, 217, 240, 241];
+ var record = new tizen.NDEFRecord(recordBytes);
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+ var type = new Array(255),
+ var payload = new Array(256),
+ var recordId = [155, 150],
+ var newRecord = new tizen.NDEFRecord(tizen.nfc.NFC_RECORD_TNF_UNKNOWN, type, payload, recordId);
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
<div class="constructors">
<h4 id="NDEFRecord::constructor">Constructors</h4>
<dl>
1.0
</p>
<div class="example">
-<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
- var newRecord = new tizen.NDEFRecord(2, [42, 84], [1, 2, 3, 4]);
-</pre>
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> // Creates a new NDEF record.
+ var newRecord = new tizen.NDEFRecordURI("https://www.tizen.org/");
+ var payload = newRecord.payload;
+ </pre>
</div>
</li>
</ul>
Since: </span>
1.0
</p>
-</li>
<div class="example">
-<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
- var newRecord = new tizen.NDEFRecordText("Tizen", "en-US", "UTF8");
-</pre>
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var newRecord = new tizen.NDEFRecordText("Tizen", "en-US", "UTF8");
+ </pre>
</div>
+</li>
</ul>
</div>
</div>
Since: </span>
1.0
</p>
+
<div class="constructors">
<h4 id="NDEFRecordURI::constructor">Constructors</h4>
<dl><pre class="webidl prettyprint">NDEFRecordURI(DOMString uri);</pre></dl>
Since: </span>
1.0
</p>
-</li>
<div class="example">
-<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
-// Creates a new NDEF record.
-var newRecord = new tizen.NDEFRecordURI("https://www.tizen.org/");
-var payload = newRecord.payload;
-</pre>
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> // Creates a new NDEF record.
+ var newRecord = new tizen.NDEFRecordURI("https://www.tizen.org/");
+ var payload = newRecord.payload;
+ </pre>
</div>
-</ul>
+</li></ul>
</div>
</div>
<div class="interface" id="NDEFRecordMedia">
Since: </span>
1.0
</p>
-</li>
<div class="example">
-<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint">
-var myData = [116, 105, 122, 101, 110];
-var newRecord = new tizen.NDEFRecordMedia("text/plain", myData);
-</pre>
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> var myData = [116, 105, 122, 101, 110];
+ var newRecord = new tizen.NDEFRecordMedia("text/plain", myData);
+ </pre>
</div>
-</ul>
+</li></ul>
</div>
</div>
<div class="interface" id="HCEEventData">
Since: </span>
2.3.1
</p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="nfc.html#HCEEventReceiveCallback">setListener</a> code example.
+ </p>
<div class="attributes">
<h4>Attributes</h4>
<ul>
Since: </span>
2.3.1
</p>
+<p><span class="remark"> Remark : </span>
+ Example of using can be find at <a href="nfc.html#NFCAdapter::getAIDsForCategory">setListener</a> code example.
+ </p>
<div class="attributes">
<h4>Attributes</h4>
<ul>
</li>
</ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+ var onSuccessCB = {
+ onattach: function (nfcTag){
+ console.log("Successfully detected nfcTag type:" + nfcTag.type);
+ }
+ }
+
+ var adapter = tizen.nfc.getDefaultAdapter();
+ adapter.setTagListener(onSuccessCB);
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
<dt class="method" id="NFCTagDetectCallback::ondetach">
<a class="backward-compatibility-anchor" name="::NFC::NFCTagDetectCallback::ondetach"></a><code><b><span class="methodName">ondetach</span></b></code>
Since: </span>
1.0
</p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+ var adapter;
+ var onSuccessCB = {
+ onattach: function (nfcTag){
+ console.log("Successfully detected nfcTag type:" + nfcTag.type);
+ },
+ ondetach: function() {
+ adapter.unsetTagListener();
+ }
+ }
+
+ adapter = tizen.nfc.getDefaultAdapter();
+ adapter.setTagListener(onSuccessCB);
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
</li>
</ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+ var adapter;
+ var onSuccessCB = {
+ onattach: function (nfcPeer){
+ console.log("Successfully detected nfcPeer :" + nfcPeer.isConnected);
+ }
+ }
+
+ adapter = tizen.nfc.getDefaultAdapter();
+ adapter.setPeerListener(onSuccessCB);
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
<dt class="method" id="NFCPeerDetectCallback::ondetach">
<a class="backward-compatibility-anchor" name="::NFC::NFCPeerDetectCallback::ondetach"></a><code><b><span class="methodName">ondetach</span></b></code>
Since: </span>
1.0
</p>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+ var adapter;
+ var onSuccessCB = {
+ onattach: function (nfcPeer){
+ console.log("Successfully detected nfcPeer :" + nfcPeer.isConnected);
+ },
+ ondetach: function() {
+ adapter.unsetPeerListener();
+ }
+ }
+
+ adapter = tizen.nfc.getDefaultAdapter();
+ adapter.setPeerListener(onSuccessCB);
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
</li>
</ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+ var adapter;
+
+ var readCallback = function (ndefMessage) {
+ console.log("NDEFMessageReadCallback called successfully");
+ }
+
+ var tagListener = {
+ onattach: function (nfcTag){
+ var result = nfcTag.readNDEF(readCallback);
+ }
+ }
+
+ adapter = tizen.nfc.getDefaultAdapter();
+ adapter.setTagListener(tagListener);
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
</li>
</ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ var successCB = function(data) {
+ console.log("ByteArraySuccessCallback called successfully.");
+ }
+ };
+
+ var message = [0x30, 0x00, 0x02, 0xa8]; // READ command for MIFARE tags
+
+ nfcTag.transceive(message, successCB) ;
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
</li>
</ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ var onSuccessCB = function(mode) {
+ console.log("CardEmulationModeChangeCallback called successfully");
+ };
+
+ var listenerId = adapter.addCardEmulationModeChangeListener(onSuccessCB) ;
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
</li>
</ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ var onSuccessCB = function(aid, data) {
+ console.log("TransactionEventCallback called successfully");
+ };
+
+ var listenerId = adapter.addTransactionEventListener("UICC", onSuccessCB) ;
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
</li>
</ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ var onSuccessCB = function(seType) {
+ console.log("ActiveSecureElementChangeCallback called successfully");
+ };
+
+ var listenerId = adapter.addActiveSecureElementChangeListener(onSuccessCB) ;
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
</li>
</ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ var onDetectedCB = function(event_data) {
+ console.log("HCEEventReceiveCallback called successfully");
+ };
+
+ var listenerId = adapter.addHCEEventListener(onDetectedCB) ;
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
</li>
</ul>
</div>
+<div class="example">
+<span class="example"><p>Code example:</p></span><pre name="code" class="examplecode prettyprint"> try {
+
+ var successCB = function(aids) {
+ console.log("AIDArraySuccessCallback called successfully");
+ };
+
+ adapter.getAIDsForCategory("HCE", "PAYMENT", successCB) ;
+ } catch (err) {
+ console.log(err.name + ": " + err.message);
+ }
+ </pre>
+</div>
</dd>
</dl>
</div>
<li class="feature">http://tizen.org/feature/network.nfc.card_emulation.hce</li>
</div>
<p></p>
- For more information, see <a href="../../../../../org.tizen.gettingstarted/html/web/details/app_filtering_w.htm">Application Filtering</a>.
+ For more information, see <a href="../../../../../org.tizen.gettingstarted/html/web/details/app_filtering_w.htm">Application Filtering.</a>
</div>
<h2 id="full-webidl">4. Full WebIDL</h2>
<pre class="webidl prettyprint">module NFC {