From 5152b4dbd41e0e11da32c1ba308824ba367c45a9 Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Thu, 20 Jun 2024 14:58:17 +0200 Subject: WIP main controller global state update --- main/i2c.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 (?) +} -- cgit v1.2.3