Important: Please read the Qt Code of Conduct -

Qt NFC 5.11 on Linux (neard)- Mifare 1k tag "uid" returned is empty

  • Hi,
    I'm working with Qt Nfc 5.11 on my Linux board based on ARM processor (neard v0.16 is installed).

    I'd like to read the UID of a Classic Mifare 1k Tag usign the following code:

    Nfc::Nfc(QObject *parent) :
        manager = new QNearFieldManager(this);
        if (!manager->isAvailable()) {
            qDebug() << "NFC not available";
        connect(manager, SIGNAL(targetLost(QNearFieldTarget*)), this, SLOT(targetLost(QNearFieldTarget*)));
        connect(manager, SIGNAL(targetDetected(QNearFieldTarget*)), this, SLOT(targetDetected(QNearFieldTarget*)));
    void Nfc::targetLost(QNearFieldTarget *target)
        qDebug() << "lost!!!";
    void Nfc::targetDetected(QNearFieldTarget *target)
        qDebug() << "detect!!!";
        qDebug() << "UID:" + target->uid();

    All seem to be ok: neard (v0.16) is running correctly, the driver of my NFC reader (PN532) with "i2c" interface is correctly installed and Qt doesn't report any issue. When I tap my tag on the NFC reader the tag is correctly detected.
    My issue is that the "uid" returned by the Qt uid() method is empty. I debugged the driver and I'm sure that the uid is red correctly via i2c. I report below the output debug of this operation:

    qt.nfc.neard: org.neard.Adapter found for path "/org/neard/nfc0"
    qt.nfc.neard: starting target detection
    qt.nfc.neard: adapter is already powered
    qt.nfc.neard: successfully started polling
    Echoserver listening on port 8080
    Scan card screen
    qt.opengl.diskcache: OpenGL ES v2 context
    qt.opengl.diskcache: Shader cache supported = 0
    qt.nfc.neard: tag found at path "/org/neard/nfc0/tag8"
    qt.nfc.neard: tag type "Type 2"
    qt.nfc.neard: tag removed "/org/neard/nfc0/tag8"

    I noticed that after the tag detection, the tag is released by the driver automatically in few milliseconds (500ms) even if the tag is still on the NFC reader. I didn't understand why the driver releases the target but the time to read the uid should be enough.

    • Do you have some advices to solve this issue?
    • Could be a synchronization issue between the driver, neard and Qt?

    Thank you for your help guys,

  • Just for reference if anyone comes across this: neard does read the tag UID from the NFC device, but it doesn't provide a D-Bus property to allow client applications such as QtNFC to retrieve the UID. Therefore QtNFC also doesn't implement this.

    Unfortunately neard doesn't seem to be maintained anymore and in Qt6 the support for Linux/neard has been dropped altogether.

    Still I got this working quite easily as all the data and interfaces are there and only "a few" lines are missing in neard and QtConnectivity. For those who are interested, here's the patch for neard and the one for QtNFC on top of v5.15.2.

Log in to reply