Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/robots/ChameleonMini
Browse files Browse the repository at this point in the history
  • Loading branch information
geo-rg committed Jan 24, 2018
2 parents be67058 + 62ba2e0 commit c0c1489
Show file tree
Hide file tree
Showing 8 changed files with 334 additions and 185 deletions.
469 changes: 285 additions & 184 deletions Firmware/Chameleon-Mini/Application/Reader14443A.c

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Firmware/Chameleon-Mini/Application/Reader14443A.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ typedef enum {
Reader14443_Get_UID,
Reader14443_Autocalibrate,
Reader14443_Read_MF_Ultralight,
Reader14443_Identify
Reader14443_Identify,
Reader14443_Identify_Clone
} Reader14443Command;


Expand Down
7 changes: 7 additions & 0 deletions Firmware/Chameleon-Mini/Button.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Settings.h"
#include "Memory.h"
#include "Map.h"
#include "Terminal/CommandLine.h"
#include "Application/Application.h"

#define BUTTON_PORT PORTA
Expand All @@ -27,6 +28,7 @@ static const MapEntryType PROGMEM ButtonActionMap[] = {
{ .Id = BUTTON_ACTION_RECALL_MEM, .Text = "RECALL_MEM" },
{ .Id = BUTTON_ACTION_TOGGLE_FIELD, .Text = "TOGGLE_FIELD" },
{ .Id = BUTTON_ACTION_STORE_LOG, .Text = "STORE_LOG" },
{ .Id = BUTTON_ACTION_CLONE, .Text = "CLONE" },
};

static void ExecuteButtonAction(ButtonActionEnum ButtonAction)
Expand Down Expand Up @@ -180,6 +182,11 @@ static void ExecuteButtonAction(ButtonActionEnum ButtonAction)
break;
}

case BUTTON_ACTION_CLONE:
{
CommandExecute("CLONE");
break;
}

default:
break;
Expand Down
1 change: 1 addition & 0 deletions Firmware/Chameleon-Mini/Button.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef enum {
BUTTON_ACTION_RECALL_MEM,
BUTTON_ACTION_TOGGLE_FIELD,
BUTTON_ACTION_STORE_LOG,
BUTTON_ACTION_CLONE,

/* This has to be last element */
BUTTON_ACTION_COUNT
Expand Down
21 changes: 21 additions & 0 deletions Firmware/Chameleon-Mini/Terminal/CommandLine.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ const PROGMEM CommandEntryType CommandTable[] = {
.SetFunc = CommandSetField,
.GetFunc = CommandGetField
},
{
.Command = COMMAND_CLONE,
.ExecFunc = CommandExecClone,
.ExecParamFunc = NO_FUNCTION,
.SetFunc = NO_FUNCTION,
.GetFunc = NO_FUNCTION
},
{ /* This has to be last element */
.Command = COMMAND_LIST_END,
.ExecFunc = NO_FUNCTION,
Expand Down Expand Up @@ -396,6 +403,20 @@ static CommandStatusIdType CallCommandFunc(
return Status;
}

void CommandExecute(const char* command)
{
uint8_t i;

for (i = 0; i < ARRAY_COUNT(CommandTable); i++)
{
if (strcmp_P(command, CommandTable[i].Command) == 0)
{
CallCommandFunc(&CommandTable[i], CHAR_EXEC_MODE, NULL);
break;
}
}
}

static void DecodeCommand(void)
{
uint8_t i;
Expand Down
1 change: 1 addition & 0 deletions Firmware/Chameleon-Mini/Terminal/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void CommandLineInit(void);
bool CommandLineProcessByte(uint8_t Byte);
void CommandLineTick(void);

void CommandExecute(const char* command);
void CommandLineAppendData(void const * const Buffer, uint16_t Bytes);

/* Functions for timeout commands */
Expand Down
14 changes: 14 additions & 0 deletions Firmware/Chameleon-Mini/Terminal/Commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,3 +639,17 @@ CommandStatusIdType CommandExecAutocalibrate(char* OutMessage)
CommandLinePendingTaskTimeout = &Reader14443AAppTimeout;
return TIMEOUT_COMMAND;
}

CommandStatusIdType CommandExecClone(char *OutMessage)
{
ConfigurationSetById(CONFIG_ISO14443A_READER);

ApplicationReset();

Reader14443CurrentCommand = Reader14443_Identify_Clone;
Reader14443AAppInit();
Reader14443ACodecStart();
CommandLinePendingTaskTimeout = &Reader14443AAppTimeout;

return TIMEOUT_COMMAND;
}
3 changes: 3 additions & 0 deletions Firmware/Chameleon-Mini/Terminal/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ CommandStatusIdType CommandExecAutocalibrate(char* OutMessage);
CommandStatusIdType CommandSetField(char* OutMessage, const char* InParam);
CommandStatusIdType CommandGetField(char* OutMessage);

#define COMMAND_CLONE "CLONE"
CommandStatusIdType CommandExecClone(char* OutMessage);

#define COMMAND_LIST_END ""
/* Defines the end of command list. This is no actual command */

Expand Down

0 comments on commit c0c1489

Please sign in to comment.