Qt Mobility Reference Documentation

QNearFieldManager Class Reference

The QNearFieldManager class provides access to notifications for NFC events. More...

 #include <QNearFieldManager>

Inherits QObject.

Public Functions

QNearFieldManager ( QObject * parent = 0 )
~QNearFieldManager ()
int registerTargetDetectedHandler ( QObject * object, const char * method )
int registerTargetDetectedHandler ( QObject * object, const char * method )
int registerTargetDetectedHandler ( QNdefRecord::TypeNameFormat typeNameFormat, const QByteArray & type, QObject * object, const char * method )
int registerTargetDetectedHandler ( const QNdefFilter & filter, QObject * object, const char * method )
void startTargetDetection ( const QList<QNearFieldTarget::Type> & targetTypes )
void startTargetDetection ( QNearFieldTarget::Type targetType = QNearFieldTarget::AnyTarget )
void stopTargetDetection ()
bool unregisterTargetDetectedHandler ( int handlerId )
  • 29 public functions inherited from QObject

Signals

void targetDetected ( QNearFieldTarget * target )
void targetLost ( QNearFieldTarget * target )
void transactionDetected ( const QByteArray & applicationIdentifier )

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 QNearFieldManager class provides access to notifications for NFC events.

NFC Forum devices support two modes of communications. The first mode, peer-to-peer communications, is used to communicate between two NFC Forum devices. The second mode, master/slave communications, is used to communicate between an NFC Forum device and an NFC Forum Tag or Contactess Card. The targetDetected() signal is emitted when a target device enters communications range. Communications can be initiated from the slot connected to this signal.

NFC Forum devices generally operate as the master in master/slave communications. Some devices are capable of operate as the slave, so called Card Emulation mode. In this mode the local NFC device emulates a NFC Forum Tag or Contactless Card and can be used to perform transactions. The transaction happens entirely within a secure element on the device and only a notification of the transaction is provided. The transactionDetected() signal is emitted whenever a transaction occurs.

NFC Forum Tags can contain one or more messages in a standardized format. These messages are encapsulated in the QNdefMessage class. Use the registerTargetDetectedHandler() functions to register message handlers with particular criteria. Handlers can be unregistered with the unregisterTargetDetectedHandler() function.

Member Function Documentation

QNearFieldManager::QNearFieldManager ( QObject * parent = 0 )

Constructs a new near field manager with parent.

QNearFieldManager::~QNearFieldManager ()

Destroys the near field manager.

int QNearFieldManager::registerTargetDetectedHandler ( QObject * object, const char * method )

Registers object to receive notifications on method when a tag has been detected and has an NDEF message. The method on object should have the prototype 'void targetDetected(const QNdefMessage &message, QNearFieldTarget *target)'.

Returns an identifier, which can be used to unregister the handler, on success; otherwise returns -1.

Note: The target parameter of method may not be available on all platforms, in which case target will be 0.

int QNearFieldManager::registerTargetDetectedHandler ( QObject * object, const char * method )

int QNearFieldManager::registerTargetDetectedHandler ( QNdefRecord::TypeNameFormat typeNameFormat, const QByteArray & type, QObject * object, const char * method )

Registers object to receive notifications on method when a tag has been detected and has an NDEF record that matchings typeNameFormat and type. The method on object should have the prototype 'void targetDetected(const QNdefMessage &message, QNearFieldTarget *target)'.

Returns an identifier, which can be used to unregister the handler, on success; otherwise returns -1.

Note: The target parameter of method may not be available on all platforms, in which case target will be 0.

int QNearFieldManager::registerTargetDetectedHandler ( const QNdefFilter & filter, QObject * object, const char * method )

Registers object to receive notifications on method when a tag has been detected and has an NDEF message that matches filter is detected. The method on object should have the prototype 'void targetDetected(const QNdefMessage &message, QNearFieldTarget *target)'.

Returns an identifier, which can be used to unregister the handler, on success; otherwise returns -1.

Note: The target parameter of method may not be available on all platforms, in which case target will be 0.

void QNearFieldManager::startTargetDetection ( const QList<QNearFieldTarget::Type> & targetTypes )

Starts detecting targets of type targetTypes. Causes the targetDetected() signal to be emitted when a target with a type in targetTypes is within proximity. If targetTypes is empty targets of all types will be detected.

See also stopTargetDetection().

void QNearFieldManager::startTargetDetection ( QNearFieldTarget::Type targetType = QNearFieldTarget::AnyTarget )

This is an overloaded function.

void QNearFieldManager::stopTargetDetection ()

Stops detecting targets. The targetDetected() signal will no longer be emitted until another call to startTargetDetection() is made.

void QNearFieldManager::targetDetected ( QNearFieldTarget * target ) [signal]

This signal is emitted whenever a target is detected. The target parameter represents the detected target.

This signal will be emitted for all detected targets.

QNearFieldManager maintains ownership of target, however, it will not be destroyed until the QNearFieldManager destructor is called. Ownership may be transferred by calling setParent().

Do not delete target from the slot connected to this signal, instead call deleteLater().

Note: that if target is deleted before it moves out of proximity the targetLost() signal will not be emitted.

See also targetLost().

void QNearFieldManager::targetLost ( QNearFieldTarget * target ) [signal]

This signal is emitted whenever a target moves out of proximity. The target parameter represents the lost target.

Do not delete target from the slot connected to this signal, instead use deleteLater().

See also QNearFieldTarget::disconnected().

void QNearFieldManager::transactionDetected ( const QByteArray & applicationIdentifier ) [signal]

This signal is emitted when ever a transaction is performed with the application identified by applicationIdentifier.

The applicationIdentifier is a byte array of up to 16 bytes as defined by ISO 7816-4 and uniquely identifies the application and application vendor that was involved in the transaction.

bool QNearFieldManager::unregisterTargetDetectedHandler ( int handlerId )

Unregisters the target detect handler identified by handlerId.

Returns true on success; otherwise returns false.

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.