LF: Support write LF config

When setting LF freq, the "lf config" and "hw setlfdivisor" will both be called.
Change some UI
pull/33/head
wh201906 4 years ago
parent 466cd0ecc1
commit 15538a9892

@ -1,5 +1,7 @@
#include "lf.h" #include "lf.h"
const LF::Config LF::defaultConfig;
LF::LF(Ui::MainWindow *ui, Util *addr, QWidget *parent): QObject(parent) LF::LF(Ui::MainWindow *ui, Util *addr, QWidget *parent): QObject(parent)
{ {
this->parent = parent; this->parent = parent;
@ -7,6 +9,7 @@ LF::LF(Ui::MainWindow *ui, Util *addr, QWidget *parent): QObject(parent)
this->ui = ui; this->ui = ui;
configPattern = new QRegularExpression("(\\d+)|Yes|No"); configPattern = new QRegularExpression("(\\d+)|Yes|No");
currConfig = defaultConfig;
} }
void LF::read() void LF::read()
@ -43,7 +46,7 @@ void LF::tune()
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL) if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
util->execCMD("hw tune l"); util->execCMD("hw tune l");
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN) else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
util->execCMD("lf tune"); // TODO: if freq is set, append it as a parameter util->execCMD("lf tune --divisor " + QString::number(currConfig.divisor));
Util::gotoRawTab(); Util::gotoRawTab();
} }
@ -108,9 +111,39 @@ void LF::getConfig()
syncWithUI(); syncWithUI();
} }
void LF::setConfig() void LF::setConfig(LF::Config config)
{
currConfig = config;
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
{ {
util->execCMDWithOutput(QString("lf config")
+ " q " + QString::number(currConfig.divisor)
+ " b " + QString::number(currConfig.bitPerSample)
+ " d " + QString::number(currConfig.decimation)
+ " a " + QString(currConfig.averaging ? "1" : "0")
+ " t " + QString::number(currConfig.triggerThreshold)
+ " s " + QString::number(currConfig.samplesToSkip),
500);
util->execCMDWithOutput("hw setlfdivisor " + QString::number(currConfig.divisor), 500);
}
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
{
util->execCMDWithOutput(QString("lf config")
+ " -a " + QString(currConfig.averaging ? "1" : "0")
+ " -b " + QString::number(currConfig.bitPerSample)
+ " --dec " + QString::number(currConfig.decimation)
+ " --divisor " + QString::number(currConfig.divisor)
+ " -s " + QString::number(currConfig.samplesToSkip)
+ " -t " + QString::number(currConfig.triggerThreshold),
500);
util->execCMDWithOutput("hw setlfdivisor -d " + QString::number(currConfig.divisor), 500);
}
}
void LF::resetConfig()
{
setConfig(defaultConfig);
getConfig();
} }
float LF::divisor2Freq(uint8_t divisor) float LF::divisor2Freq(uint8_t divisor)
@ -125,7 +158,7 @@ uint8_t LF::freq2Divisor(float freq)
void LF::syncWithUI() void LF::syncWithUI()
{ {
ui->LF_Conf_freqDivisorBox->setValue(currConfig.divisor); ui->LF_Conf_freqDivisorBox->setValue(currConfig.divisor); // will trigger valueChanged()
ui->LF_Conf_bitPerSampleBox->setValue(currConfig.bitPerSample); ui->LF_Conf_bitPerSampleBox->setValue(currConfig.bitPerSample);
ui->LF_Conf_decimationBox->setValue(currConfig.decimation); ui->LF_Conf_decimationBox->setValue(currConfig.decimation);
ui->LF_Conf_averagingBox->setChecked(currConfig.averaging); ui->LF_Conf_averagingBox->setChecked(currConfig.averaging);

@ -22,14 +22,26 @@ public:
uint16_t samplesToSkip; uint16_t samplesToSkip;
}; };
static constexpr Config defaultConfig =
{
95,
8,
1,
true,
0,
0
};
void read(); void read();
void sniff(); void sniff();
void search(); void search();
void tune(); void tune();
void getConfig(); void getConfig();
void setConfig(); void setConfig(LF::Config config);
void resetConfig();
static float divisor2Freq(uint8_t divisor); static float divisor2Freq(uint8_t divisor);
static uint8_t freq2Divisor(float freq); static uint8_t freq2Divisor(float freq);
private: private:
QWidget* parent; QWidget* parent;
Ui::MainWindow *ui; Ui::MainWindow *ui;

@ -1337,5 +1337,29 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
void MainWindow::on_LF_Conf_getButton_clicked() void MainWindow::on_LF_Conf_getButton_clicked()
{ {
setState(false);
lf->getConfig(); lf->getConfig();
setState(true);
}
void MainWindow::on_LF_Conf_setButton_clicked()
{
LF::Config config;
setState(false);
config.divisor = ui->LF_Conf_freqDivisorBox->value();
config.bitPerSample = ui->LF_Conf_bitPerSampleBox->value();
config.decimation = ui->LF_Conf_decimationBox->value();
config.averaging = ui->LF_Conf_averagingBox->isChecked();
config.triggerThreshold = ui->LF_Conf_thresholdBox->value();
config.samplesToSkip = ui->LF_Conf_skipsBox->value();
lf->setConfig(config);
Util::gotoRawTab();
setState(true);
}
void MainWindow::on_LF_Conf_resetButton_clicked()
{
setState(false);
lf->resetConfig();
setState(true);
} }

@ -199,6 +199,10 @@ private slots:
void on_LF_Conf_getButton_clicked(); void on_LF_Conf_getButton_clicked();
void on_LF_Conf_setButton_clicked();
void on_LF_Conf_resetButton_clicked();
private: private:
Ui::MainWindow* ui; Ui::MainWindow* ui;
QButtonGroup* MFCardTypeBtnGroup; QButtonGroup* MFCardTypeBtnGroup;

@ -21,7 +21,7 @@
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -136,7 +136,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>4</number>
</property> </property>
<widget class="QWidget" name="mifareTab"> <widget class="QWidget" name="mifareTab">
<attribute name="title"> <attribute name="title">
@ -1211,17 +1211,13 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<attribute name="title"> <attribute name="title">
<string>LF/Data</string> <string>LF</string>
</attribute> </attribute>
<layout class="QHBoxLayout" name="horizontalLayout_22">
<item>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QGroupBox" name="LF_configGroupBox"> <widget class="QGroupBox" name="LF_configGroupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>431</width>
<height>341</height>
</rect>
</property>
<property name="title"> <property name="title">
<string>LF Config</string> <string>LF Config</string>
</property> </property>
@ -1338,12 +1334,6 @@
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
@ -1368,7 +1358,8 @@
<widget class="QLabel" name="label_22"> <widget class="QLabel" name="label_22">
<property name="text"> <property name="text">
<string>Note: <string>Note:
You might need a modified LF antenna if the freq is not 125k/134k.</string> You might need a modified LF antenna if the freq is not 125k/134k.
When setting the freq, the &quot;hw setlfdivisor&quot; will also be called.</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
@ -1380,6 +1371,19 @@ You might need a modified LF antenna if the freq is not 125k/134k.</string>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_20"> <layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<spacer name="horizontalSpacer_18">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="0" column="0"> <item row="0" column="0">
@ -1480,6 +1484,19 @@ You might need a modified LF antenna if the freq is not 125k/134k.</string>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_14"> <layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QPushButton" name="LF_Conf_getButton"> <widget class="QPushButton" name="LF_Conf_getButton">
<property name="sizePolicy"> <property name="sizePolicy">
@ -1499,19 +1516,6 @@ You might need a modified LF antenna if the freq is not 125k/134k.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QPushButton" name="LF_Conf_setButton"> <widget class="QPushButton" name="LF_Conf_setButton">
<property name="sizePolicy"> <property name="sizePolicy">
@ -1531,38 +1535,56 @@ You might need a modified LF antenna if the freq is not 125k/134k.</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item>
<widget class="QPushButton" name="LF_Conf_resetButton">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_4"> <spacer name="horizontalSpacer_8">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>40</width>
<height>40</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox"> <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"> <property name="title">
<string>LF Operation</string> <string>LF Operation</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_13"> <layout class="QVBoxLayout" name="verticalLayout_13">
<property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_27"> <layout class="QHBoxLayout" name="horizontalLayout_27">
<item>
<layout class="QVBoxLayout" name="verticalLayout_15">
<item> <item>
<widget class="QPushButton" name="LF_Op_searchButton"> <widget class="QPushButton" name="LF_Op_searchButton">
<property name="text"> <property name="text">
@ -1571,15 +1593,12 @@ You might need a modified LF antenna if the freq is not 125k/134k.</string>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_16"> <spacer name="verticalSpacer_6">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeType">
<size> <enum>QSizePolicy::Expanding</enum>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</spacer> </spacer>
</item> </item>
@ -1587,16 +1606,36 @@ You might need a modified LF antenna if the freq is not 125k/134k.</string>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_24"> <widget class="QLabel" name="label_24">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Read and search for valid known tag.</string> <string>Read and search for valid known tag.</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_21"> <layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<layout class="QVBoxLayout" name="verticalLayout_18">
<item> <item>
<widget class="QPushButton" name="LF_Op_readButton"> <widget class="QPushButton" name="LF_Op_readButton">
<property name="text"> <property name="text">
@ -1605,15 +1644,12 @@ You might need a modified LF antenna if the freq is not 125k/134k.</string>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_13"> <spacer name="verticalSpacer_9">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeType">
<size> <enum>QSizePolicy::Expanding</enum>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</spacer> </spacer>
</item> </item>
@ -1621,17 +1657,37 @@ You might need a modified LF antenna if the freq is not 125k/134k.</string>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_25"> <widget class="QLabel" name="label_25">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Sniff low frequency signal with LF field ON. <string>Sniff low frequency signal with LF field ON.
Use this to get raw data from a tag.</string> Use this to get raw data from a tag.</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item>
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_26"> <layout class="QHBoxLayout" name="horizontalLayout_26">
<item>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item> <item>
<widget class="QPushButton" name="LF_Op_tuneButton"> <widget class="QPushButton" name="LF_Op_tuneButton">
<property name="text"> <property name="text">
@ -1640,15 +1696,12 @@ Use this to get raw data from a tag.</string>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_15"> <spacer name="verticalSpacer_7">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeType">
<size> <enum>QSizePolicy::Expanding</enum>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</spacer> </spacer>
</item> </item>
@ -1656,18 +1709,38 @@ Use this to get raw data from a tag.</string>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_26"> <widget class="QLabel" name="label_26">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Measure LF antenna tuning. <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. 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> On Iceman/RRG repo, press the button on PM3 to stop measuring</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item>
<widget class="Line" name="line_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_25"> <layout class="QHBoxLayout" name="horizontalLayout_25">
<item>
<layout class="QVBoxLayout" name="verticalLayout_17">
<item> <item>
<widget class="QPushButton" name="LF_Op_sniffButton"> <widget class="QPushButton" name="LF_Op_sniffButton">
<property name="text"> <property name="text">
@ -1676,15 +1749,12 @@ On Iceman/RRG repo, press the button on PM3 to stop measuring</string>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_14"> <spacer name="verticalSpacer_8">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeType">
<size> <enum>QSizePolicy::Expanding</enum>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</spacer> </spacer>
</item> </item>
@ -1692,31 +1762,62 @@ On Iceman/RRG repo, press the button on PM3 to stop measuring</string>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_27"> <widget class="QLabel" name="label_27">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Sniff low frequency signal with LF field OFF. <string>Sniff low frequency signal with LF field OFF.
Use this to get raw data from a reader Use this to get raw data from a reader
or the communication between a tag and a reader.</string> or the communication between a tag and a reader.</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_6"> <spacer name="verticalSpacer_4">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>0</width>
<height>40</height> <height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_19">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>502</width>
<height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</widget>
</widget> </widget>
<widget class="QWidget" name="t55xxTab"> <widget class="QWidget" name="t55xxTab">
<attribute name="title"> <attribute name="title">
@ -2093,12 +2194,6 @@ or &quot;-p &lt;port&gt; -f&quot;</string>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
@ -2111,12 +2206,6 @@ or &quot;-p &lt;port&gt; -f&quot;</string>
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
@ -2126,12 +2215,6 @@ or &quot;-p &lt;port&gt; -f&quot;</string>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer> </spacer>
</item> </item>
</layout> </layout>

Loading…
Cancel
Save