aboutsummaryrefslogtreecommitdiff
path: root/main/sock.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/sock.c')
-rw-r--r--main/sock.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/main/sock.c b/main/sock.c
index fe932bb..33da03c 100644
--- a/main/sock.c
+++ b/main/sock.c
@@ -5,11 +5,16 @@
#include <lwip/api.h>
#include <string.h>
+#include <FreeRTOS.h>
+#include <queue.h>
+
#include "init.h"
#include "config.h"
#include "i2ctcpv1.h"
#include "sock.h"
+extern QueueHandle_t queue;
+
struct netconn* current_connection = NULL;
i2ctcp_msg_t recv_msg;
@@ -35,15 +40,25 @@ 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) {
+ /*
printf("address: 0x%02x\n", addr);
printf("data: \"%.*s\"\n", data_size, data);
// send message back
char reply[] = "Test message back!";
i2c_send(0x69, reply, strlen(reply));
+ */
// 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("Sending data over i2c");
+ uint8_t i2cData[2] = {addr, 0x00};
+ if(xQueueSend(queue, &i2cData, portMAX_DELAY) == pdPASS) {
+ printf("Socket send data to address: %d, data: %d", i2cData[0], i2cData[1]);
+ }
+
}
void recv_handler(struct netconn* conn, struct netbuf* buf) {
@@ -55,8 +70,10 @@ void recv_handler(struct netconn* conn, struct netbuf* buf) {
netbuf_data(buf, (void**)&data, &len);
// continue early if more data is needed to complete message
+ printf("yeetus deletus defeatus");
if (!i2ctcp_read(&recv_msg, data, len)) continue;
+ printf("yeetus deletus defeatus v2!");
// forward received message to puzzle bus
i2c_recv(recv_msg.addr, recv_msg.data, recv_msg.length);
free(recv_msg.data);