From b6dcfbf078bb8595f0c03e079b058b2410381025 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 5 Mar 2020 11:16:05 +0100 Subject: [PATCH] =?UTF-8?q?chg:=20allow=20to=20download=20=C2=B4lf=20confi?= =?UTF-8?q?g=C2=B4=20settings=20to=20client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- armsrc/appmain.c | 9 ++++++++- armsrc/lfsampling.c | 2 +- client/cmdlf.c | 21 ++++++++++++++++++++- client/cmdlf.h | 1 + include/pm3_cmd.h | 3 ++- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 415e03291..88c85ad57 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -721,10 +721,17 @@ static void PacketReceived(PacketCommandNG *packet) { setT55xxConfig(packet->oldarg[0], (t55xx_configurations_t *) packet->data.asBytes); break; } - case CMD_LF_SAMPLING_GET_CONFIG: { + case CMD_LF_SAMPLING_PRINT_CONFIG: { printConfig(); break; } + case CMD_LF_SAMPLING_GET_CONFIG: { + sample_config *c; + c = getSamplingConfig(); + Dbprintf("CMD_LF_SAMPLING_GET_CONFIG - before answer"); + reply_ng(CMD_LF_SAMPLING_GET_CONFIG, PM3_SUCCESS, (uint8_t *)c, sizeof(sample_config)); + break; + } case CMD_LF_SAMPLING_SET_CONFIG: { sample_config c; memcpy(&c, packet->data.asBytes, sizeof(sample_config)); diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index 2e33ec434..3ce7bc5da 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -81,7 +81,7 @@ void setSamplingConfig(sample_config *sc) { printConfig(); } -sample_config *getSamplingConfig() { +sample_config *getSamplingConfig(void) { return &config; } diff --git a/client/cmdlf.c b/client/cmdlf.c index f153ba1c3..c44764fd0 100644 --- a/client/cmdlf.c +++ b/client/cmdlf.c @@ -457,6 +457,25 @@ int CmdFlexdemod(const char *Cmd) { return PM3_SUCCESS; } +int lf_getconfig(sample_config *config) { + if (!session.pm3_present) return PM3_ENOTTY; + + if (config == NULL) + return PM3_EINVARG; + + clearCommandBuffer(); + + SendCommandNG(CMD_LF_SAMPLING_GET_CONFIG, NULL, 0); + PacketResponseNG resp; + if (!WaitForResponseTimeout(CMD_LF_SAMPLING_GET_CONFIG, &resp, 2000)) { + PrintAndLogEx(WARNING, "command execution time out"); + return PM3_ETIMEOUT; + } + + config = (sample_config *) resp.data.asBytes; + return PM3_SUCCESS; +} + int lf_config(sample_config *config) { if (!session.pm3_present) return PM3_ENOTTY; @@ -464,7 +483,7 @@ int lf_config(sample_config *config) { if (config != NULL) SendCommandNG(CMD_LF_SAMPLING_SET_CONFIG, (uint8_t *)config, sizeof(sample_config)); else - SendCommandNG(CMD_LF_SAMPLING_GET_CONFIG, NULL, 0); + SendCommandNG(CMD_LF_SAMPLING_PRINT_CONFIG, NULL, 0); return PM3_SUCCESS; } diff --git a/client/cmdlf.h b/client/cmdlf.h index 7393405ba..bb0628609 100644 --- a/client/cmdlf.h +++ b/client/cmdlf.h @@ -34,5 +34,6 @@ int CmdLFfind(const char *Cmd); int lf_read(bool verbose, uint32_t samples); int lf_config(sample_config *config); +int lf_getconfig(sample_config *config); #endif diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index 32b2ba35c..cff1f891f 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -392,7 +392,8 @@ typedef struct { #define CMD_LF_T55XX_WAKEUP 0x0224 #define CMD_LF_COTAG_READ 0x0225 #define CMD_LF_T55XX_SET_CONFIG 0x0226 -#define CMD_LF_SAMPLING_GET_CONFIG 0x0227 +#define CMD_LF_SAMPLING_PRINT_CONFIG 0x0227 +#define CMD_LF_SAMPLING_GET_CONFIG 0x0228 #define CMD_LF_T55XX_CHK_PWDS 0x0230 #define CMD_LF_T55XX_DANGERRAW 0x0231