11 #define BIT(x) (1 << (x))
14 #define __packed __attribute__((__packed__))
17 #define CMD_PING BIT(7) | 0x1
18 #define CMD_MSG BIT(7) | 0x3
19 #define CMD_LOCK BIT(7) | 0x4
20 #define CMD_INIT BIT(7) | 0x6
21 #define CMD_WINK BIT(7) | 0x8
22 #define CMD_SYNC BIT(7) | 0x3c
23 #define CMD_ERROR BIT(7) | 0x3f
27 #define ERR_INVALID_CMD 0x01
28 #define ERR_INVALID_PAR 0x02
29 #define ERR_INVALID_LEN 0x03
30 #define ERR_INVALID_SEQ 0x04
31 #define ERR_MSG_TIMEOUT 0x05
32 #define ERR_CHANNEL_BUSY 0x06
33 #define ERR_LOCK_REQUIRED 0x0a
34 #define ERR_SYNC_FAILED 0x0b
35 #define ERR_INVALID_CID 0x0b
36 #define ERR_OTHER 0x7f
39 #define PROTOCOL_VERSION 2
40 #define MAJ_DEV_VERSION 0
41 #define MIN_DEV_VERSION 1
42 #define BUILD_DEV_VERSION 0
44 #define CAPABILITY_WINK 0
struct message * cmd_process(struct usb_state *state, const struct message *request)
Process a command request.
Definition: cmd.c:294
Message representation.
Definition: message.h:26
uint8_t cap_flags
Definition: cmd.h:57
uint8_t nonce[8]
Definition: cmd.h:51
uint8_t maj_dev_ver
Definition: cmd.h:54
uint32_t cid
Definition: cmd.h:52
uint32_t cid
Definition: cmd.h:49
uint8_t protocol_ver
Definition: cmd.h:53
struct message * cmd_generate_error(uint32_t cid, uint8_t error)
Generate an error response.
Definition: cmd.c:122
The command init reponse payload.
Definition: cmd.h:49
uint8_t build_dev_ver
Definition: cmd.h:56
#define __packed
Definition: cmd.h:14
USB transport state.
Definition: usb.h:20
uint8_t min_dev_ver
Definition: cmd.h:55
const char * cmd_strerror(int error_nb)
Get the command error description.
Definition: cmd.c:89