Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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) :
        QObject(parent)
    {
        QLoggingCategory::setFilterRules("*.debug=true\n"
                                         "driver.usb.debug=true");
    
        manager = new QNearFieldManager(this);
    
        if (!manager->isAvailable()) {
            qDebug() << "NFC not available";
            return;
        }
    
        manager->setTargetAccessModes(QNearFieldManager::NdefReadTargetAccess);
    
        connect(manager, SIGNAL(targetLost(QNearFieldTarget*)), this, SLOT(targetLost(QNearFieldTarget*)));
        connect(manager, SIGNAL(targetDetected(QNearFieldTarget*)), this, SLOT(targetDetected(QNearFieldTarget*)));
    
        manager->startTargetDetection();
    }
    
    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"
    detect!!!
    "UID:"
    
    qt.nfc.neard: tag removed "/org/neard/nfc0/tag8"
    lost!!!
    

    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,
    Fabrizio


Log in to reply