aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/cmd.cpp30
-rw-r--r--client/cmd.h30
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]);