aboutsummaryrefslogtreecommitdiff
path: root/main/sock.c
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-06-25 12:09:15 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-06-25 12:09:15 +0200
commit18e5d93da8fdf6dd97c9e2d090ae2648d85cb851 (patch)
treeec4935b8682ab878ecbe0c41afa96cacf9b5f53c /main/sock.c
parent208dee5a3cf9eea84c5e26ef5cfe3abdd2e2a2f8 (diff)
fix client show all messages
Diffstat (limited to 'main/sock.c')
-rw-r--r--main/sock.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/main/sock.c b/main/sock.c
index 07db6af..c97ad04 100644
--- a/main/sock.c
+++ b/main/sock.c
@@ -14,7 +14,7 @@
struct netconn* current_connection = NULL;
i2ctcp_msg_t recv_msg;
-void pb_hook_i2c_send(i2c_addr_t addr, const uint8_t * data, size_t data_size) {
+static void sock_dump_msg(i2c_addr_t addr, const uint8_t * data, size_t data_size) {
if (current_connection == NULL) return;
i2ctcp_msg_t send_msg = {
@@ -35,7 +35,17 @@ void pb_hook_i2c_send(i2c_addr_t addr, const uint8_t * data, size_t data_size) {
free(buf);
}
-static void i2c_recv_fwd(i2c_addr_t addr, const uint8_t * data, size_t data_size) {
+bool pb_hook_i2c_send(i2c_addr_t addr, const uint8_t * data, size_t data_size) {
+ sock_dump_msg(addr, data, data_size);
+ return addr == PB_MOD_ADDR; // stop processing message if it is sent to myself
+}
+
+bool pb_hook_i2c_recv(const uint8_t * data, size_t data_size) {
+ sock_dump_msg(0x00, data, data_size);
+ return false;
+}
+
+static void sock_fwd_msg(i2c_addr_t addr, const uint8_t * data, size_t data_size) {
if (addr == PB_MOD_ADDR) {
// addressed to me = act as recieved
pb_i2c_recv(data, data_size);
@@ -57,7 +67,7 @@ void recv_handler(struct netconn* conn, struct netbuf* buf) {
if (i2ctcp_read(&recv_msg, data, len) != 0) continue;
// forward received message to puzzle bus
- i2c_recv_fwd(recv_msg.addr, (uint8_t *) recv_msg.data, recv_msg.length);
+ sock_fwd_msg(recv_msg.addr, (uint8_t *) recv_msg.data, recv_msg.length);
free(recv_msg.data);
} while (netbuf_next(buf) >= 0);