-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLutronBridge.h
More file actions
82 lines (55 loc) · 1.61 KB
/
LutronBridge.h
File metadata and controls
82 lines (55 loc) · 1.61 KB
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
72
73
74
75
76
77
78
79
80
81
82
/*
PArticle Library for connecting to Lutron RadioRA2 server
Created December 2015
by Rowan Trollope - hosted on http://github.com/rowantrollope/LutronController
*/
using namespace std;
#include <map>
#include "application.h"
#ifndef LutronBridge_h
#define LutronBridge_h
#define DEFAULT_ON_LEVEL 90
class LUTRON_DEVICE
{
public:
LUTRON_DEVICE(int nID=0, float fCurLevel=0, float fOnLevel=DEFAULT_ON_LEVEL);
int id;
float currentLevel;
float onLevel;
};
typedef void (*notifyFunc)(int id);
typedef std::map<int, LUTRON_DEVICE> DEVICE_MAP;
class LutronBridge {
public:
LutronBridge();
bool connect(byte lutronIP[]);
void disconnect();
os_thread_return_t telnetListener(void* param);
int
initDimmerLevels(int nMax),
setDimmer(String sDimmer),
_setDimmer(int nDimmer, float fLevel),
getDimmer(String sDimmer),
_getDimmer(int nDimmer),
sendCommand(String sCommand),
setAllDimmers(String sCommand);
String getAllDimmers();
void setNotifyCallback(notifyFunc func) { changeCB = func; };
void addDevice(int nDeviceID, LUTRON_DEVICE device);
LUTRON_DEVICE getDevice(int nDeviceID);
void updateDevice(int nDeviceID, LUTRON_DEVICE device);
bool deviceExists(int nDeviceID);
bool m_bMonitor;
private:
Thread *telnetListenerThread;
DEVICE_MAP deviceMap;
notifyFunc changeCB;
TCPClient client;
bool bPublishAll;
};
//----------------
#define LUTRON_READ "?OUTPUT,%i,1"
#define LUTRON_WRITE "#OUTPUT,%i,1,%.2f"
#define LUTRON_RETURN "~OUTPUT,"
#define TELNET_PORT 23
#endif // LutronBridge_h