aboutsummaryrefslogtreecommitdiff
path: root/main/i2c.c
diff options
context:
space:
mode:
authorThomasintAnker <thomasintanker1@gmail.com>2024-06-20 14:58:17 +0200
committerThomasintAnker <thomasintanker1@gmail.com>2024-06-20 14:58:17 +0200
commit5152b4dbd41e0e11da32c1ba308824ba367c45a9 (patch)
treeb2b2c007b400fc84ce49eaabfad3bfba765d44f9 /main/i2c.c
parentf121de7c7e3ca8f0dc526973a5ee2586485aad22 (diff)
WIP main controller global state update
Diffstat (limited to 'main/i2c.c')
-rw-r--r--main/i2c.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/main/i2c.c b/main/i2c.c
index 2503560..5074915 100644
--- a/main/i2c.c
+++ b/main/i2c.c
@@ -17,6 +17,9 @@ i2c_addr_t modules[CFG_PB_MOD_MAX];
size_t modules_size = 0;
static void state_exchange() {
+
+ // TODO: Add calculation(?) to get global state
+
for (size_t i = 0; i < modules_size; i++) {
pb_buf_t buf = pb_send_state_req();
@@ -47,3 +50,11 @@ void pb_route_cmd_magic_res(pb_msg_t * msg) {
printf("i2c: registered puzzle module w/ address 0x%02x\n", msg->sender);
}
+void pb_route_cmd_state_res(pb_msg_t * msg) {
+ pb_cmd_state_t * cmd = msg->cmd;
+ // return early if state has wrong size
+ if (cmd->_magic_size != sizeof(pb_cmd_state_t))
+ return;
+
+ // TODO: Get msg sender & update state in array struct (?)
+}