diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/sock.c | 8 | ||||
-rw-r--r-- | main/sock.h | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/main/sock.c b/main/sock.c index 7064de7..dac62af 100644 --- a/main/sock.c +++ b/main/sock.c @@ -5,9 +5,10 @@ #include <lwip/api.h> #include "init.h" - #include "config.h" +struct netconn* current_connection = NULL; + void recv_handler(struct netconn* conn, struct netbuf* buf) { void *data; uint16_t len; @@ -21,17 +22,16 @@ void recv_handler(struct netconn* conn, struct netbuf* buf) { } void accept_handler(struct netconn* conn) { - printf("new connection!\n"); + current_connection = conn; struct netbuf* buf; - while (netconn_recv(conn, &buf) == ERR_OK) recv_handler(conn, buf); netconn_close(conn); netconn_delete(conn); - printf("connection closed!\n"); + current_connection = NULL; } void serve_task() { diff --git a/main/sock.h b/main/sock.h index dd7fc61..2a73418 100644 --- a/main/sock.h +++ b/main/sock.h @@ -1,5 +1,11 @@ #pragma once +#include <stdint.h> +#include <stddef.h> + /** \brief start listening for TCP socket requests */ void serve_task(); +void i2c_send(uint16_t addr, char* data, size_t data_size); +void i2c_recv(uint16_t addr, char* data, size_t data_size); + |