-
Notifications
You must be signed in to change notification settings - Fork 1
/
eISCP.h
44 lines (37 loc) · 1.02 KB
/
eISCP.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
#ifndef eISCP_h
#define eISCP_h
#include "Arduino.h"
#include "Client.h"
#define eISCP_REQUEST_TIMEOUT 500
// Header structure based on https://github.com/miracle2k/onkyo-eiscp/blob/master/eiscp/core.py
typedef struct __attribute__ ((packed)) {
char magic[4] = {'I', 'S', 'C', 'P'};
uint32_t size_header = __builtin_bswap32(16);
uint32_t size_body = __builtin_bswap32(0);
signed char version = 0x01;
char reserved[3] = {'\x00','\x00','\x00'};
} eISCP_Header;
class eISCP_Message {
public:
eISCP_Message(String _content = "");
String encode();
void decode(char* cmsg);
String content;
bool valid;
};
class eISCP {
public:
eISCP(const char ip_address[], int port, Client* client);
bool send(String command);
bool connected();
void set_callback(void (*_callback)(eISCP_Message));
void handle();
private:
void get_packet();
bool send_packet(eISCP_Message* message);
void (*callback)(eISCP_Message);
Client* client;
const char* ip_address;
int port;
};
#endif