aboutsummaryrefslogtreecommitdiff
path: root/main/sock.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/sock.c')
-rw-r--r--main/sock.c10
1 files changed, 6 insertions, 4 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;