-
Notifications
You must be signed in to change notification settings - Fork 3
/
SteamLinkPaho.h
71 lines (50 loc) · 1.54 KB
/
SteamLinkPaho.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef STEAMLINKPAHO_H
#define STEAMLINKPAHO_H
#ifdef UNIX
#include <math.h>
#include <SteamLinkGeneric.h>
#include <SteamLink.h>
#include <memory.h>
#include "MQTTClient.h"
#define DEFAULT_STACK_SIZE -1
#include "linux.cpp"
#define SL_PAHO_DEFAULT_TOPIC_LEN 100
#define SL_PAHO_MAX_MESSAGE_LEN 255
struct SteamLinkPahoConfig {
bool encrypted;
uint8_t *key;
const char *sl_server;
uint16_t sl_serverport;
const char *sl_username;
const char *sl_conid;
const char *sl_key;
const char *sl_server_fingerprint;
};
class SteamLinkPaho : public SteamLinkGeneric {
public:
/// constructor
SteamLinkPaho(SL_NodeCfgStruct *config);
virtual void init(void *vconf, uint8_t config_length);
/// send
virtual bool driver_send(uint8_t* packet, uint8_t packet_length, uint32_t slid);
/// receive
virtual bool driver_receive(uint8_t* &packet, uint8_t &packet_size, uint32_t &slid);
private:
// config info
struct SteamLinkPahoConfig *_conf;
char _pub_str[SL_PAHO_DEFAULT_TOPIC_LEN];
char _sub_str[SL_PAHO_DEFAULT_TOPIC_LEN];
IPStack* _ipstack;
MQTT::Client<IPStack, Countdown>* _client;
MQTTPacket_connectData _data = MQTTPacket_connectData_initializer;
bool mqtt_connect();
void create_pub_str(char* topic, uint32_t slid);
void create_sub_str(char* topic, uint32_t slid);
static void _sub_callback(MQTT::MessageData& md);
// TODO: use queue?
static uint8_t driverbuffer[SL_PAHO_MAX_MESSAGE_LEN];
static uint8_t rcvlen;
static bool available;
};
#endif // ifdef UNIX
#endif // ifdef STEAMLINKPAHO_H