NFC implementation tizen wearable

114 Views Asked by At

Unable to get NDEFRecordsText.text from tizen NFC simulator. Am only getting first three characters.

Is it a bug from simulator or am i doing something wrong ?

SAMPLE CODE

var setPeerDetect = {
            /* When an NFC tag is detected */
            onattach: function(nfcPeer) {
                
                nfcPeer.setReceiveNDEFListener(function(ndefMessage){
                    console.log(ndefMessage.records[0].text);   
                    return true;
                });
            },

            /* When an NFC tag becomes unavailable */
            ondetach: function() {
                console.log('NFC Peer unavailable');
            }
        };

Here, ndefMessage.records[0].text just returns first three characters of payload. Also how can i decode the actual payload sent through emulator, currently am getting something like [5,121,121,0,0,0,0] as payload from ndefRecord

1

There are 1 best solutions below

0
On

I noticed that you seem to use some custom field of NDEFRecord interface which is defined here. 'text' member is not defined in documentation. To access payload of message, you just need to use:

console.log(ndefMessage.records[0].payload); 

I quickly confirmed this on Tizen 6.0 wearable emulator available in Tizen Studio 4.1, which I have installed.