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.
| Constant | Value | Description |
|---|---|---|
QNearFieldTarget::UnknownAccess | 0x00 | The target supports an unknown access type. |
QNearFieldTarget::NdefAccess | 0x01 | The target supports reading and writing NDEF messages using readNdefMessages() and writeNdefMessages(). |
QNearFieldTarget::TagTypeSpecificAccess | 0x02 | The target supports sending tag type specific commands using sendCommand() and sendCommands(). |
QNearFieldTarget::LlcpAccess | 0x04 | The target supports peer-to-peer LLCP communication. |
enum QNearFieldTarget::Error
This enum describes the error codes that a near field target reports.
| Constant | Value | Description |
|---|---|---|
QNearFieldTarget::NoError | 0 | No error has occurred. |
QNearFieldTarget::UnknownError | 1 | An unidentified error occurred. |
QNearFieldTarget::UnsupportedError | 2 | The requested operation is unsupported by this near field target. |
QNearFieldTarget::TargetOutOfRangeError | 3 | The target is no longer within range. |
QNearFieldTarget::NoResponseError | 4 | The target did not respond. |
QNearFieldTarget::ChecksumMismatchError | 5 | The checksum has detected a corrupted response. |
QNearFieldTarget::InvalidParametersError | 6 | Invalid parameters were passed to a tag type specific function. |
QNearFieldTarget::NdefReadError | 7 | Failed to read NDEF messages from the target. |
QNearFieldTarget::NdefWriteError | 8 | Failed to write NDEF messages to the target. |
QNearFieldTarget::CommandError | 9 | Failed to send a command to the target. |
enum QNearFieldTarget::Type
This enum describes the type of tag the target is detected as.
| Constant | Value | Description |
|---|---|---|
QNearFieldTarget::ProprietaryTag | 0 | An unidentified proprietary target tag. |
QNearFieldTarget::NfcTagType1 | 1 | An NFC tag type 1 target. |
QNearFieldTarget::NfcTagType2 | 2 | An NFC tag type 2 target. |
QNearFieldTarget::NfcTagType3 | 3 | An NFC tag type 3 target. |
QNearFieldTarget::NfcTagType4 | 4 | An NFC tag type 4 target. |
QNearFieldTarget::MifareTag | 5 | A Mifare target. |