LF: support read(), sniff(), search() and tune()

pull/33/head
wh201906 4 years ago
parent c3aafc3d31
commit ae9e4d1a4f

@ -20,6 +20,7 @@ SOURCES += \
main.cpp \
common/pm3process.cpp \
common/util.cpp \
module/lf.cpp \
module/mifare.cpp \
ui/mf_trailerdecoderdialog.cpp \
ui/mf_sim_simdialog.cpp \
@ -31,6 +32,7 @@ HEADERS += \
common/myeventfilter.h \
common/pm3process.h \
common/util.h \
module/lf.h \
module/mifare.h \
ui/mf_trailerdecoderdialog.h \
ui/mf_sim_simdialog.h \

@ -53,7 +53,7 @@ public:
QString execCMDWithOutput(const QString& cmd, ReturnTrigger trigger = 10000);
void delay(unsigned int msec);
static ClientType getClientType();
static const int rawTabIndex = 1;
static const int rawTabIndex = 2;
static bool chooseLanguage(QSettings *guiSettings, QMainWindow *window);
public slots:
void processOutput(const QString& output);

@ -0,0 +1,47 @@
#include "lf.h"
LF::LF(Ui::MainWindow *ui, Util *addr, QWidget *parent): QObject(parent)
{
this->parent = parent;
util = addr;
this->ui = ui;
}
void LF::read()
{
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
util->execCMD("lf read");
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
util->execCMD("lf read -v");
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
util->execCMD("data plot");
}
void LF::sniff()
{
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
util->execCMD("lf snoop");
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
util->execCMD("lf sniff -v");
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
util->execCMD("data plot");
}
void LF::search()
{
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
util->execCMD("lf search u");
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
util->execCMD("lf search -u");
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
}
void LF::tune()
{
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
util->execCMD("hw tune l");
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
util->execCMD("lf tune"); // TODO: if freq is set, append it as a parameter
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
}

@ -0,0 +1,28 @@
#ifndef LF_H
#define LF_H
#include <QObject>
#include "common/util.h"
#include "ui_mainwindow.h"
class LF : public QObject
{
Q_OBJECT
public:
explicit LF(Ui::MainWindow *ui, Util *addr, QWidget *parent = nullptr);
void read();
void sniff();
void search();
void tune();
private:
QWidget* parent;
Ui::MainWindow *ui;
Util* util;
signals:
};
#endif // LF_H

@ -32,13 +32,14 @@ MainWindow::MainWindow(QWidget *parent):
util = new Util(this);
mifare = new Mifare(ui, util, this);
lf = new LF(ui, util, this);
keyEventFilter = new MyEventFilter(QEvent::KeyPress);
resizeEventFilter = new MyEventFilter(QEvent::Resize);
// hide unused tabs
ui->funcTab->removeTab(1);
ui->funcTab->removeTab(1);
// ui->funcTab->removeTab(1);
ui->funcTab->removeTab(2);
portSearchTimer = new QTimer(this);
portSearchTimer->setInterval(2000);
@ -1224,3 +1225,66 @@ void MainWindow::on_Set_Client_keepClientActiveBox_stateChanged(int arg1)
settings->endGroup();
emit setSerialListener(!keepClientActive);
}
void MainWindow::on_LF_Conf_freqSlider_valueChanged(int value)
{
onLFfreqConfChanged(value, true);
}
void MainWindow::onLFfreqConfChanged(int value, bool isCustomized)
{
ui->LF_Conf_freqDivisorBox->blockSignals(true);
ui->LF_Conf_freqSlider->blockSignals(true);
if(isCustomized)
ui->LF_Conf_freqOtherButton->setChecked(true);
ui->LF_Conf_freqLabel->setText(QString("Actural Freq: %1kHz").arg(12000.0 / (value + 1.0), 0, 'f', 3));
ui->LF_Conf_freqDivisorBox->setValue(value);
ui->LF_Conf_freqSlider->setValue(value);
ui->LF_Conf_freqDivisorBox->blockSignals(false);
ui->LF_Conf_freqSlider->blockSignals(false);
}
void MainWindow::on_LF_Conf_freqDivisorBox_valueChanged(int arg1)
{
onLFfreqConfChanged(arg1, true);
}
void MainWindow::on_LF_Conf_freq125kButton_clicked()
{
onLFfreqConfChanged(95, false);
}
void MainWindow::on_LF_Conf_freq134kButton_clicked()
{
onLFfreqConfChanged(88, false);
}
void MainWindow::on_LF_Op_searchButton_clicked()
{
setState(false);
lf->search();
setState(true);
}
void MainWindow::on_LF_Op_readButton_clicked()
{
setState(false);
lf->read();
setState(true);
}
void MainWindow::on_LF_Op_tuneButton_clicked()
{
setState(false);
lf->tune();
setState(true);
}
void MainWindow::on_LF_Op_sniffButton_clicked()
{
setState(false);
lf->sniff();
setState(true);
}

@ -28,6 +28,7 @@
#include "common/myeventfilter.h"
#include "common/pm3process.h"
#include "module/mifare.h"
#include "module/lf.h"
#include "common/util.h"
#include "ui/mf_trailerdecoderdialog.h"
@ -178,6 +179,22 @@ private slots:
void on_Set_Client_keepClientActiveBox_stateChanged(int arg1);
void on_LF_Conf_freqSlider_valueChanged(int value);
void on_LF_Conf_freqDivisorBox_valueChanged(int arg1);
void on_LF_Conf_freq125kButton_clicked();
void on_LF_Conf_freq134kButton_clicked();
void on_LF_Op_searchButton_clicked();
void on_LF_Op_readButton_clicked();
void on_LF_Op_tuneButton_clicked();
void on_LF_Op_sniffButton_clicked();
private:
Ui::MainWindow* ui;
QButtonGroup* MFCardTypeBtnGroup;
@ -208,6 +225,7 @@ private:
QDir* clientWorkingDir;
Mifare* mifare;
LF* lf;
Util* util;
MF_trailerDecoderDialog* decDialog;
@ -217,6 +235,7 @@ private:
void setTableItem(QTableWidget *widget, int row, int column, const QString& text);
void setState(bool st);
void saveClientPath(const QString& path);
void onLFfreqConfChanged(int value, bool isCustomized);
signals:
void connectPM3(const QString& path, const QStringList args);
void reconnectPM3();

@ -130,7 +130,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>4</number>
<number>1</number>
</property>
<widget class="QWidget" name="mifareTab">
<attribute name="title">
@ -1212,8 +1212,8 @@
<rect>
<x>10</x>
<y>10</y>
<width>121</width>
<height>211</height>
<width>431</width>
<height>341</height>
</rect>
</property>
<property name="title">
@ -1240,7 +1240,7 @@
<property name="title">
<string>Frequency</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="spacing">
<number>5</number>
</property>
@ -1256,6 +1256,8 @@
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QRadioButton" name="LF_Conf_freq125kButton">
<property name="sizePolicy">
@ -1267,6 +1269,9 @@
<property name="text">
<string>125k</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -1282,15 +1287,99 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="LF_Conf_freqOtherButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>other</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_23">
<property name="text">
<string>Divisor:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="LF_Conf_freqDivisorBox">
<property name="minimum">
<number>19</number>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>95</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="LF_Conf_freqLabel">
<property name="text">
<string>Actural Freq: 125.000kHz</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QSlider" name="LF_Conf_freqSlider">
<property name="minimum">
<number>19</number>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>95</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_22">
<property name="text">
<string>Note:
You might need a modified LF antenna if the freq is not 125k/134k.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>BitRate:</string>
<string>Bit per sample:</string>
</property>
</widget>
</item>
@ -1302,7 +1391,14 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="LF_Conf_decimationBox"/>
<widget class="QSpinBox" name="LF_Conf_decimationBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>8</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
@ -1321,17 +1417,21 @@
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Threshold:</string>
<string>Trigger threshold:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="LF_Conf_thresholdBox"/>
<widget class="QSpinBox" name="LF_Conf_thresholdBox">
<property name="maximum">
<number>128</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Skips:</string>
<string>Samples to skip:</string>
</property>
</widget>
</item>
@ -1339,7 +1439,32 @@
<widget class="QSpinBox" name="LF_Conf_skipsBox"/>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="LF_Conf_bitRateBox"/>
<widget class="QSpinBox" name="LF_Conf_bitRateBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>8</number>
</property>
<property name="value">
<number>8</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
@ -1398,6 +1523,188 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>500</x>
<y>30</y>
<width>311</width>
<height>361</height>
</rect>
</property>
<property name="title">
<string>LF Operation</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_27">
<item>
<widget class="QPushButton" name="LF_Op_searchButton">
<property name="text">
<string>Search</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_24">
<property name="text">
<string>Read and search for valid known tag.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="QPushButton" name="LF_Op_readButton">
<property name="text">
<string>Read</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_25">
<property name="text">
<string>Sniff low frequency signal with LF field ON.
Use this to get raw data from a tag.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_26">
<item>
<widget class="QPushButton" name="LF_Op_tuneButton">
<property name="text">
<string>Tune</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_26">
<property name="text">
<string>Measure LF antenna tuning.
If the antenna voltage has a obvious drop after putting card on the antenna, it is likely that the tag is a LF tag.
On Iceman/RRG repo, press the button on PM3 to stop measuring</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_25">
<item>
<widget class="QPushButton" name="LF_Op_sniffButton">
<property name="text">
<string>Sniff</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_14">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_27">
<property name="text">
<string>Sniff low frequency signal wit LF field OFF.
Use this to get raw data from a reader
or the communication between a tag and a reader.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>

Loading…
Cancel
Save