diff options
Diffstat (limited to 'shared')
-rw-r--r-- | shared/protocol.c | 3 | ||||
-rw-r--r-- | shared/protocol.h | 17 |
2 files changed, 19 insertions, 1 deletions
diff --git a/shared/protocol.c b/shared/protocol.c index 02d746a..8aa4a3f 100644 --- a/shared/protocol.c +++ b/shared/protocol.c @@ -23,6 +23,7 @@ void w2_cmd_setup_handlers() { g_w2_cmd_handlers[W2_CMD_DISP | W2_CMDDIR_RX] = w2_cmd_disp_rx; g_w2_cmd_handlers[W2_CMD_PLAY | W2_CMDDIR_RX] = w2_cmd_play_rx; g_w2_cmd_handlers[W2_CMD_CLED | W2_CMDDIR_RX] = w2_cmd_cled_rx; + g_w2_cmd_handlers[W2_CMD_TARQ | W2_CMDDIR_RX] = w2_cmd_tarq_rx; } size_t w2_cmd_sizeof(uint8_t data[W2_SERIAL_READ_BUFFER_SIZE], uint8_t data_length) { @@ -47,6 +48,8 @@ size_t w2_cmd_sizeof(uint8_t data[W2_SERIAL_READ_BUFFER_SIZE], uint8_t data_leng if (data[0] == (W2_CMD_INFO | W2_CMDDIR_RX)) return sizeof(w2_s_cmd_info_rx); if (data[0] == (W2_CMD_INFO | W2_CMDDIR_TX)) return sizeof(w2_s_cmd_info_tx); + if (data[0] == (W2_CMD_TARQ | W2_CMDDIR_RX)) return sizeof(w2_s_cmd_tarq_rx); + w2_s_bin *copy = w2_bin_s_alloc(data_length, data); uint8_t length = 1; diff --git a/shared/protocol.h b/shared/protocol.h index ba16d56..c13e56c 100644 --- a/shared/protocol.h +++ b/shared/protocol.h @@ -17,7 +17,7 @@ #define W2_CMD_CODE_MASK (~1) #define W2_CMD_DIRECTION_MASK (1) -#define W2_CMD_COUNT 28 +#define W2_CMD_COUNT 30 typedef enum { /** ping command */ W2_CMD_PING = 0x00, @@ -47,8 +47,16 @@ typedef enum { W2_CMD_PLAY = 0x18, /** control leds command */ W2_CMD_CLED = 0x1a, + /** target area request */ + W2_CMD_TARQ = 0x1c, } w2_e_scmds; +typedef enum { + W2_AREA_MAZE = 0, + W2_AREA_GRID = 1, + W2_AREA_CHRG = 2, +} w2_e_target_area; + #pragma pack(push, 1) typedef struct { @@ -158,6 +166,11 @@ typedef struct { typedef struct { } w2_s_cmd_cled_rx; +typedef struct { + uint8_t opcode; + w2_e_target_area target_area; +} w2_s_cmd_tarq_rx; + #pragma pack(pop) /** stores message handlers in array with opcode as index */ @@ -206,6 +219,8 @@ void w2_cmd_disp_rx(w2_s_bin *data); void w2_cmd_play_rx(w2_s_bin *data); /** handler for cled_rx (on complete message) */ void w2_cmd_cled_rx(w2_s_bin *data); +/** handler for tarq_rx (on complete message) */ +void w2_cmd_tarq_rx(w2_s_bin *data); /** calculate message length for expt_tx (incomplete message) */ size_t w2_cmd_expt_tx_sizeof(w2_s_bin *data); |