×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    4

    How to read UID from type 2 tags, QNearFieldTarget::uid() is returning garbled data

    Hi, first off thank you for sparing the time to read my post.
    I'm generally very new with QT programming and C++ as I come from a Java based education.

    Currently I'm following the corkboard example from QT Creator, along with the PDF file.

    I'm trying to read the UID of the tag and the closest I could get to is accessing the QNearFieldTarget::uid() method.

    It's currently returning garbled data like Ñ)K%?" instead of a proper string.
    Am I accessing it wrongly?

    At the moment I'm outputting it via the following snippet:

    void NdefManager::targetDetected(QNearFieldTarget *target) {
    [...]
    QString id(target->uid());
    qDebug() << "Attempt read results: " + id;
    [...]
    }

  2. #2
    Registered User
    Join Date
    Oct 2011
    Posts
    4

    Re: How to read UID from type 2 tags, QNearFieldTarget::uid() is returning garbled da

    Just an update, I have been playing around with the various QString methods to see if any of them works but unfortunately they dont.

    Here's the snippet and outputs:

    [Qt Message] Target detected ...
    [Qt Message] "Test read:??7¡Á"
    [Qt Message] "Test read fromAscii:??7¡Á"
    [Qt Message] "Test read fromLatin1:??7¡Á"
    [Qt Message] "Test read fromLocal8Bit:"
    [Qt Message] "Test read fromUtf8:??7?"
    [Qt Message] Target lost ...

    QString id(target->uid());

    qDebug() << "Test read:" + id;

    id = QString::fromAscii(target->uid());
    qDebug() << "Test read fromAscii:" + id;

    id = QString::fromLatin1(target->uid());
    qDebug() << "Test read fromLatin1:" + id;

    id = QString::fromLocal8Bit(target->uid());
    qDebug() << "Test read fromLocal8Bit:" + id;

    //id = QString::fromRawData(target->uid());
    //qDebug() << "Test read fromRawData:" + id;

    //id = QString::fromUcs4(target->uid());
    //qDebug() << "Test read fromUcs4:" + id;

    id = QString::fromUtf8(target->uid());
    qDebug() << "Test read fromUtf8:" + id;

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    4

    Re: How to read UID from type 2 tags, QNearFieldTarget::uid() is returning garbled da

    Ahhhh...

    My bad, a careless mistake to assume that the uid is a QString.
    It is a Hexadecimal figure.

    id = "" + target->uid().toHex();

    This worked for me.
    Do feel free to close this thread, thanks!

Similar Threads

  1. Replies: 1
    Last Post: 2010-11-29, 13:40
  2. Is there a way to read UHF rf-id tags using a S40 or S60 phone?
    By Bernd42 in forum Near Field Communication
    Replies: 0
    Last Post: 2009-06-03, 00:55
  3. Asynchronous RFile::Read returning KErrCorrupt
    By Gingah in forum Symbian C++
    Replies: 7
    Last Post: 2007-05-24, 03:46
  4. Read/write 3220 tags from Pegoda
    By jideel in forum Near Field Communication
    Replies: 6
    Last Post: 2007-05-04, 16:43
  5. SDK 3.0 CLVoice - can I read/write VOICE Dial Tags?
    By taoiseachjoe in forum PC Suite API and PC Connectivity SDK
    Replies: 2
    Last Post: 2004-03-07, 06:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •