diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-05-27 08:23:21 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-05-27 08:23:21 +0200 |
commit | f4868604384908a7477cbb4b544c6ee7aac2a883 (patch) | |
tree | 53b7df9dd58d49db5d3640f01a4cc600d088f655 /client | |
parent | fb37e47bc13912a8d94bf1b3b7aa8456601f317a (diff) |
quickly implement some pseudo handlers for the remaining commands
Diffstat (limited to 'client')
-rw-r--r-- | client/cmd.cpp | 30 | ||||
-rw-r--r-- | client/cmd.h | 30 |
2 files changed, 45 insertions, 15 deletions
diff --git a/client/cmd.cpp b/client/cmd.cpp index a098a14..736cf12 100644 --- a/client/cmd.cpp +++ b/client/cmd.cpp @@ -3,9 +3,12 @@ #include <string.h> #include "cmd.h" +#include "puzbusv1.h" #include "sock.h" #include "parse.h" +#include "../shared/busaddr.h" + char* consume_token(char* input, const char* ifs) { strtok(input, ifs); return strtok(NULL, "\0"); @@ -61,3 +64,30 @@ void cmd_send(char* addr_str) { free(data); } +void cmd_status(char*) { + const char msg[] = { + PB_CMD_READ, + 0x00, // addr 0 = global state + }; + i2c_send(BUSADDR_MAIN, msg, sizeof(msg)); + // NOTE: the reply handler will automatically print the state once it's + // received +} + +void cmd_reset(char*) { + const char msg[] = { + PB_CMD_WRITE, + 0x00, + PB_GS_IDLE, + }; + i2c_send(BUSADDR_MAIN, msg, sizeof(msg)); +} + +void cmd_ls(char*) { + return; + const char msg[] = { + PB_CMD_READ, + // TODO: which address is this? + }; + i2c_send(BUSADDR_MAIN, msg, sizeof(msg)); +} diff --git a/client/cmd.h b/client/cmd.h index 9d20328..30bcbeb 100644 --- a/client/cmd.h +++ b/client/cmd.h @@ -40,21 +40,21 @@ static const struct cmd cmds[] = { .name = "send", .info = "[debug] send raw message", }, - // { - // .handle = cmd_status, - // .name = "status", - // .info = "show global puzzle box state (main controller state)", - // }, - // { - // .handle = cmd_reset, - // .name = "reset", - // .info = "reset entire game state", - // }, - // { - // .handle = cmd_ls, - // .name = "ls", - // .info = "list connected puzzle modules", - // }, + { + .handle = cmd_status, + .name = "status", + .info = "show global puzzle box state (main controller state)", + }, + { + .handle = cmd_reset, + .name = "reset", + .info = "reset entire game state", + }, + { + .handle = cmd_ls, + .name = "ls", + .info = "list connected puzzle modules", + }, }; static const size_t cmds_length = sizeof(cmds) / sizeof(cmds[0]); |