QNearFieldTarget Class

The QNearFieldTarget class provides an interface for communicating with a target device. More...

Header: #include <QNearFieldTarget>
qmake: QT += nfc
Since: Qt 5.2
Inherits: QObject

This class was introduced in Qt 5.2.

Public Types

class RequestId
enum AccessMethod { UnknownAccess, NdefAccess, TagTypeSpecificAccess, LlcpAccess }
enum Error { NoError, UnknownError, UnsupportedError, TargetOutOfRangeError, NoResponseError, …, CommandError }
enum Type { ProprietaryTag, NfcTagType1, NfcTagType2, NfcTagType3, NfcTagType4, MifareTag }

Detailed Description

QNearFieldTarget provides a generic interface for communicating with an NFC target device. Both NFC Forum devices and NFC Forum Tag targets are supported by this class. All target specific classes subclass this class.

The type() function can be used to get the type of the target device. The uid() function returns the unique identifier of the target. The AccessMethods flags returns from the accessMethods() function can be tested to determine which access methods are supported by the target.

If the target supports NdefAccess, hasNdefMessage() can be called to test if the target has a stored NDEF message, readNdefMessages() and writeNdefMessages() functions can be used to get and set the NDEF message.

If the target supports TagTypeSpecificAccess, sendCommand() can be used to send a single proprietary command to the target and retrieve the response. sendCommands() can be used to send multiple proprietary commands to the target and retrieve all of the responses.

If the target supports LlcpAccess, the QLlcpSocket class can be used to connected to a service provided by the target.

Member Type Documentation

enum QNearFieldTarget::AccessMethod

This enum describes the access methods a near field target supports.

ConstantValueDescription
QNearFieldTarget::UnknownAccess0x00The target supports an unknown access type.
QNearFieldTarget::NdefAccess0x01The target supports reading and writing NDEF messages using readNdefMessages() and writeNdefMessages().
QNearFieldTarget::TagTypeSpecificAccess0x02The target supports sending tag type specific commands using sendCommand() and sendCommands().
QNearFieldTarget::LlcpAccess0x04The target supports peer-to-peer LLCP communication.

enum QNearFieldTarget::Error

This enum describes the error codes that a near field target reports.

ConstantValueDescription
QNearFieldTarget::NoError0No error has occurred.
QNearFieldTarget::UnknownError1An unidentified error occurred.
QNearFieldTarget::UnsupportedError2The requested operation is unsupported by this near field target.
QNearFieldTarget::TargetOutOfRangeError3The target is no longer within range.
QNearFieldTarget::NoResponseError4The target did not respond.
QNearFieldTarget::ChecksumMismatchError5The checksum has detected a corrupted response.
QNearFieldTarget::InvalidParametersError6Invalid parameters were passed to a tag type specific function.
QNearFieldTarget::NdefReadError7Failed to read NDEF messages from the target.
QNearFieldTarget::NdefWriteError8Failed to write NDEF messages to the target.
QNearFieldTarget::CommandError9Failed to send a command to the target.

enum QNearFieldTarget::Type

This enum describes the type of tag the target is detected as.

ConstantValueDescription
QNearFieldTarget::ProprietaryTag0An unidentified proprietary target tag.
QNearFieldTarget::NfcTagType11An NFC tag type 1 target.
QNearFieldTarget::NfcTagType22An NFC tag type 2 target.
QNearFieldTarget::NfcTagType33An NFC tag type 3 target.
QNearFieldTarget::NfcTagType44An NFC tag type 4 target.
QNearFieldTarget::MifareTag5A Mifare target.