diff options
Diffstat (limited to 'main/sock.c')
-rw-r--r-- | main/sock.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/main/sock.c b/main/sock.c index 0755a5d..08bec6b 100644 --- a/main/sock.c +++ b/main/sock.c @@ -11,8 +11,7 @@ #include "sock.h" #include <hardware/i2c.h> -extern QueueHandle_t queue; - +extern uint8_t found[MAX_SLAVES]; struct netconn* current_connection = NULL; i2ctcp_msg_t recv_msg; @@ -40,26 +39,27 @@ void i2c_send(uint16_t addr, const char * data, size_t data_size) { void i2c_recv(uint16_t addr, const char * data, size_t data_size) { // TODO: this function should forward the recieved message onto the puzzle // bus instead of printing/replying - // using queueu -> i2c_write only accepts uint8_t addr, and uint8_t data ._. printf("Addr: %lu, Data: %c, Data_size: %lu\n", addr, data[0], data_size); i2c_write_blocking(i2c0, addr, data, data_size, false); } void recv_handler(struct netconn* conn, struct netbuf* buf) { - i2ctcp_read_reset(&recv_msg); + // i2ctcp_read_reset(&recv_msg); do { char* data; uint16_t len; netbuf_data(buf, (void**)&data, &len); + + scan_bus(found); // continue early if more data is needed to complete message - if (i2ctcp_read(&recv_msg, data, len) > 0) continue; + // if (i2ctcp_read(&recv_msg, data, len) > 0) continue; // forward received message to puzzle bus - i2c_recv(recv_msg.addr, recv_msg.data, recv_msg.length); - free(recv_msg.data); + // i2c_recv(recv_msg.addr, recv_msg.data, recv_msg.length); + // free(recv_msg.data); } while (netbuf_next(buf) >= 0); netbuf_delete(buf); |