Chameleon-Mini
Commands.h
1 
2 
3 #ifndef COMMANDS_H_
4 #define COMMANDS_H_
5 
6 #include "../Common.h"
7 
8 #define MAX_COMMAND_LENGTH 16
9 #define MAX_STATUS_LENGTH 32
10 
11 
12 #define COMMAND_INFO_OK_ID 100
13 #define COMMAND_INFO_OK "OK"
14 #define COMMAND_INFO_OK_WITH_TEXT_ID 101
15 #define COMMAND_INFO_OK_WITH_TEXT "OK WITH TEXT"
16 #define COMMAND_INFO_XMODEM_WAIT_ID 110
17 #define COMMAND_INFO_XMODEM_WAIT "WAITING FOR XMODEM"
18 #define COMMAND_INFO_FALSE_ID 120
19 #define COMMAND_INFO_FALSE "FALSE"
20 #define COMMAND_INFO_TRUE_ID 121
21 #define COMMAND_INFO_TRUE "TRUE"
22 #define COMMAND_ERR_UNKNOWN_CMD_ID 200
23 #define COMMAND_ERR_UNKNOWN_CMD "UNKNOWN COMMAND"
24 #define COMMAND_ERR_INVALID_USAGE_ID 201
25 #define COMMAND_ERR_INVALID_USAGE "INVALID COMMAND USAGE"
26 #define COMMAND_ERR_INVALID_PARAM_ID 202
27 #define COMMAND_ERR_INVALID_PARAM "INVALID PARAMETER"
28 #define COMMAND_ERR_TIMEOUT_ID 203
29 #define COMMAND_ERR_TIMEOUT "TIMEOUT"
30 #define TIMEOUT_COMMAND 255 // this is just for the CommandLine module to know that this is a timeout command
31 
32 
33 #define COMMAND_CHAR_TRUE '1'
34 #define COMMAND_CHAR_FALSE '0'
35 #define COMMAND_CHAR_SUGGEST '?' /* <CMD>=? for help */
36 
37 #define COMMAND_UID_BUFSIZE 32
38 
39 #define COMMAND_IS_SUGGEST_STRING(x) ( ((x)[0] == COMMAND_CHAR_SUGGEST) && ((x)[1] == '\0') )
40 
41 typedef uint8_t CommandStatusIdType;
42 typedef const char CommandStatusMessageType[MAX_STATUS_LENGTH];
43 
44 typedef CommandStatusIdType(*CommandExecFuncType)(char *OutMessage);
45 typedef CommandStatusIdType(*CommandExecParamFuncType)(char *OutMessage, const char *InParams);
46 typedef CommandStatusIdType(*CommandSetFuncType)(char *OutMessage, const char *InParam);
47 typedef CommandStatusIdType(*CommandGetFuncType)(char *OutParam);
48 
49 typedef struct {
50  char Command[MAX_COMMAND_LENGTH];
51  CommandExecFuncType ExecFunc;
52  CommandExecParamFuncType ExecParamFunc;
53  CommandSetFuncType SetFunc;
54  CommandGetFuncType GetFunc;
55 } CommandEntryType;
56 
57 #define COMMAND_VERSION "VERSION"
58 CommandStatusIdType CommandGetVersion(char *OutParam);
59 
60 #define COMMAND_CONFIG "CONFIG"
61 CommandStatusIdType CommandGetConfig(char *OutParam);
62 CommandStatusIdType CommandSetConfig(char *OutMessage, const char *InParam);
63 
64 #define COMMAND_UID "UID"
65 #define COMMAND_UID_RANDOM "RANDOM"
66 CommandStatusIdType CommandGetUid(char *OutParam);
67 CommandStatusIdType CommandSetUid(char *OutMessage, const char *InParam);
68 
69 #define COMMAND_READONLY "READONLY"
70 CommandStatusIdType CommandGetReadOnly(char *OutParam);
71 CommandStatusIdType CommandSetReadOnly(char *OutMessage, const char *InParam);
72 
73 #define COMMAND_UPLOAD "UPLOAD"
74 CommandStatusIdType CommandExecUpload(char *OutMessage);
75 
76 #define COMMAND_DOWNLOAD "DOWNLOAD"
77 CommandStatusIdType CommandExecDownload(char *OutMessage);
78 
79 #define COMMAND_RESET "RESET"
80 CommandStatusIdType CommandExecReset(char *OutMessage);
81 
82 #define COMMAND_UPGRADE "UPGRADE"
83 CommandStatusIdType CommandExecUpgrade(char *OutMessage);
84 
85 #define COMMAND_MEMSIZE "MEMSIZE"
86 CommandStatusIdType CommandGetMemSize(char *OutParam);
87 
88 #define COMMAND_UIDSIZE "UIDSIZE"
89 CommandStatusIdType CommandGetUidSize(char *OutParam);
90 
91 #define COMMAND_RBUTTON "RBUTTON"
92 CommandStatusIdType CommandGetRButton(char *OutParam);
93 CommandStatusIdType CommandSetRButton(char *OutMessage, const char *InParam);
94 
95 #define COMMAND_RBUTTON_LONG "RBUTTON_LONG"
96 CommandStatusIdType CommandGetRButtonLong(char *OutParam);
97 CommandStatusIdType CommandSetRButtonLong(char *OutMessage, const char *InParam);
98 
99 #define COMMAND_LBUTTON "LBUTTON"
100 CommandStatusIdType CommandGetLButton(char *OutParam);
101 CommandStatusIdType CommandSetLButton(char *OutMessage, const char *InParam);
102 
103 #define COMMAND_LBUTTON_LONG "LBUTTON_LONG"
104 CommandStatusIdType CommandGetLButtonLong(char *OutParam);
105 CommandStatusIdType CommandSetLButtonLong(char *OutMessage, const char *InParam);
106 
107 
108 #define COMMAND_LEDGREEN "LEDGREEN"
109 CommandStatusIdType CommandGetLedGreen(char *OutParam);
110 CommandStatusIdType CommandSetLedGreen(char *OutMessage, const char *InParam);
111 
112 #define COMMAND_LEDRED "LEDRED"
113 CommandStatusIdType CommandGetLedRed(char *OutParam);
114 CommandStatusIdType CommandSetLedRed(char *OutMessage, const char *InParam);
115 
116 #define COMMAND_PIN "PIN"
117 CommandStatusIdType CommandGetPin(char *OutParam);
118 CommandStatusIdType CommandSetPin(char *OutMessage, const char *InParam);
119 
120 #define COMMAND_LOGMODE "LOGMODE"
121 CommandStatusIdType CommandGetLogMode(char *OutParam);
122 CommandStatusIdType CommandSetLogMode(char *OutMessage, const char *InParam);
123 
124 #define COMMAND_LOGMEM "LOGMEM"
125 CommandStatusIdType CommandGetLogMem(char *OutParam);
126 
127 #define COMMAND_LOGDOWNLOAD "LOGDOWNLOAD"
128 CommandStatusIdType CommandExecLogDownload(char *OutMessage);
129 
130 #define COMMAND_STORELOG "LOGSTORE"
131 CommandStatusIdType CommandExecStoreLog(char *OutMessage);
132 
133 #define COMMAND_LOGCLEAR "LOGCLEAR"
134 CommandStatusIdType CommandExecLogClear(char *OutMessage);
135 
136 #define COMMAND_SETTING "SETTING"
137 CommandStatusIdType CommandGetSetting(char *OutParam);
138 CommandStatusIdType CommandSetSetting(char *OutMessage, const char *InParam);
139 
140 #define COMMAND_CLEAR "CLEAR"
141 CommandStatusIdType CommandExecClear(char *OutMessage);
142 
143 #define COMMAND_STORE "STORE"
144 CommandStatusIdType CommandExecStore(char *OutMessage);
145 
146 #define COMMAND_RECALL "RECALL"
147 CommandStatusIdType CommandExecRecall(char *OutMessage);
148 
149 #define COMMAND_CHARGING "CHARGING"
150 CommandStatusIdType CommandGetCharging(char *OutParam);
151 
152 #define COMMAND_HELP "HELP"
153 CommandStatusIdType CommandExecHelp(char *OutMessage);
154 
155 #define COMMAND_RSSI "RSSI"
156 CommandStatusIdType CommandGetRssi(char *OutParam);
157 
158 #define COMMAND_SYSTICK "SYSTICK"
159 CommandStatusIdType CommandGetSysTick(char *OutParam);
160 
161 #define COMMAND_SEND_RAW "SEND_RAW"
162 CommandStatusIdType CommandExecParamSendRaw(char *OutMessage, const char *InParams);
163 
164 #define COMMAND_SEND "SEND"
165 CommandStatusIdType CommandExecParamSend(char *OutMessage, const char *InParams);
166 
167 #define COMMAND_GETUID "GETUID"
168 CommandStatusIdType CommandExecGetUid(char *OutMessage);
169 
170 #define COMMAND_DUMP_MFU "DUMP_MFU"
171 CommandStatusIdType CommandExecDumpMFU(char *OutMessage);
172 
173 #define COMMAND_CLONE_MFU "CLONE_MFU"
174 CommandStatusIdType CommandExecCloneMFU(char *OutMessage);
175 
176 #define COMMAND_IDENTIFY_CARD "IDENTIFY"
177 CommandStatusIdType CommandExecIdentifyCard(char *OutMessage);
178 
179 #define COMMAND_TIMEOUT "TIMEOUT"
180 CommandStatusIdType CommandGetTimeout(char *OutMessage);
181 CommandStatusIdType CommandSetTimeout(char *OutMessage, const char *InParam);
182 
183 #define COMMAND_THRESHOLD "THRESHOLD"
184 CommandStatusIdType CommandGetThreshold(char *OutParam);
185 CommandStatusIdType CommandSetThreshold(char *OutMessage, const char *InParam);
186 
187 #define COMMAND_AUTOCALIBRATE "AUTOCALIBRATE"
188 CommandStatusIdType CommandExecAutocalibrate(char *OutMessage);
189 
190 #define COMMAND_FIELD "FIELD"
191 CommandStatusIdType CommandSetField(char *OutMessage, const char *InParam);
192 CommandStatusIdType CommandGetField(char *OutMessage);
193 
194 #define COMMAND_CLONE "CLONE"
195 CommandStatusIdType CommandExecClone(char *OutMessage);
196 
197 #ifdef CONFIG_ISO15693_SNIFF_SUPPORT
198 #define COMMAND_AUTOTHRESHOLD "AUTOTHRESHOLD"
199 CommandStatusIdType CommandGetAutoThreshold(char *OutParam);
200 CommandStatusIdType CommandSetAutoThreshold(char *OutMessage, const char *InParam);
201 #endif /*#ifdef CONFIG_ISO15693_SNIFF_SUPPORT*/
202 
203 #ifdef ENABLE_RUNTESTS_TERMINAL_COMMAND
204 #include "../Tests/ChameleonTerminal.h"
205 #endif
206 
207 #if defined(CONFIG_MF_DESFIRE_SUPPORT) && !defined(DISABLE_DESFIRE_TERMINAL_COMMANDS)
208 #include "../Application/DESFire/DESFireChameleonTerminal.h"
209 #endif
210 
211 #define COMMAND_LIST_END ""
212 /* Defines the end of command list. This is no actual command */
213 
214 #endif /* COMMANDS_H_ */