aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/sock.c10
-rw-r--r--main/sock.h4
2 files changed, 8 insertions, 6 deletions
diff --git a/main/sock.c b/main/sock.c
index 705e2eb..4f50981 100644
--- a/main/sock.c
+++ b/main/sock.c
@@ -13,16 +13,16 @@
struct netconn* current_connection = NULL;
struct pb_msg recv_msg;
-void i2c_send(uint16_t addr, char* data, size_t data_size) {
+void i2c_send(uint16_t addr, const char * data, size_t data_size) {
if (current_connection == NULL) return;
struct pb_msg send_msg = {
.addr = addr,
- .data = data,
+ .data = (char *) data,
.length = data_size,
};
- char* buf;
+ char * buf;
size_t buf_sz;
if (!pb_write(&send_msg, &buf, &buf_sz)) return;
@@ -34,7 +34,7 @@ void i2c_send(uint16_t addr, char* data, size_t data_size) {
free(buf);
}
-void i2c_recv(uint16_t addr, char* data, size_t data_size) {
+void i2c_recv(uint16_t addr, const char * data, size_t data_size) {
printf("address: 0x%02x\n", addr);
printf("data: \"%.*s\"\n", data_size, data);
@@ -47,6 +47,8 @@ void i2c_recv(uint16_t addr, char* data, size_t data_size) {
}
void recv_handler(struct netconn* conn, struct netbuf* buf) {
+ pb_read_reset(&recv_msg);
+
do {
char* data;
uint16_t len;
diff --git a/main/sock.h b/main/sock.h
index 2a73418..f2db35d 100644
--- a/main/sock.h
+++ b/main/sock.h
@@ -6,6 +6,6 @@
/** \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);
+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);