summaryrefslogtreecommitdiffstats
path: root/src/nfc/qnearfieldtarget_emulator.cpp
diff options
context:
space:
mode:
authorLars Schmertmann <Lars.Schmertmann@governikus.de>2016-12-25 19:28:52 +0100
committerLars Schmertmann <lars.schmertmann@governikus.de>2017-01-14 11:19:12 +0000
commit44401721f66bdd72da197a14241a66fdb3d11cf4 (patch)
tree4f26e73d752099121f72746127103d9d0e95470c /src/nfc/qnearfieldtarget_emulator.cpp
parentf9e85fb10a0560563e3106c4e8f6e269ece67659 (diff)
Avoid code duplication by using checksum calculation from qtbase
Since qtbase supports checksum calculation defined in ITU-V.41 an own implementation is not longer needed. Change-Id: I0f62c872b4fb517493ba43a9bb7a6d35481fa40d Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/nfc/qnearfieldtarget_emulator.cpp')
-rw-r--r--src/nfc/qnearfieldtarget_emulator.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/nfc/qnearfieldtarget_emulator.cpp b/src/nfc/qnearfieldtarget_emulator.cpp
index 96462b0d..29b1f74d 100644
--- a/src/nfc/qnearfieldtarget_emulator.cpp
+++ b/src/nfc/qnearfieldtarget_emulator.cpp
@@ -40,11 +40,12 @@
#include "qnearfieldtarget_emulator_p.h"
#include "qnearfieldtarget_p.h"
-#include <QtCore/QDirIterator>
-#include <QtCore/QSettings>
-#include <QtCore/QMutex>
+#include <QtCore/QByteArray>
#include <QtCore/QCoreApplication>
#include <QtCore/QDateTime>
+#include <QtCore/QDirIterator>
+#include <QtCore/QMutex>
+#include <QtCore/QSettings>
QT_BEGIN_NAMESPACE
@@ -87,7 +88,7 @@ QNearFieldTarget::RequestId TagType1::sendCommand(const QByteArray &command)
return id;
}
- quint16 crc = qNfcChecksum(command.constData(), command.length());
+ quint16 crc = qChecksum(command.constData(), command.length(), Qt::ChecksumItuV41);
QByteArray response = m_tag->processCommand(command + char(crc & 0xff) + char(crc >> 8));
@@ -99,7 +100,7 @@ QNearFieldTarget::RequestId TagType1::sendCommand(const QByteArray &command)
}
// check crc
- if (qNfcChecksum(response.constData(), response.length()) != 0) {
+ if (qChecksum(response.constData(), response.length(), Qt::ChecksumItuV41) != 0) {
QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
Q_ARG(QNearFieldTarget::Error, ChecksumMismatchError),
Q_ARG(QNearFieldTarget::RequestId, id));
@@ -157,7 +158,7 @@ QNearFieldTarget::RequestId TagType2::sendCommand(const QByteArray &command)
return id;
}
- quint16 crc = qNfcChecksum(command.constData(), command.length());
+ quint16 crc = qChecksum(command.constData(), command.length(), Qt::ChecksumItuV41);
QByteArray response = m_tag->processCommand(command + char(crc & 0xff) + char(crc >> 8));
@@ -166,7 +167,7 @@ QNearFieldTarget::RequestId TagType2::sendCommand(const QByteArray &command)
if (response.length() > 1) {
// check crc
- if (qNfcChecksum(response.constData(), response.length()) != 0) {
+ if (qChecksum(response.constData(), response.length(), Qt::ChecksumItuV41) != 0) {
QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
Q_ARG(QNearFieldTarget::Error, ChecksumMismatchError),
Q_ARG(QNearFieldTarget::RequestId, id));