Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
hegt
Posts: 3
Registered: ‎06-26-2013
My Device: BlackBerry 10
My Carrier: -

nfc_tag_transceive()

Hello,

 

I am facing some troubles reading from an ISO_15693 NFC Tag. After getting the correct target from the bsp system I try to write some bytes on the tag but I always get an error from

nfc_tag_transceive(). Error is NFC_RESULT_TIMEOUT  .

 

I get the feeling that this function is not waiting for an answer of the tag long enouth or do I have to configure that somewhere?

 

Here is the main code after receiving correct target:

 

 

 

            int clength = 6;
            uint8_t command[clength];
            QString cmd_hex = "0020000";
            Utilities::hexToIntArray(cmd_hex, command);

            size_t rlength; // provided by NFC API

            rlength = 0;

            int rc =  nfc_tag_transceive(target, TAG_TYPE_ISO_15693_3, command, clength, response, NFC_TRANSCEIVE_RESPONSE_MAX_BUFFER_LENGTH, &rlength);

Maybe someone has some experience with this?

Please use plain text.
BlackBerry Development Advisor (Retired)
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: nfc_tag_transceive()

[ Edited ]

Hi,

 

That code as shown has a problem...

 

A byte in hex is two characters. Your cmd_hex is 7 hex chars - meaning 3.5 bytes?

 

If the utility converts that to 3 or 4 - neither of those match 6. You're telling the tag here comes an APDU with 6 bytes - some of which are undefined...

 

From your data sheet - what is the expected behaviour when the tag is sent a message structured like this?

 

Thanks.

 

--
Rob is no longer associated with BlackBerry.
Please use plain text.
New Contributor
hegt
Posts: 3
Registered: ‎06-26-2013
My Device: BlackBerry 10
My Carrier: -

Re: nfc_tag_transceive()

Hi,

 

Aw yes. That of course is wrong. Should be:

002000.

 

But the effect is the same.

 

I tried the same code with another command of your example:

QString cmd_hex = "00210001020304"; (Writing 01020304 to addr: 00)

 

Funny thing is. I can see the data on the Tag after writing. Means the writing is working. But the error I am getting back is the same. Error 0x0a = NFC_RESULT_TIMEOUT....

 

Please use plain text.
BlackBerry Development Advisor (Retired)
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: nfc_tag_transceive()

[ Edited ]

Hey, 002000 is 6 hex chars - 3 bytes when converted... can you check that you are using the correct length?

 

Current code is telling API that there are 6 bytes...

 

 

 

 

 

--
Rob is no longer associated with BlackBerry.
Please use plain text.
New Contributor
hegt
Posts: 3
Registered: ‎06-26-2013
My Device: BlackBerry 10
My Carrier: -

Re: nfc_tag_transceive()

Hey,

 

Aw man, Im sorry bothering you. Thanks for your help. The problem was in the command....so the tag was not answering and then a timeout occured.

 

Here is the correct code for writing to the st m24LR04E TAG:

 

            int MAX_RESPONSE_SIZE = 20;
            uchar_t response[MAX_RESPONSE_SIZE];

            int clength = 3;
            uint8_t command[clength];
            QString cmd_hex = "022000";
            Utilities::hexToIntArray(cmd_hex, command);


            size_t rlength; // provided by NFC API

            rlength = 0;

            int rc;

            rc = nfc_tag_transceive(target, TAG_TYPE_ISO_15693_3, command, clength, response, MAX_RESPONSE_SIZE, &rlength);

            if (rc == NFC_RESULT_SUCCESS) {
                QByteArray responseData = QByteArray::fromRawData(reinterpret_cast<const char *>(response), rlength);
                QString responseAsHex = QString::fromAscii(responseData.toHex());
                //emit message(QString("APDU response: %1").arg(responseAsHex));
                setText(QString("APDU response: %1").arg(responseAsHex));
            } else {
                //emit message(QString("ERROR transmitting APDU:%1").arg(rc));
                //emit message(Utilities::getOperationResultName(rc));
                setText(QString("ERROR transmitting APDU:%1").arg(rc));
            }

Please use plain text.