1: /*
2: * Guitar-ZyX(tm)::MasterControlProgram - portable guitar F/X controller
3: * Copyright (C) 2009 Douglas McClendon
4: *
5: * This program is free software: you can redistribute it and/or modify
6: * it under the terms of the GNU General Public License as published by
7: * the Free Software Foundation, version 3 of the License.
8: *
9: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program. If not, see <http://www.gnu.org/licenses/>.
16: */
17: /*
18: #
19: #############################################################################
20: #############################################################################
21: ##
22: ## gzmcp: protocol definition
23: ##
24: #############################################################################
25: ##
26: ## Copyright 2009 Douglas McClendon <dmc AT filteredperception DOT org>
27: ##
28: #############################################################################
29: #############################################################################
30: #
31: */
32:
33:
34:
35: #define GZMCP_DEF_MAGIC_COOKIE 0x42244224
36:
37: #define GZMCP_DEF_TCP_PORT 24642
38: #define GZMCP_DEF_UDP_PORT 24642
39:
40: #define GZMCP_BEACON_MSG_MAXLEN 1023
41:
42: #define GZMCP_HANDSHAKE_MAXLEN 11
43:
44:
45:
46:
47:
48: typedef enum {
49: GZMCP_CMD_UNDEFINED,
50: GZMCP_CMD_HANDSHAKE,
51: GZMCP_CMD_PRESET,
52: GZMCP_CMD_PARAMETER,
53: GZMCP_CMD_GETUPDATE,
54: GZMCP_CMD_SHUTDOWN,
55: GZMCP_CMD_MAX = 0xFFFFFFFA,
56: } gzmcp_cmd_type;
57:
58: typedef struct gzmcp_cmd_handshake_data_tag {
59: char string[GZMCP_HANDSHAKE_MAXLEN + 1];
60: } gzmcp_cmd_handshake_data;
61:
62:
63: typedef struct gzmcp_cmd_preset_data_tag {
64: int32_t channel;
65: int32_t preset;
66: } gzmcp_cmd_preset_data;
67:
68: typedef struct gzmcp_cmd_parameter_data_tag {
69: int32_t channel;
70: int32_t parameter;
71: int32_t value;
72: } gzmcp_cmd_parameter_data;
73:
74: typedef struct gzmcp_cmd_getupdate_data_tag {
75: // size of last cached copy, -1 if not available
76: uint32_t size;
77: // xor of all ints in the file
78: uint32_t hash;
79: // 4 sample bytes of last cached copy,
80: // first and last byte of first and second half of file
81: uint32_t sample_data;
82: } gzmcp_cmd_getupdate_data;
83:
84: typedef union gzmcp_cmd_data_tag {
85: gzmcp_cmd_handshake_data handshake;
86: gzmcp_cmd_preset_data preset;
87: gzmcp_cmd_parameter_data parameter;
88: gzmcp_cmd_getupdate_data getupdate;
89: } gzmcp_cmd_data;
90:
91:
92: typedef struct gzmcp_cmd_tag {
93: gzmcp_cmd_type type;
94: gzmcp_cmd_data data;
95: } gzmcp_cmd;
96: