forked from xkonni/raspberry-remote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
daemon_new.h
55 lines (43 loc) · 1.03 KB
/
daemon_new.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
#ifndef DAEMON_NEW_H
#define DAEMON_NEW_H
#include <list>
#include <map>
#include <string>
#include <sys/stat.h>
#include <unistd.h>
#include "RCSwitch.h"
using namespace std;
enum rcswitch_cmd_t { OFF = 0, ON, STATE };
class RaspberryRemoteDaemon
{
public:
RaspberryRemoteDaemon();
~RaspberryRemoteDaemon();
bool init();
bool serverLoop();
void setInput(string inputStr);
bool parseInput();
void processInput();
unsigned short getPlugAddr();
void dumpPowerStateOn();
static bool daemonize();
private:
bool parseDecimalSystemUnitCode();
bool parseLegacy();
void savePowerState(bool stateOn);
bool getPowerState();
void writePowerStateToSocket();
static bool doFork();
RCSwitch* mRCSwitch;
int mSrvSockFd;
int mCliSockFd;
fd_set mSockFdSet;
unsigned short mSystemCode;
unsigned short mUnitCode;
unsigned short mDelay;
string mRecvStr;
rcswitch_cmd_t mCmd;
list<unsigned short> mPowerState;
map<unsigned short, pair<bool, unsigned short> > mDelayPending;
};
#endif /* DAEMON_NEW_H */