-
Notifications
You must be signed in to change notification settings - Fork 41
/
PlainConnection.h
45 lines (37 loc) · 1.01 KB
/
PlainConnection.h
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
36
37
38
39
40
41
42
43
44
45
#ifndef PLAINCONNECTION_H
#define PLAINCONNECTION_H
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include "win32shim.h"
#else
#include <unistd.h> // for size_t
#endif
#include <cstdint> // for uint8_t
#include <functional> // for function
#include <string> // for string
#include <vector> // for vector
typedef std::function<bool()> timeoutCallback;
namespace cspot {
class PlainConnection {
public:
PlainConnection();
~PlainConnection();
/**
* @brief Connect to the given AP address
*
* @param apAddress The AP url to connect to
*/
void connect(const std::string& apAddress);
void close();
timeoutCallback timeoutHandler;
std::vector<uint8_t> sendPrefixPacket(const std::vector<uint8_t>& prefix,
const std::vector<uint8_t>& data);
std::vector<uint8_t> recvPacket();
void readBlock(const uint8_t* dst, size_t size);
size_t writeBlock(const std::vector<uint8_t>& data);
private:
int apSock;
};
} // namespace cspot
#endif