Qt Mobility Reference Documentation

QNearFieldTarget Class Reference

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

 #include <QNearFieldTarget>

Inherits QObject.

Inherited by QNearFieldTagType1 and QNearFieldTagType2.

Public Types

enum AccessMethod { NdefAccess, ApduAccess, TagTypeSpecificAccess, LlcpAccess }
flags AccessMethods
enum Type { AnyTarget, ProprietaryTag, NfcTagType1, NfcTagType2, ..., MifareTag }

Public Functions

QNearFieldTarget ( QObject * parent = 0 )
virtual AccessMethods accessMethods () const = 0
virtual bool hasNdefMessage ()
virtual QList<QNdefMessage> ndefMessages ()
virtual QByteArray sendApduCommand ( const QByteArray & command )
virtual QList<QByteArray> sendApduCommands ( const QList<QByteArray> & commands )
virtual QByteArray sendCommand ( const QByteArray & command )
virtual QList<QByteArray> sendCommands ( const QList<QByteArray> & commands )
virtual void setNdefMessages ( const QList<QNdefMessage> & messages )
virtual Type type () const = 0
virtual QByteArray uid () const = 0
virtual QUrl url () const
  • 29 public functions inherited from QObject

Signals

void disconnected ()

Related Non-Members

quint16 qNfcChecksum ( const char * data, uint len )

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

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

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, ndefMessages() and setNdefMessages() functions can be used to get and set the NDEF message.

If the target supports ApduAccess, sendApduCommand() can be used to send a single APDU command to the target and retrieve the response. sendApduCommands() can be used to send multiple APDU commands to the target and retrieve all of the responses.

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
flags QNearFieldTarget::AccessMethods

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

ConstantValueDescription
QNearFieldTarget::NdefAccess0The target supports NDEF records using ndefMessages() and setNdefMessages().
QNearFieldTarget::ApduAccess1The target supports APDU access using sendApduCommand() and sendApduCommands().
QNearFieldTarget::TagTypeSpecificAccess2The target supports sending tag type specific commands using sendCommand() and sendCommands().
QNearFieldTarget::LlcpAccess3The target supports peer-to-peer LLCP communication.

The AccessMethods type is a typedef for QFlags<AccessMethod>. It stores an OR combination of AccessMethod values.

enum QNearFieldTarget::Type

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

ConstantValueDescription
QNearFieldTarget::AnyTarget0This value is only used when registering handlers to indicate that any compatible target can be used.
QNearFieldTarget::ProprietaryTag1An unidentified proprietary target tag.
QNearFieldTarget::NfcTagType12An NFC tag type 1 target.
QNearFieldTarget::NfcTagType23An NFC tag type 2 target.
QNearFieldTarget::NfcTagType34An NFC tag type 3 target.
QNearFieldTarget::NfcTagType45An NFC tag type 4 target.
QNearFieldTarget::MifareTag6A Mifare target.

Member Function Documentation

QNearFieldTarget::QNearFieldTarget ( QObject * parent = 0 )

Constructs a new near field target with parent.

AccessMethods QNearFieldTarget::accessMethods () const [pure virtual]

Returns the access methods support by this near field target.

void QNearFieldTarget::disconnected () [signal]

This signal is emitted when the near field target moves out of proximity.

bool QNearFieldTarget::hasNdefMessage () [virtual]

Returns true if at least one NDEF message is stored on the near field target; otherwise returns false.

QList<QNdefMessage> QNearFieldTarget::ndefMessages () [virtual]

Returns a list of all NDEF messages stored on the near field target.

See also setNdefMessages().

QByteArray QNearFieldTarget::sendApduCommand ( const QByteArray & command ) [virtual]

Sends the APDU command to the near field target and returns the result.

QList<QByteArray> QNearFieldTarget::sendApduCommands ( const QList<QByteArray> & commands ) [virtual]

Sends multiple APDU commands to the near field target and returns the results.

QByteArray QNearFieldTarget::sendCommand ( const QByteArray & command ) [virtual]

Sends command to the near field target and returns the result.

QList<QByteArray> QNearFieldTarget::sendCommands ( const QList<QByteArray> & commands ) [virtual]

Sends multiple commands to the near field target and returns the result.

void QNearFieldTarget::setNdefMessages ( const QList<QNdefMessage> & messages ) [virtual]

Sets the NDEF messages stored on the near field target to messages.

See also ndefMessages().

Type QNearFieldTarget::type () const [pure virtual]

Returns the type of tag type of this near field target.

QByteArray QNearFieldTarget::uid () const [pure virtual]

Returns the UID of the near field target.

QUrl QNearFieldTarget::url () const [virtual]

Returns the URL of the near field target.

Related Non-Members

quint16 qNfcChecksum ( const char * data, uint len )

Returns the NFC checksum of the first len bytes of data.

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.