aboutsummaryrefslogtreecommitdiff
path: root/client/sock.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-05-25 18:30:13 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-05-25 18:30:13 +0200
commit4525f60f29359b7ba88e47880d79fb9869913656 (patch)
treed6fa4be85ddfcee9861304eee53660bff7487d26 /client/sock.h
parent4fc192eb9ba949276c47c1bbd86164d955d3548c (diff)
parent5d5b186a5a82b7e2415eddd77ef93af851034a5b (diff)
Merge branch 'wip/main-controller' into wip/i2c-communication
Diffstat (limited to 'client/sock.h')
-rw-r--r--client/sock.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/client/sock.h b/client/sock.h
new file mode 100644
index 0000000..42eba3b
--- /dev/null
+++ b/client/sock.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <cstdint>
+#include <thread>
+
+class PBSocket {
+public:
+ PBSocket();
+ PBSocket(const char * addr, uint16_t port);
+ virtual ~PBSocket();
+
+ void set_server(const char * addr, uint16_t port);
+
+ void sock_connect();
+
+ void send(const char * buf, size_t buf_sz);
+
+private:
+ void sock_task();
+ void sock_close();
+
+ std::thread* _thread = nullptr;
+
+ const char * _addr = NULL;
+ uint16_t _port = 0;
+
+ int _fd = -1;
+};
+
+extern PBSocket* sock;
+
+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);
+