2 /*global $, tizen, App, app */
4 (function () { // strict mode wrapper
10 * @param {NFCControl} nfc
12 App.NFCPeer = function (nfc) {
16 App.NFCPeer.prototype = {
18 sucSendToTarget: function nfc_peer_sucSendToTarget() {
21 errSendToTarget: function nfc_peer_errSendToTarget(e) {
22 this.nfc.timeExpired('Send problem! ' + e.message);
25 setReceiveFromTarget: function nfc_peer_setReceiveFromTarget() {
27 if (!this.nfc.nfcTarget) {
28 console.warn("app.nfc.nfcTarget not set");
31 this.nfc.nfcTarget.setReceiveNDEFListener(
32 this.nfc.readMessage.bind(this.nfc)
35 console.error('setReceiveFromTarget error: ' + error.message);
39 sucTargetAttach: function nfc_peer_sucTargetAttach(target) {
40 var newMessage = null,
41 fullContact = this.nfc.prepareForNFC(localStorage);
43 this.nfc.nfcTarget = target;
44 this.setReceiveFromTarget();
47 newMessage = this.nfc.phoneNumber2NDEF(fullContact);
50 this.sucSendToTarget.bind(this),
51 this.errSendToTarget.bind(this)
54 console.error("NDEFMessage problem: " + e.message);
58 setTargetDetect: function nfc_peer_setTargetDetect() {
59 var successCallbacks = {
60 onattach: this.sucTargetAttach.bind(this),
61 ondetach: this.nfc.sucDetach.bind(this.nfc)
65 this.nfc.nfcAdapter.setPeerListener(successCallbacks);
67 console.error(error.message);