Chameleon-Mini
 All Classes Files Functions Variables Macros Pages
Commands.h
1 /* Copyright 2013 Timo Kasper, Simon Küppers, David Oswald ("ORIGINAL
2  * AUTHORS"). All rights reserved.
3  *
4  * DEFINITIONS:
5  *
6  * "WORK": The material covered by this license includes the schematic
7  * diagrams, designs, circuit or circuit board layouts, mechanical
8  * drawings, documentation (in electronic or printed form), source code,
9  * binary software, data files, assembled devices, and any additional
10  * material provided by the ORIGINAL AUTHORS in the ChameleonMini project
11  * (https://github.com/skuep/ChameleonMini).
12  *
13  * LICENSE TERMS:
14  *
15  * Redistributions and use of this WORK, with or without modification, or
16  * of substantial portions of this WORK are permitted provided that the
17  * following conditions are met:
18  *
19  * Redistributions and use of this WORK, with or without modification, or
20  * of substantial portions of this WORK must include the above copyright
21  * notice, this list of conditions, the below disclaimer, and the following
22  * attribution:
23  *
24  * "Based on ChameleonMini an open-source RFID emulator:
25  * https://github.com/skuep/ChameleonMini"
26  *
27  * The attribution must be clearly visible to a user, for example, by being
28  * printed on the circuit board and an enclosure, and by being displayed by
29  * software (both in binary and source code form).
30  *
31  * At any time, the majority of the ORIGINAL AUTHORS may decide to give
32  * written permission to an entity to use or redistribute the WORK (with or
33  * without modification) WITHOUT having to include the above copyright
34  * notice, this list of conditions, the below disclaimer, and the above
35  * attribution.
36  *
37  * DISCLAIMER:
38  *
39  * THIS PRODUCT IS PROVIDED BY THE ORIGINAL AUTHORS "AS IS" AND ANY EXPRESS
40  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
41  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42  * DISCLAIMED. IN NO EVENT SHALL THE ORIGINAL AUTHORS OR CONTRIBUTORS BE
43  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
44  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
45  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
46  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48  * ARISING IN ANY WAY OUT OF THE USE OF THIS PRODUCT, EVEN IF ADVISED OF
49  * THE POSSIBILITY OF SUCH DAMAGE.
50  *
51  * The views and conclusions contained in the hardware, software, and
52  * documentation should not be interpreted as representing official
53  * policies, either expressed or implied, of the ORIGINAL AUTHORS.
54  */
55 
56 #ifndef COMMANDS_H_
57 #define COMMANDS_H_
58 
59 #include "../Common.h"
60 
61 #define MAX_COMMAND_LENGTH 16
62 #define MAX_STATUS_LENGTH 32
63 
64 
65 #define COMMAND_INFO_OK_ID 100
66 #define COMMAND_INFO_OK "OK"
67 #define COMMAND_INFO_OK_WITH_TEXT_ID 101
68 #define COMMAND_INFO_OK_WITH_TEXT "OK WITH TEXT"
69 #define COMMAND_INFO_XMODEM_WAIT_ID 110
70 #define COMMAND_INFO_XMODEM_WAIT "WAITING FOR XMODEM"
71 #define COMMAND_ERR_UNKNOWN_CMD_ID 200
72 #define COMMAND_ERR_UNKNOWN_CMD "UNKNOWN COMMAND"
73 #define COMMAND_ERR_INVALID_USAGE_ID 201
74 #define COMMAND_ERR_INVALID_USAGE "INVALID COMMAND USAGE"
75 #define COMMAND_ERR_INVALID_PARAM_ID 202
76 #define COMMAND_ERR_INVALID_PARAM "INVALID PARAMETER"
77 
78 
79 #define COMMAND_CHAR_TRUE '1'
80 #define COMMAND_CHAR_FALSE '0'
81 
82 #define COMMAND_UID_BUFSIZE 32
83 
84 typedef uint8_t CommandStatusIdType;
85 typedef const char CommandStatusMessageType[MAX_STATUS_LENGTH];
86 
87 typedef CommandStatusIdType (*CommandExecFuncType) (char* OutMessage);
88 typedef CommandStatusIdType (*CommandSetFuncType) (const char* InParam);
89 typedef CommandStatusIdType (*CommandGetFuncType) (char* OutParam);
90 
91 typedef struct {
92  char Command[MAX_COMMAND_LENGTH];
93  CommandExecFuncType ExecFunc;
94  CommandSetFuncType SetFunc;
95  CommandGetFuncType GetFunc;
96 } CommandEntryType;
97 
98 #define COMMAND_VERSION "VERSION"
99 CommandStatusIdType CommandGetVersion(char* OutParam);
100 
101 #define COMMAND_CONFIG "CONFIG"
102 CommandStatusIdType CommandExecConfig(char* OutMessage);
103 CommandStatusIdType CommandGetConfig(char* OutParam);
104 CommandStatusIdType CommandSetConfig(const char* InParam);
105 
106 #define COMMAND_UID "UID"
107 #define COMMAND_UID_RANDOM "RANDOM"
108 CommandStatusIdType CommandGetUid(char* OutParam);
109 CommandStatusIdType CommandSetUid(const char* InParam);
110 
111 #define COMMAND_READONLY "READONLY"
112 CommandStatusIdType CommandGetReadOnly(char* OutParam);
113 CommandStatusIdType CommandSetReadOnly(const char* InParam);
114 
115 #define COMMAND_UPLOAD "UPLOAD"
116 CommandStatusIdType CommandExecUpload(char* OutMessage);
117 
118 #define COMMAND_DOWNLOAD "DOWNLOAD"
119 CommandStatusIdType CommandExecDownload(char* OutMessage);
120 
121 #define COMMAND_RESET "RESET"
122 CommandStatusIdType CommandExecReset(char* OutMessage);
123 
124 #define COMMAND_UPGRADE "UPGRADE"
125 CommandStatusIdType CommandExecUpgrade(char* OutMessage);
126 
127 #define COMMAND_MEMSIZE "MEMSIZE"
128 CommandStatusIdType CommandGetMemSize(char* OutParam);
129 
130 #define COMMAND_UIDSIZE "UIDSIZE"
131 CommandStatusIdType CommandGetUidSize(char* OutParam);
132 
133 #define COMMAND_BUTTON "BUTTON"
134 CommandStatusIdType CommandExecButton(char* OutMessage);
135 CommandStatusIdType CommandGetButton(char* OutParam);
136 CommandStatusIdType CommandSetButton(const char* InParam);
137 
138 #define COMMAND_SETTING "SETTING"
139 CommandStatusIdType CommandGetSetting(char* OutParam);
140 CommandStatusIdType CommandSetSetting(const char* InParam);
141 
142 #define COMMAND_CLEAR "CLEAR"
143 CommandStatusIdType CommandExecClear(char* OutParam);
144 
145 #define COMMAND_HELP "HELP"
146 CommandStatusIdType CommandExecHelp(char* OutMessage);
147 
148 #define COMMAND_RSSI "RSSI"
149 CommandStatusIdType CommandGetRssi(char* OutParam);
150 
151 #define COMMAND_LIST_END ""
152 /* Defines the end of command list. This is no actual command */
153 
154 #endif /* COMMANDS_H_ */