aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-05-18 20:11:44 +0200
committerlonkaars <loek@pipeframe.xyz>2024-05-18 20:11:44 +0200
commit1152ec32b6086c153dc41da59c9c451aa4465995 (patch)
treede696dc61a4566a75b4df1df907cb1a2da25bd82 /main
parentcddfbb715d6f4f9d022d383ab8737b6af57a1d6f (diff)
WIP send/receive w/ msgpack
Diffstat (limited to 'main')
-rw-r--r--main/sock.c8
-rw-r--r--main/sock.h6
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);
+