From 4a8fe389db0212eb6f85a49612ceddd56dd1aaf4 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Thu, 12 Sep 2013 11:09:27 +0200 Subject: Changing the way nfc target detection works On Android and BB10 the target detection does not distinguish between NFC tag types when it comes to target detection but rather between the protocols the tags use. This patch removes the parameters used for target detection. Change-Id: I4609cde61d34159bc66b29a27f8d76df816e2c23 Reviewed-by: Alex Blasche --- src/nfc/doc/src/nfc-cpp.qdoc | 5 ++-- src/nfc/doc/src/nfc-index.qdoc | 3 +-- src/nfc/doc/src/nfc-overview.qdoc | 8 ++----- src/nfc/doc/src/nfc-qml.qdoc | 2 +- src/nfc/qnearfieldmanager.cpp | 40 ++++++++------------------------ src/nfc/qnearfieldmanager.h | 3 +-- src/nfc/qnearfieldmanager_p.h | 4 +--- src/nfc/qnearfieldmanager_qnx.cpp | 6 ++--- src/nfc/qnearfieldmanager_qnx_p.h | 2 +- src/nfc/qnearfieldmanagervirtualbase.cpp | 18 +++++++------- src/nfc/qnearfieldmanagervirtualbase_p.h | 2 +- src/nfc/qnearfieldtarget.cpp | 3 --- src/nfc/qnearfieldtarget.h | 2 -- src/nfc/qnx/qnxnfcmanager.cpp | 3 +-- src/nfc/qnx/qnxnfcmanager_p.h | 2 +- 15 files changed, 33 insertions(+), 70 deletions(-) (limited to 'src/nfc') diff --git a/src/nfc/doc/src/nfc-cpp.qdoc b/src/nfc/doc/src/nfc-cpp.qdoc index 3e2942d0..b52db05b 100644 --- a/src/nfc/doc/src/nfc-cpp.qdoc +++ b/src/nfc/doc/src/nfc-cpp.qdoc @@ -31,10 +31,9 @@ \qtvariable nfc \title Qt NFC C++ Classes -\brief An API for accessing NFC Forum Tags and communication with NFC Forum Devices. +\brief An API for accessing NFC Forum Tags. -The \l{Qt NFC} C++ API enables an application to access NFC Forum Tags and communication with NFC -Forum Devices. +The \l{Qt NFC} C++ API enables an application to access NFC Forum Tagss. To use the C++ library in your application, add the following configuration option to your \c .pro file: diff --git a/src/nfc/doc/src/nfc-index.qdoc b/src/nfc/doc/src/nfc-index.qdoc index a3ff0392..a353a759 100644 --- a/src/nfc/doc/src/nfc-index.qdoc +++ b/src/nfc/doc/src/nfc-index.qdoc @@ -36,8 +36,7 @@ devices are touched together. The NFC API provides APIs for interacting with NFC Forum Tags and NFC Forum Devices, including target detection and loss, registering NDEF message handlers, reading and writing NDEF messages -on NFC Forum Tags, sending tag specific commands, client and server LLCP sockets for bidirectional -communication between two NFC Forum Devices. +on NFC Forum Tags and sending tag specific commands. \section1 Getting started diff --git a/src/nfc/doc/src/nfc-overview.qdoc b/src/nfc/doc/src/nfc-overview.qdoc index a70972d9..6c479c62 100644 --- a/src/nfc/doc/src/nfc-overview.qdoc +++ b/src/nfc/doc/src/nfc-overview.qdoc @@ -36,18 +36,14 @@ With the Qt NFC API typical use cases are: \list - \li Detect NFC devices entering and leaving communication range. + \li Detect NFC tags entering and leaving communication range. \li Read and write NDEF message on NFC Forum Tags. - \li Create an LLCP server listening for incoming LLCP socket connections. - \li Create an LLCP socket connection to a NFC Forum Device. \li Register an NDEF message handler for a particular content type. \endlist The following sections describe how to use QtNfc C++ classes for the above use cases. -\section1 Detect NFC devices entering and leaving communication range. +\section1 Detect NFC tags entering and leaving communication range. \section1 Read and write NDEF message on NFC Forum Tags. -\section1 Create an LLCP server listening for incoming LLCP socket connections. -\section1 Create an LLCP socket connection to a NFC Forum Device. \section1 Register an NDEF message handler for a particular content type. */ diff --git a/src/nfc/doc/src/nfc-qml.qdoc b/src/nfc/doc/src/nfc-qml.qdoc index 3ed4cc9c..54902112 100644 --- a/src/nfc/doc/src/nfc-qml.qdoc +++ b/src/nfc/doc/src/nfc-qml.qdoc @@ -31,7 +31,7 @@ \qmlmodule QtNfc 5.0 \title Qt NFC QML Types \ingroup qmlmodules -\brief Provides QML types for accessing NFC Forum Tags and Devices +\brief Provides QML types for accessing NFC Forum Tags To use the classes of the module in your application you need the following import statement in your \c .qml file: diff --git a/src/nfc/qnearfieldmanager.cpp b/src/nfc/qnearfieldmanager.cpp index 83e2e63e..5e483343 100644 --- a/src/nfc/qnearfieldmanager.cpp +++ b/src/nfc/qnearfieldmanager.cpp @@ -71,10 +71,7 @@ QT_BEGIN_NAMESPACE NFC Forum devices generally operate as the master in master/slave communications. Some devices are also capable of operating 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. + local NFC device emulates a NFC Forum Tag or Contactless Card. NFC Forum Tags can contain one or more messages in a standardized format. These messages are encapsulated by the QNdefMessage class. Use the registerNdefMessageHandler() functions to @@ -82,9 +79,9 @@ QT_BEGIN_NAMESPACE unregisterNdefMessageHandler() function. Applications can connect to the targetDetected() and targetLost() signals to get notified when - an NFC Forum Device or NFC Forum Tag enters or leaves proximity. Before these signals are - emitted target detection must be started with the startTargetDetection() function, which takes - a parameter to limit the type of device or tags detected. Target detection can be stopped with + an NFC Forum Tag enters or leaves proximity. Before these signals are + emitted target detection must be started with the startTargetDetection() function. + Target detection can be stopped with the stopTargetDetection() function. Before a detected target can be accessed it is necessary to request access rights. This must be done before the target device is touched. The setTargetAccessModes() function is used to set the types of access the application wants to @@ -206,34 +203,17 @@ bool QNearFieldManager::isAvailable() const } /*! - Starts detecting targets of type \a targetTypes. Returns true if target detection is - successfully started; otherwise returns false. - - Causes the targetDetected() signal to be emitted when a target with a type in \a targetTypes is - within proximity. If \a targetTypes is empty targets of all types will be detected. + \fn bool QNearFieldManager::startTargetDetection() + Starts detecting targets and returns true if target detection is + successfully started; otherwise returns false. Causes the targetDetected() signal to be emitted + when a target is within proximity. \sa stopTargetDetection() */ -bool QNearFieldManager::startTargetDetection(const QList &targetTypes) +bool QNearFieldManager::startTargetDetection() { Q_D(QNearFieldManager); - - if (targetTypes.isEmpty()) - return d->startTargetDetection(QList() << QNearFieldTarget::AnyTarget); - else - return d->startTargetDetection(targetTypes); -} - -/*! - \overload - - Starts detecting targets of type \a targetType. Returns true if target detection is - successfully started; otherwise returns false. Causes the targetDetected() signal to be emitted - when a target with the type \a targetType is within proximity. -*/ -bool QNearFieldManager::startTargetDetection(QNearFieldTarget::Type targetType) -{ - return startTargetDetection(QList() << targetType); + return d->startTargetDetection(); } /*! diff --git a/src/nfc/qnearfieldmanager.h b/src/nfc/qnearfieldmanager.h index c608fcd7..b690c2e2 100644 --- a/src/nfc/qnearfieldmanager.h +++ b/src/nfc/qnearfieldmanager.h @@ -75,8 +75,7 @@ public: void setTargetAccessModes(TargetAccessModes accessModes); TargetAccessModes targetAccessModes() const; - bool startTargetDetection(const QList &targetTypes); - bool startTargetDetection(QNearFieldTarget::Type targetType = QNearFieldTarget::AnyTarget); + bool startTargetDetection(); void stopTargetDetection(); template diff --git a/src/nfc/qnearfieldmanager_p.h b/src/nfc/qnearfieldmanager_p.h index 4b6d7df4..24911707 100644 --- a/src/nfc/qnearfieldmanager_p.h +++ b/src/nfc/qnearfieldmanager_p.h @@ -73,10 +73,8 @@ public: return false; } - virtual bool startTargetDetection(const QList &targetTypes) + virtual bool startTargetDetection() { - Q_UNUSED(targetTypes); - return false; } diff --git a/src/nfc/qnearfieldmanager_qnx.cpp b/src/nfc/qnearfieldmanager_qnx.cpp index 696d2d88..e405ecc0 100644 --- a/src/nfc/qnearfieldmanager_qnx.cpp +++ b/src/nfc/qnearfieldmanager_qnx.cpp @@ -70,10 +70,10 @@ bool QNearFieldManagerPrivateImpl::isAvailable() const return QNXNFCManager::instance()->isAvailable(); } -bool QNearFieldManagerPrivateImpl::startTargetDetection(const QList &targetTypes) +bool QNearFieldManagerPrivateImpl::startTargetDetection() { - qQNXNFCDebug() << "STarting targetdetection in nearfieldmanager"; - if (QNXNFCManager::instance()->startTargetDetection(targetTypes)) { + qQNXNFCDebug() << "Starting targetdetection in nearfieldmanager"; + if (QNXNFCManager::instance()->startTargetDetection()) { connect(QNXNFCManager::instance(), SIGNAL(targetDetected(QNearFieldTarget *, const QList&)), this, SLOT(newTarget(QNearFieldTarget *, const QList&))); return true; diff --git a/src/nfc/qnearfieldmanager_qnx_p.h b/src/nfc/qnearfieldmanager_qnx_p.h index 37aeba95..323f85b8 100644 --- a/src/nfc/qnearfieldmanager_qnx_p.h +++ b/src/nfc/qnearfieldmanager_qnx_p.h @@ -60,7 +60,7 @@ public: bool isAvailable() const; - bool startTargetDetection(const QList &targetTypes); + bool startTargetDetection(); void stopTargetDetection(); diff --git a/src/nfc/qnearfieldmanagervirtualbase.cpp b/src/nfc/qnearfieldmanagervirtualbase.cpp index ec3e778d..115a94d6 100644 --- a/src/nfc/qnearfieldmanagervirtualbase.cpp +++ b/src/nfc/qnearfieldmanagervirtualbase.cpp @@ -45,11 +45,11 @@ QT_BEGIN_NAMESPACE -static inline bool matchesTarget(QNearFieldTarget::Type type, - const QList &types) -{ - return types.contains(type) || types.contains(QNearFieldTarget::AnyTarget); -} +//static inline bool matchesTarget(QNearFieldTarget::Type type, +// const QList &types) +//{ +// return types.contains(type) || types.contains(QNearFieldTarget::AnyTarget); +//} QNearFieldManagerPrivateVirtualBase::QNearFieldManagerPrivateVirtualBase() { @@ -59,15 +59,13 @@ QNearFieldManagerPrivateVirtualBase::~QNearFieldManagerPrivateVirtualBase() { } -bool QNearFieldManagerPrivateVirtualBase::startTargetDetection(const QList &targetTypes) +bool QNearFieldManagerPrivateVirtualBase::startTargetDetection() { - m_detectTargetTypes = targetTypes; return true; } void QNearFieldManagerPrivateVirtualBase::stopTargetDetection() { - m_detectTargetTypes.clear(); } int QNearFieldManagerPrivateVirtualBase::getFreeId() @@ -125,8 +123,8 @@ bool QNearFieldManagerPrivateVirtualBase::unregisterNdefMessageHandler(int id) void QNearFieldManagerPrivateVirtualBase::targetActivated(QNearFieldTarget *target) { - if (matchesTarget(target->type(), m_detectTargetTypes)) - emit targetDetected(target); + //if (matchesTarget(target->type(), m_detectTargetTypes)) + emit targetDetected(target); if (target->hasNdefMessage()) { QTlvReader reader(target); diff --git a/src/nfc/qnearfieldmanagervirtualbase_p.h b/src/nfc/qnearfieldmanagervirtualbase_p.h index 93dc517d..804c362f 100644 --- a/src/nfc/qnearfieldmanagervirtualbase_p.h +++ b/src/nfc/qnearfieldmanagervirtualbase_p.h @@ -56,7 +56,7 @@ public: QNearFieldManagerPrivateVirtualBase(); ~QNearFieldManagerPrivateVirtualBase(); - bool startTargetDetection(const QList &targetTypes); + bool startTargetDetection(); void stopTargetDetection(); int registerNdefMessageHandler(QObject *object, const QMetaMethod &method); diff --git a/src/nfc/qnearfieldtarget.cpp b/src/nfc/qnearfieldtarget.cpp index 36d1e8c7..c4f00d6d 100644 --- a/src/nfc/qnearfieldtarget.cpp +++ b/src/nfc/qnearfieldtarget.cpp @@ -88,15 +88,12 @@ QT_BEGIN_NAMESPACE This enum describes the type of tag the target is detected as. - \value AnyTarget This value is only used when registering handlers to indicate that any - compatible target can be used. \value ProprietaryTag An unidentified proprietary target tag. \value NfcTagType1 An NFC tag type 1 target. \value NfcTagType2 An NFC tag type 2 target. \value NfcTagType3 An NFC tag type 3 target. \value NfcTagType4 An NFC tag type 4 target. \value MifareTag A Mifare target. - \value NfcForumDevice An NFC Forum device target. */ /*! diff --git a/src/nfc/qnearfieldtarget.h b/src/nfc/qnearfieldtarget.h index 0cf85400..4e90e275 100644 --- a/src/nfc/qnearfieldtarget.h +++ b/src/nfc/qnearfieldtarget.h @@ -66,14 +66,12 @@ class Q_NFC_EXPORT QNearFieldTarget : public QObject public: enum Type { - AnyTarget, ProprietaryTag, NfcTagType1, NfcTagType2, NfcTagType3, NfcTagType4, MifareTag, - NfcForumDevice }; enum AccessMethod { diff --git a/src/nfc/qnx/qnxnfcmanager.cpp b/src/nfc/qnx/qnxnfcmanager.cpp index 3ecdcfae..bd072c7b 100644 --- a/src/nfc/qnx/qnxnfcmanager.cpp +++ b/src/nfc/qnx/qnxnfcmanager.cpp @@ -386,9 +386,8 @@ void QNXNFCManager::targetLost(unsigned int targetId) } } -bool QNXNFCManager::startTargetDetection(const QList &targetTypes) +bool QNXNFCManager::startTargetDetection() { - Q_UNUSED(targetTypes) qQNXNFCDebug() << "Start target detection for all types"; //TODO handle the target types if (nfc_register_tag_readerwriter(TAG_TYPE_ALL) == NFC_RESULT_SUCCESS) { diff --git a/src/nfc/qnx/qnxnfcmanager_p.h b/src/nfc/qnx/qnxnfcmanager_p.h index 44a652db..70729c41 100644 --- a/src/nfc/qnx/qnxnfcmanager_p.h +++ b/src/nfc/qnx/qnxnfcmanager_p.h @@ -120,7 +120,7 @@ private Q_SLOTS: public: //TODO add a parameter to only detect a special target for now we are detecting all target types - bool startTargetDetection(const QList &targetTypes); + bool startTargetDetection(); void updateNdefFilters(QList,QObject *); -- cgit v1.2.3