diff options
author | ThomasintAnker <thomasintanker1@gmail.com> | 2024-06-25 14:05:19 +0200 |
---|---|---|
committer | ThomasintAnker <thomasintanker1@gmail.com> | 2024-06-25 14:05:19 +0200 |
commit | 3a3679908019a63772fc414b0f997497c481625c (patch) | |
tree | 927700b504df580118f7afd512d4ba28cd0e6ffb | |
parent | 384001487675f65940701d6e65235a24a3af9900 (diff) |
added handling for bus scan req from client
-rw-r--r-- | main/i2c.c | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -7,6 +7,7 @@ #include <hardware/i2c.h> #include "i2c.h" +#include "lib/pbdrv/mod/main/mod.h" #include "pb-mod.h" #include "config.h" #include "pb-buf.h" @@ -18,10 +19,10 @@ typedef struct { } puzzle_module_t; static pb_global_state_t _global_state = PB_GS_IDLE; -puzzle_module_t modules[CFG_PB_MOD_MAX]; +puzzle_module_t modules[CFG_PB_MOD_MAX] = {}; +size_t modules_size = 0; // stolen from lib/pico-sdk/src/rp2_common/hardware_i2c/i2c.c #define i2c_reserved_addr(addr) (((addr) & 0x78) == 0 || ((addr) & 0x78) == 0x78) -size_t modules_size = 0; static void bus_scan() { pb_buf_t buf = pb_send_magic_req(); @@ -132,23 +133,25 @@ void pb_hook_mod_state_write(pb_global_state_t state) { void pb_route_cmd_prop_req(pb_msg_t * msg) { // send modules using buf - pb_cmd_prop_t cmd = msg->cmd; + // pb_cmd_prop_t cmd = msg->cmd; - pb_buf_t buf; + // pb_buf_t buf; - if(cmd == "PROPID_AJHDKADLHL") { - pb_send_reply(msg,buf); - } + // if(cmd == "PROPID_AJHDKADLHL") { + // pb_send_reply(msg,buf); + // } - pb_buf_free(buf); + // pb_buf_free(buf); } void pb_route_cmd_prop_set(pb_msg_t * msg) { - // scan bus again. - pb_cmd_prop_t cmd = msg->cmd; + // if incorrect property id -> stop + pb_cmd_prop_t * cmd = msg->cmd; + if(cmd->propid != PB_MOD_MAIN_PROP_MODS) return; - if(cmd == "") { + bus_scan(); - } + puzzle_module_t modules[CFG_PB_MOD_MAX] = {}; + size_t modules_size = 0; } |