summaryrefslogtreecommitdiffstats
path: root/src/nfc
diff options
context:
space:
mode:
authorFabian Bumberger <fbumberger@rim.com>2013-07-06 06:37:09 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-07-10 09:03:46 +0200
commit4fca8de918b4ae7b8b745f60847e28f948089445 (patch)
tree73bdc3791e04a87af33f87644ea1bbc281957969 /src/nfc
parentdb2fc63155e8c821f5c6c751a33974cab9cb4ed3 (diff)
Fixing QNearFieldTarget::waitForRequestCompleted
The current implementation is not waiting at all. Adjust the waiting time for the tagtype1 unit test to avoid 30min runtime. Change-Id: Ied9cff72456b964af9224362f47113a7e2c792ae Reviewed-by: Fabian Bumberger <fbumberger@rim.com> Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com> Reviewed-by: Alex <alexander.blasche@digia.com>
Diffstat (limited to 'src/nfc')
-rw-r--r--src/nfc/qnearfieldtagtype2.cpp20
-rw-r--r--src/nfc/qnearfieldtagtype2.h2
-rw-r--r--src/nfc/qnearfieldtarget.cpp17
3 files changed, 14 insertions, 25 deletions
diff --git a/src/nfc/qnearfieldtagtype2.cpp b/src/nfc/qnearfieldtagtype2.cpp
index 41b228bf..91ed9cca 100644
--- a/src/nfc/qnearfieldtagtype2.cpp
+++ b/src/nfc/qnearfieldtagtype2.cpp
@@ -262,26 +262,6 @@ QNearFieldTarget::RequestId QNearFieldTagType2::selectSector(quint8 sector)
/*!
\reimp
*/
-bool QNearFieldTagType2::waitForRequestCompleted(const RequestId &id, int msecs)
-{
- Q_D(QNearFieldTagType2);
-
- QTime timer;
- timer.start();
- while (d->m_pendingSectorSelectCommands.contains(id)) {
- QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents, 1);
-
- // detect passive ack
- if (timer.elapsed() >= 10)
- break;
- }
-
- return QNearFieldTarget::waitForRequestCompleted(id, msecs);
-}
-
-/*!
- \reimp
-*/
bool QNearFieldTagType2::handleResponse(const QNearFieldTarget::RequestId &id,
const QByteArray &response)
{
diff --git a/src/nfc/qnearfieldtagtype2.h b/src/nfc/qnearfieldtagtype2.h
index e5476745..6b8c2315 100644
--- a/src/nfc/qnearfieldtagtype2.h
+++ b/src/nfc/qnearfieldtagtype2.h
@@ -71,8 +71,6 @@ public:
virtual RequestId writeBlock(quint8 blockAddress, const QByteArray &data);
virtual RequestId selectSector(quint8 sector);
- bool waitForRequestCompleted(const RequestId &id, int msecs = 5000);
-
void timerEvent(QTimerEvent *event);
protected:
diff --git a/src/nfc/qnearfieldtarget.cpp b/src/nfc/qnearfieldtarget.cpp
index 89f76f99..f95d2ee1 100644
--- a/src/nfc/qnearfieldtarget.cpp
+++ b/src/nfc/qnearfieldtarget.cpp
@@ -49,6 +49,9 @@
#include <QtCore/QDebug>
+#include <QTime>
+#include <QCoreApplication>
+
QT_BEGIN_NAMESPACE_NFC
/*!
@@ -396,11 +399,19 @@ QNearFieldTarget::RequestId QNearFieldTarget::sendCommands(const QList<QByteArra
*/
bool QNearFieldTarget::waitForRequestCompleted(const RequestId &id, int msecs)
{
- Q_UNUSED(msecs);
-
Q_D(QNearFieldTarget);
- return d->m_decodedResponses.contains(id);
+ QTime timer;
+ timer.start();
+
+ do {
+ if (d->m_decodedResponses.contains(id))
+ return true;
+ else
+ QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents, 1);
+ } while (timer.elapsed() <= msecs);
+
+ return false;
}
/*!