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 \ main.cpp \
common/pm3process.cpp \ common/pm3process.cpp \
common/util.cpp \ common/util.cpp \
module/lf.cpp \
module/mifare.cpp \ module/mifare.cpp \
ui/mf_trailerdecoderdialog.cpp \ ui/mf_trailerdecoderdialog.cpp \
ui/mf_sim_simdialog.cpp \ ui/mf_sim_simdialog.cpp \
@ -31,6 +32,7 @@ HEADERS += \
common/myeventfilter.h \ common/myeventfilter.h \
common/pm3process.h \ common/pm3process.h \
common/util.h \ common/util.h \
module/lf.h \
module/mifare.h \ module/mifare.h \
ui/mf_trailerdecoderdialog.h \ ui/mf_trailerdecoderdialog.h \
ui/mf_sim_simdialog.h \ ui/mf_sim_simdialog.h \

@ -53,7 +53,7 @@ public:
QString execCMDWithOutput(const QString& cmd, ReturnTrigger trigger = 10000); QString execCMDWithOutput(const QString& cmd, ReturnTrigger trigger = 10000);
void delay(unsigned int msec); void delay(unsigned int msec);
static ClientType getClientType(); static ClientType getClientType();
static const int rawTabIndex = 1; static const int rawTabIndex = 2;
static bool chooseLanguage(QSettings *guiSettings, QMainWindow *window); static bool chooseLanguage(QSettings *guiSettings, QMainWindow *window);
public slots: public slots:
void processOutput(const QString& output); 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); util = new Util(this);
mifare = new Mifare(ui, util, this); mifare = new Mifare(ui, util, this);
lf = new LF(ui, util, this);
keyEventFilter = new MyEventFilter(QEvent::KeyPress); keyEventFilter = new MyEventFilter(QEvent::KeyPress);
resizeEventFilter = new MyEventFilter(QEvent::Resize); resizeEventFilter = new MyEventFilter(QEvent::Resize);
// hide unused tabs // hide unused tabs
ui->funcTab->removeTab(1); // ui->funcTab->removeTab(1);
ui->funcTab->removeTab(1); ui->funcTab->removeTab(2);
portSearchTimer = new QTimer(this); portSearchTimer = new QTimer(this);
portSearchTimer->setInterval(2000); portSearchTimer->setInterval(2000);
@ -1224,3 +1225,66 @@ void MainWindow::on_Set_Client_keepClientActiveBox_stateChanged(int arg1)
settings->endGroup(); settings->endGroup();
emit setSerialListener(!keepClientActive); 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/myeventfilter.h"
#include "common/pm3process.h" #include "common/pm3process.h"
#include "module/mifare.h" #include "module/mifare.h"
#include "module/lf.h"
#include "common/util.h" #include "common/util.h"
#include "ui/mf_trailerdecoderdialog.h" #include "ui/mf_trailerdecoderdialog.h"
@ -178,6 +179,22 @@ private slots:
void on_Set_Client_keepClientActiveBox_stateChanged(int arg1); 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: private:
Ui::MainWindow* ui; Ui::MainWindow* ui;
QButtonGroup* MFCardTypeBtnGroup; QButtonGroup* MFCardTypeBtnGroup;
@ -208,6 +225,7 @@ private:
QDir* clientWorkingDir; QDir* clientWorkingDir;
Mifare* mifare; Mifare* mifare;
LF* lf;
Util* util; Util* util;
MF_trailerDecoderDialog* decDialog; MF_trailerDecoderDialog* decDialog;
@ -217,6 +235,7 @@ private:
void setTableItem(QTableWidget *widget, int row, int column, const QString& text); void setTableItem(QTableWidget *widget, int row, int column, const QString& text);
void setState(bool st); void setState(bool st);
void saveClientPath(const QString& path); void saveClientPath(const QString& path);
void onLFfreqConfChanged(int value, bool isCustomized);
signals: signals:
void connectPM3(const QString& path, const QStringList args); void connectPM3(const QString& path, const QStringList args);
void reconnectPM3(); void reconnectPM3();

@ -130,7 +130,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>4</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="mifareTab"> <widget class="QWidget" name="mifareTab">
<attribute name="title"> <attribute name="title">
@ -1212,8 +1212,8 @@
<rect> <rect>
<x>10</x> <x>10</x>
<y>10</y> <y>10</y>
<width>121</width> <width>431</width>
<height>211</height> <height>341</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
@ -1240,7 +1240,7 @@
<property name="title"> <property name="title">
<string>Frequency</string> <string>Frequency</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_13"> <layout class="QVBoxLayout" name="verticalLayout_8">
<property name="spacing"> <property name="spacing">
<number>5</number> <number>5</number>
</property> </property>
@ -1257,28 +1257,115 @@
<number>2</number> <number>2</number>
</property> </property>
<item> <item>
<widget class="QRadioButton" name="LF_Conf_freq125kButton"> <layout class="QHBoxLayout" name="horizontalLayout_13">
<property name="sizePolicy"> <item>
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <widget class="QRadioButton" name="LF_Conf_freq125kButton">
<horstretch>0</horstretch> <property name="sizePolicy">
<verstretch>0</verstretch> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
</sizepolicy> <horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>125k</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="LF_Conf_freq134kButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>134k</string>
</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>
<property name="text"> <property name="maximum">
<string>125k</string> <number>255</number>
</property>
<property name="value">
<number>95</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="LF_Conf_freq134kButton"> <widget class="QLabel" name="label_22">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>134k</string> <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> </property>
</widget> </widget>
</item> </item>
@ -1286,60 +1373,98 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QHBoxLayout" name="horizontalLayout_20">
<item row="0" column="0"> <item>
<widget class="QLabel" name="label_6"> <layout class="QFormLayout" name="formLayout">
<property name="text"> <item row="0" column="0">
<string>BitRate:</string> <widget class="QLabel" name="label_6">
</property> <property name="text">
</widget> <string>Bit per sample:</string>
</item> </property>
<item row="1" column="0"> </widget>
<widget class="QLabel" name="label_7"> </item>
<property name="text"> <item row="1" column="0">
<string>Decimation:</string> <widget class="QLabel" name="label_7">
</property> <property name="text">
</widget> <string>Decimation:</string>
</item> </property>
<item row="1" column="1"> </widget>
<widget class="QSpinBox" name="LF_Conf_decimationBox"/> </item>
</item> <item row="1" column="1">
<item row="2" column="0"> <widget class="QSpinBox" name="LF_Conf_decimationBox">
<widget class="QLabel" name="label_8"> <property name="minimum">
<property name="text"> <number>1</number>
<string>Averaging:</string> </property>
</property> <property name="maximum">
</widget> <number>8</number>
</item> </property>
<item row="2" column="1"> </widget>
<widget class="QCheckBox" name="LF_Conf_averagingBox"> </item>
<property name="text"> <item row="2" column="0">
<string/> <widget class="QLabel" name="label_8">
</property> <property name="text">
</widget> <string>Averaging:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="LF_Conf_averagingBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Trigger threshold:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<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>Samples to skip:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="LF_Conf_skipsBox"/>
</item>
<item row="0" column="1">
<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>
<item row="3" column="0"> <item>
<widget class="QLabel" name="label_9"> <spacer name="horizontalSpacer_12">
<property name="text"> <property name="orientation">
<string>Threshold:</string> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
</item> <size>
<item row="3" column="1"> <width>40</width>
<widget class="QSpinBox" name="LF_Conf_thresholdBox"/> <height>20</height>
</item> </size>
<item row="4" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Skips:</string>
</property> </property>
</widget> </spacer>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="LF_Conf_skipsBox"/>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="LF_Conf_bitRateBox"/>
</item> </item>
</layout> </layout>
</item> </item>
@ -1398,6 +1523,188 @@
</item> </item>
</layout> </layout>
</item> </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> </layout>
</widget> </widget>
</widget> </widget>

Loading…
Cancel
Save