for lf commands that gets impacted negative when some configuration values has been set, this will offer a way to sort it out on client side

This commit is contained in:
iceman1001 2021-07-29 10:42:22 +02:00
parent 01483a68a5
commit 7ec18a040b
2 changed files with 43 additions and 0 deletions

View file

@ -434,6 +434,46 @@ int CmdFlexdemod(const char *Cmd) {
return PM3_SUCCESS; return PM3_SUCCESS;
} }
/*
* 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) {
if (config == NULL) {
return PM3_EINVARG;
}
memset(&config, 0, sizeof(sample_config));
int res = lf_getconfig(config);
if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "failed to get current device LF config");
return res;
}
sample_config def_config = {
.decimation = 1,
.bits_per_sample = 8,
.averaging = 1,
.divisor = LF_DIVISOR_125,
.trigger_threshold = 0,
.samples_to_skip = 0,
.verbose = false,
};
res = lf_config(&def_config);
if (res != PM3_SUCCESS) {
PrintAndLogEx(ERR, "failed to reset LF configuration to default values");
return res;
}
// disable output on save config object
config->verbose = false;
return PM3_SUCCESS;
}
int lf_getconfig(sample_config *config) { int lf_getconfig(sample_config *config) {
if (!session.pm3_present) return PM3_ENOTTY; if (!session.pm3_present) return PM3_ENOTTY;
@ -475,6 +515,7 @@ int CmdLFConfig(const char *Cmd) {
"lf config -b 8 --125 --> samples at 125 kHz, 8 bps\n" "lf config -b 8 --125 --> samples at 125 kHz, 8 bps\n"
"lf config -b 4 --134 --dec 3 --> samples at 134 kHz, averages three samples into one, stored with a resolution of 4 bits per sample\n" "lf config -b 4 --134 --dec 3 --> samples at 134 kHz, averages three samples into one, stored with a resolution of 4 bits per sample\n"
"lf config --trig 20 -s 10000 --> trigger sampling when above 20, skip 10 000 first samples after triggered\n" "lf config --trig 20 -s 10000 --> trigger sampling when above 20, skip 10 000 first samples after triggered\n"
"lf config --reset --> reset back to default values\n"
); );
char div_str[70] = {0}; char div_str[70] = {0};

View file

@ -38,4 +38,6 @@ int lf_config(sample_config *config);
int lf_getconfig(sample_config *config); int lf_getconfig(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