aboutsummaryrefslogtreecommitdiff
path: root/client/sock.h
blob: 818ea7247935bf71881b623cf6ee822a71dc8846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include <cstdint>
#include <thread>

class PBSocket {
public:
	PBSocket();
	PBSocket(char* addr, uint16_t port);
	virtual ~PBSocket();

	void set_server(char* addr, uint16_t port);

	void sock_connect();

	void send(char* buf, size_t buf_sz);

private:
	void sock_task();
	void sock_close();

	std::thread* _thread = nullptr;

	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);