refactor: lf config renames

This commit is contained in:
douniwan5788 2024-08-27 22:38:51 +08:00
commit 112caec054
7 changed files with 15 additions and 16 deletions

View file

@ -40,7 +40,7 @@ Default LF config is set to:
verbose = YES verbose = YES
*/ */
static sample_config def_config = { static const sample_config def_config = {
.decimation = 1, .decimation = 1,
.bits_per_sample = 8, .bits_per_sample = 8,
.averaging = 1, .averaging = 1,

View file

@ -541,7 +541,7 @@ int CmdFlexdemod(const char *Cmd) {
* this function will save a copy of the current lf config value, and set config to default values. * this function will save a copy of the current lf config value, and set config to default values.
* *
*/ */
int lf_config_savereset(sample_config *config) { int lf_resetconfig(sample_config *config) {
if (config == NULL) { if (config == NULL) {
return PM3_EINVARG; return PM3_EINVARG;
@ -565,7 +565,7 @@ int lf_config_savereset(sample_config *config) {
.verbose = false, .verbose = false,
}; };
res = lf_config(&def_config); res = lf_setconfig(&def_config);
if (res != PM3_SUCCESS) { if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "failed to reset LF configuration to default values"); PrintAndLogEx(ERR, "failed to reset LF configuration to default values");
return res; return res;
@ -595,7 +595,7 @@ int lf_getconfig(sample_config *config) {
return PM3_SUCCESS; return PM3_SUCCESS;
} }
int lf_config(sample_config *config) { int lf_setconfig(sample_config *config) {
if (!g_session.pm3_present) return PM3_ENOTTY; if (!g_session.pm3_present) return PM3_ENOTTY;
clearCommandBuffer(); clearCommandBuffer();
@ -656,7 +656,7 @@ int CmdLFConfig(const char *Cmd) {
// if called with no params, just print the device config // if called with no params, just print the device config
if (strlen(Cmd) == 0) { if (strlen(Cmd) == 0) {
return lf_config(NULL); return lf_setconfig(NULL);
} }
if (use_125 + use_134 > 1) { if (use_125 + use_134 > 1) {
@ -729,7 +729,7 @@ int CmdLFConfig(const char *Cmd) {
config.trigger_threshold = 0; config.trigger_threshold = 0;
} }
return lf_config(&config); return lf_setconfig(&config);
} }
static int lf_read_internal(bool realtime, bool verbose, uint64_t samples) { static int lf_read_internal(bool realtime, bool verbose, uint64_t samples) {

View file

@ -42,10 +42,10 @@ int CmdLFfind(const char *Cmd);
int lf_read(bool verbose, uint64_t samples); int lf_read(bool verbose, uint64_t samples);
int lf_sniff(bool realtime, bool verbose, uint64_t samples); int lf_sniff(bool realtime, bool verbose, uint64_t samples);
int lf_config(sample_config *config); int lf_setconfig(sample_config *config);
int lf_getconfig(sample_config *config); int lf_getconfig(sample_config *config);
int lf_resetconfig(sample_config *config);
int lfsim_upload_gb(void); int lfsim_upload_gb(void);
int lfsim_wait_check(uint32_t cmd); int lfsim_wait_check(uint32_t cmd);
int lf_config_savereset(sample_config *config);
#endif #endif

View file

@ -671,14 +671,14 @@ static int CmdFdxBReader(const char *Cmd) {
if (curr_div == LF_DIVISOR_125) { if (curr_div == LF_DIVISOR_125) {
config.divisor = LF_DIVISOR_134; config.divisor = LF_DIVISOR_134;
res = lf_config(&config); res = lf_setconfig(&config);
if (res != PM3_SUCCESS) { if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "failed to change to 134 KHz LF configuration"); PrintAndLogEx(ERR, "failed to change to 134 KHz LF configuration");
return res; return res;
} }
} else { } else {
config.divisor = LF_DIVISOR_125; config.divisor = LF_DIVISOR_125;
res = lf_config(&config); res = lf_setconfig(&config);
if (res != PM3_SUCCESS) { if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "failed to change to 125 KHz LF configuration"); PrintAndLogEx(ERR, "failed to change to 125 KHz LF configuration");
return res; return res;
@ -694,7 +694,7 @@ static int CmdFdxBReader(const char *Cmd) {
if (old_div != curr_div) { if (old_div != curr_div) {
config.divisor = old_div; config.divisor = old_div;
res = lf_config(&config); res = lf_setconfig(&config);
if (res != PM3_SUCCESS) { if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "failed to restore LF configuration"); PrintAndLogEx(ERR, "failed to restore LF configuration");
return res; return res;

View file

@ -172,7 +172,7 @@ static int CmdMotorolaReader(const char *Cmd) {
.samples_to_skip = 4500, .samples_to_skip = 4500,
.verbose = false .verbose = false
}; };
lf_config(&sc); lf_setconfig(&sc);
int res; int res;
do { do {
@ -184,7 +184,7 @@ static int CmdMotorolaReader(const char *Cmd) {
// reset back to 125 kHz // reset back to 125 kHz
sc.divisor = LF_DIVISOR_125; sc.divisor = LF_DIVISOR_125;
sc.samples_to_skip = 0; sc.samples_to_skip = 0;
lf_config(&sc); lf_setconfig(&sc);
return res; return res;
} }

View file

@ -114,7 +114,7 @@ static int lf_search_plus(const char *Cmd) {
d = config.divisor = default_divisor[i]; d = config.divisor = default_divisor[i];
PrintAndLogEx(INFO, "--> trying ( " _GREEN_("%d.%02d kHz")" )", 12000 / (d + 1), ((1200000 + (d + 1) / 2) / (d + 1)) - ((12000 / (d + 1)) * 100)); PrintAndLogEx(INFO, "--> trying ( " _GREEN_("%d.%02d kHz")" )", 12000 / (d + 1), ((1200000 + (d + 1) / 2) / (d + 1)) - ((12000 / (d + 1)) * 100));
retval = lf_config(&config); retval = lf_setconfig(&config);
if (retval != PM3_SUCCESS) if (retval != PM3_SUCCESS)
break; break;
@ -125,7 +125,7 @@ static int lf_search_plus(const char *Cmd) {
} }
lf_config(&oldconfig); lf_setconfig(&oldconfig);
return retval; return retval;
} }

View file

@ -41,7 +41,6 @@
#include "crc16.h" #include "crc16.h"
#include "protocols.h" #include "protocols.h"
#include "fileutils.h" // searchfile #include "fileutils.h" // searchfile
#include "cmdlf.h" // lf_config
#include "generator.h" #include "generator.h"
#include "cmdlfem4x05.h" // read 4305 #include "cmdlfem4x05.h" // read 4305
#include "cmdlfem4x50.h" // read 4350 #include "cmdlfem4x50.h" // read 4350