aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-05-21 10:30:06 +0200
committerlonkaars <loek@pipeframe.xyz>2024-05-21 10:30:06 +0200
commit68a5c65f9b0e1df30e9cef490d9b218b2f21f90d (patch)
tree804ec0edc0769764b0a090703cf784c2ac7a6f5c /client
parentdb8906d54cd9afbc57f0b40a0d618335c552f704 (diff)
clean up puzbusv1 API
Diffstat (limited to 'client')
-rw-r--r--client/sock.cpp12
-rw-r--r--client/sock.h13
2 files changed, 12 insertions, 13 deletions
diff --git a/client/sock.cpp b/client/sock.cpp
index cc18a69..f967f64 100644
--- a/client/sock.cpp
+++ b/client/sock.cpp
@@ -18,7 +18,7 @@ using std::logic_error;
using std::thread;
PBSocket::PBSocket() { }
-PBSocket::PBSocket(char* addr, uint16_t port) : PBSocket() {
+PBSocket::PBSocket(const char * addr, uint16_t port) : PBSocket() {
set_server(addr, port);
}
@@ -32,7 +32,7 @@ PBSocket::~PBSocket() {
sock_close();
}
-void PBSocket::set_server(char* addr, uint16_t port) {
+void PBSocket::set_server(const char * addr, uint16_t port) {
_addr = addr;
_port = port;
}
@@ -67,7 +67,7 @@ void PBSocket::sock_close() {
_fd = -1;
}
-void PBSocket::send(char* buf, size_t buf_sz) {
+void PBSocket::send(const char * buf, size_t buf_sz) {
write(_fd, buf, buf_sz);
}
@@ -105,10 +105,10 @@ void PBSocket::sock_task() {
sock_close();
}
-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) {
struct pb_msg msg = {
.addr = addr,
- .data = data,
+ .data = (char *) data,
.length = data_size,
};
@@ -119,7 +119,7 @@ void i2c_send(uint16_t addr, char* data, size_t data_size) {
sock->send(packed, size);
}
-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) {
rl_printf("[0x%02x]: %.*s\n", addr, data_size, data);
}
diff --git a/client/sock.h b/client/sock.h
index 818ea72..42eba3b 100644
--- a/client/sock.h
+++ b/client/sock.h
@@ -6,14 +6,14 @@
class PBSocket {
public:
PBSocket();
- PBSocket(char* addr, uint16_t port);
+ PBSocket(const char * addr, uint16_t port);
virtual ~PBSocket();
- void set_server(char* addr, uint16_t port);
+ void set_server(const char * addr, uint16_t port);
void sock_connect();
- void send(char* buf, size_t buf_sz);
+ void send(const char * buf, size_t buf_sz);
private:
void sock_task();
@@ -21,15 +21,14 @@ private:
std::thread* _thread = nullptr;
- char* _addr = NULL;
+ const char * _addr = NULL;
uint16_t _port = 0;
int _fd = -1;
-
};
extern PBSocket* sock;
-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);