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 Developer
Posts: 7
Registered: ‎04-13-2014
My Device: z10
My Carrier: turkcell

nfc_tag_transceive returns NFC_RESULT_UNHANDLED_ERROR

hello,

 

i am developing an nfc application that handles various tags using nfc_tag_transceive command,

 

For mifare ulrallght tags,

nfc_tag_transceive with,

 

command 30h returns success and i read 16 bytes of tag data from selected page,

 

however, A2h write command

returns NFC_RESULT_UNHANDLED_ERROR

 

When i read back tag content, i see that

in fact tag data has been written correctly,

If so, why nfc_tag_transceive returns NFC_RESULT_UNHANDLED_ERROR?

Why it does not return NFC_RESULT_SUCCESS?

 

According to specifications, mifare ultralight returns only 4 bits of acknowledgment to write command,

can this be the reason?

 

best regards,

Retired
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: nfc_tag_transceive returns NFC_RESULT_UNHANDLED_ERROR

Hi

 

can you please post a hex decode of the full write APDU that you are sending to the tag please?

 

Thank you

 

Martin

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
New Developer
Posts: 7
Registered: ‎04-13-2014
My Device: z10
My Carrier: turkcell

Re: nfc_tag_transceive returns NFC_RESULT_UNHANDLED_ERROR

 

hello,

 

i use

nfc_tag_transceive(target,tgType,tgCmd,tgCmdLen,tgResponse,tgMaxResp,&tgResponseLen)

command to send apdus to mfUL,

 

parameters for this command are,

 

target->tag returned from the @c nfc_get_target() function

tgType->1,(TAG_TYPE_ISO_14443_3)

tgCmd->buffer holding the command to be sent, content is A2h,page No, 4 bytes page data

tgCmdLen->6 bytes,

tgResponse->buffer to get response data,

max. response 16 bytes,

tgResponseLen->int variable to get response length,

 

best regards,

 

Retired
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: nfc_tag_transceive returns NFC_RESULT_UNHANDLED_ERROR

Thanks. Could you give me some specific values for the command buffer please i.e. block number and 4 bytes data? I'd like to try to recreate the issue before I perhaps discuss with our development team.

 

Could you also tell me what exact OS version you are running please?

 

Regards

 

Martin

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
New Developer
Posts: 7
Registered: ‎04-13-2014
My Device: z10
My Carrier: turkcell

Re: nfc_tag_transceive returns NFC_RESULT_UNHANDLED_ERROR

 

i use page number instead of block number,

since mfUltralight contains pages,

an example page number may be 4,

and example of data may be 4 bytes of 255 to erase the page,

best regards,

Retired
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: nfc_tag_transceive returns NFC_RESULT_UNHANDLED_ERROR

Thanks.

 

I think "page" and "block" are equivalent here (just fyi). The NFC Forum Type 2 tag specification uses the term "block" for 4 contigous bytes and the Mifare Ultralight spec seems to use "page" for the same thing.

 

I'll investigate and get back to you.

 

Martin

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
New Developer
Posts: 7
Registered: ‎04-13-2014
My Device: z10
My Carrier: turkcell

Re: nfc_tag_transceive returns NFC_RESULT_UNHANDLED_ERROR

 

hello,

 

there is no problem with block or page,

it is just a notation and contains 4 bytes as you mention,

please do not bother about this point,

it is not the failure reason  for my case(unhandled error)

 

Meanwhile, i managed to integrate mifare desfire cards to my app.

and can send apdus to desfire,select file, read binary and update binary,

everything is working as expected with desfire,

 

best regards,

 

Retired
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: nfc_tag_transceive returns NFC_RESULT_UNHANDLED_ERROR

Hi

 

I have recreated the problem, which is a good start. I get the same response.... NFC_RESULT_UNHANDLED_ERROR although I do see that the write operation was in fact successful. For comparison purposes and others who may read this thread, here are the details. Note that I just hard coded writing 0xFFFFFFFF to page/block number 5.

 

void NfcWorker::handleWriteBlockEvent(bps_event_t *event)
{
    uint16_t code = bps_event_get_code(event);
    qDebug() << "XXXX NfcWorker::handleWriteBlockEvent - processing event code " << code;


    if (NFC_TAG_READWRITE_EVENT == code) {
        nfc_event_t *nfcEvent;
        nfc_target_t* target;
        qDebug() << "XXXX NfcWorker::handleWriteBlockEvent - Target Read Write Event";

        CHECK(nfc_get_nfc_event(event, &nfcEvent));
        CHECK(nfc_get_target(nfcEvent, &target));

        int MAX_RESPONSE_SIZE = 256;
        uchar_t response[MAX_RESPONSE_SIZE];

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

        emit message(QString("Writing %1").arg(cmd_hex));
        size_t rlength;
        int rc = nfc_tag_transceive(target, TAG_TYPE_ISO_14443_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));
        } else {
            emit message(QString("ERROR transmitting APDU:%1").arg(rc));
            emit message(Utilities::getOperationResultName(rc));
        }

        CHECK(nfc_unregister_tag_readerwriter());
        CHECK(nfc_destroy_target(target));
    }

    qDebug() << "XXXX NfcWorker::handleWriteBlockEvent - done";

}

 

I also dumped the memory of the tag before and after writing to it:

 

BEFORE WRITING:

Memory Map
----------
Page  0 : 04 85 87 8E : ?àçÄ
Page  1 : 71 E5 02 80 : qs?Ç
Page  2 : 16 48 00 00 : ?H
Page  3 : 00 00 00 00 :
Page  4 : FF FF FF FF :     
Page  5 : 11 22 33 44 : ?"3D
Page  6 : 00 00 00 00 :
Page  7 : 00 00 00 00 :

AFTER WRITING:

Memory Map
----------
Page  0 : 04 85 87 8E : ?àçÄ
Page  1 : 71 E5 02 80 : qs?Ç
Page  2 : 16 48 00 00 : ?H
Page  3 : 00 00 00 00 :
Page  4 : FF FF FF FF :     
Page  5 : FF FF FF FF :     
Page  6 : 00 00 00 00 :
Page  7 : 00 00 00 00 :

 I'll bring this to the attention of our development team and see what they say. Right now it looks as though you may be able to safely ignore that error however.

 

Regards

 

Martin

 

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
New Developer
Posts: 7
Registered: ‎04-13-2014
My Device: z10
My Carrier: turkcell

Re: nfc_tag_transceive returns NFC_RESULT_UNHANDLED_ERROR

T

New Developer
Posts: 7
Registered: ‎04-13-2014
My Device: z10
My Carrier: turkcell

Re: nfc_tag_transceive returns NFC_RESULT_UNHANDLED_ERROR

 

Thanks for your effort,

 

just as you mention,

at the moment i ignore the error case, and verify written data,

but what about

nfc_write_ndef_message_to_tag(....) api function?

it also returns success flag and manages to update tag data correctly,

does it also ignore this error case and return success or something different is being done in this function?

 

Just as a good news, i want to share with you that

nfc_tag_transceive api function can handle M22LRxx iso15693 dual eeprom tags from ST microelectronics,

you may perhaps add this tag family to supported tags,

 

i hopefully wait for your solution regarding mifare ultralight problem,

 

best regards,