Skip to content

Commit

Permalink
Terminal: Add commands to control Sniff15693 autothreshold feature
Browse files Browse the repository at this point in the history
Signed-off-by: cacke-r <cresch@gmx.de>
  • Loading branch information
cacke-r committed Feb 23, 2022
1 parent b04351b commit b8fec22
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Firmware/Chameleon-Mini/Terminal/CommandLine.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,15 @@ const PROGMEM CommandEntryType CommandTable[] = {
.GetFunc = NO_FUNCTION
},
#endif
#ifdef CONFIG_ISO15693_SNIFF_SUPPORT
{
.Command = COMMAND_AUTOTHRESHOLD,
.ExecFunc = NO_FUNCTION,
.ExecParamFunc = NO_FUNCTION,
.SetFunc = CommandSetAutoThreshold,
.GetFunc = CommandGetAutoThreshold
},
#endif
#ifdef ENABLE_RUNTESTS_TERMINAL_COMMAND
#include "../Tests/ChameleonTerminalInclude.c"
#endif
Expand Down
46 changes: 46 additions & 0 deletions Firmware/Chameleon-Mini/Terminal/Commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include "../Application/Reader14443A.h"
#include "../Application/Sniff15693.h"

#ifdef CONFIG_ISO15693_SNIFF_SUPPORT
#include "../Codec/SniffISO15693.h"
#endif /*#ifdef CONFIG_ISO15693_SNIFF_SUPPORT*/
extern Reader14443Command Reader14443CurrentCommand;
extern Sniff14443Command Sniff14443CurrentCommand;

Expand Down Expand Up @@ -687,3 +690,46 @@ CommandStatusIdType CommandExecClone(char *OutMessage) {
#endif
}
#endif

#ifdef CONFIG_ISO15693_SNIFF_SUPPORT
CommandStatusIdType CommandGetAutoThreshold(char *OutParam){

/* Only Execute the command if the current configuration is CONFIG_ISO15693_SNIFF */
if (GlobalSettings.ActiveSettingPtr->Configuration != CONFIG_ISO15693_SNIFF)
return COMMAND_ERR_INVALID_USAGE_ID;

/* Get Autothreshold mode */
if(SniffISO15693GetAutoThreshold())
snprintf(OutParam, TERMINAL_BUFFER_SIZE, "%c (enabled)", COMMAND_CHAR_TRUE);
else
snprintf(OutParam, TERMINAL_BUFFER_SIZE, "%c - (disabled)", COMMAND_CHAR_FALSE);
/* In case of overflow, snprintf does not write the terminating '\0' */
/* so we should make sure it gets terminated */
OutParam[TERMINAL_BUFFER_SIZE-1] = '\0';

return COMMAND_INFO_OK_WITH_TEXT_ID;
}

CommandStatusIdType CommandSetAutoThreshold(char *OutMessage, const char *InParam){

/* Only Execute the command if the current configuration is CONFIG_ISO15693_SNIFF */
if (GlobalSettings.ActiveSettingPtr->Configuration != CONFIG_ISO15693_SNIFF)
return COMMAND_ERR_INVALID_USAGE_ID;

if (COMMAND_IS_SUGGEST_STRING(InParam)) {
snprintf(OutMessage, TERMINAL_BUFFER_SIZE, "%c (enable), %c (disable)", COMMAND_CHAR_TRUE, COMMAND_CHAR_FALSE);
/* In case of overflow, snprintf does not write the terminating '\0' */
/* so we should make sure it gets terminated */
OutMessage[TERMINAL_BUFFER_SIZE-1] = '\0';
return COMMAND_INFO_OK_WITH_TEXT_ID;
} else if (InParam[0] == COMMAND_CHAR_TRUE) {
SniffISO15693CtrlAutoThreshold(true);
return COMMAND_INFO_OK_ID;
} else if (InParam[0] == COMMAND_CHAR_FALSE) {
SniffISO15693CtrlAutoThreshold(false);
return COMMAND_INFO_OK_ID;
} else {
return COMMAND_ERR_INVALID_PARAM_ID;
}
}
#endif /*#ifdef CONFIG_ISO15693_SNIFF_SUPPORT*/
6 changes: 6 additions & 0 deletions Firmware/Chameleon-Mini/Terminal/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ CommandStatusIdType CommandGetField(char *OutMessage);
#define COMMAND_CLONE "CLONE"
CommandStatusIdType CommandExecClone(char *OutMessage);

#ifdef CONFIG_ISO15693_SNIFF_SUPPORT
#define COMMAND_AUTOTHRESHOLD "AUTOTHRESHOLD"
CommandStatusIdType CommandGetAutoThreshold(char *OutParam);
CommandStatusIdType CommandSetAutoThreshold(char *OutMessage, const char *InParam);
#endif /*#ifdef CONFIG_ISO15693_SNIFF_SUPPORT*/

#ifdef ENABLE_RUNTESTS_TERMINAL_COMMAND
#include "../Tests/ChameleonTerminal.h"
#endif
Expand Down

0 comments on commit b8fec22

Please sign in to comment.