You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
1.9 KiB
84 lines
1.9 KiB
/*
|
|
* FritzBox Smart Home - C++ interface class
|
|
*/
|
|
|
|
#ifndef _FBSH_H_
|
|
#define _FBSH_H_
|
|
|
|
#include <string>
|
|
#include <list>
|
|
#include <libxml/xmlmemory.h>
|
|
#include <libxml/parser.h>
|
|
#include <UDPTCPNetwork.h>
|
|
|
|
std::string generateMD5 (char* input, int size);
|
|
|
|
#define FB_BUFFER (4*1024*1024)
|
|
|
|
|
|
struct {
|
|
std::string id;
|
|
std::string name;
|
|
std::string others;
|
|
std::string type;
|
|
} typedef FBSmartHomeDevice;
|
|
|
|
|
|
struct {
|
|
int hue;
|
|
int sat;
|
|
int val;
|
|
} typedef FBSmartHomeLightDefaults;
|
|
|
|
|
|
struct {
|
|
std::string id;
|
|
std::string name;
|
|
float temp;
|
|
float temp_cur;
|
|
float temp_set;
|
|
float temp_h;
|
|
float temp_l;
|
|
int offset;
|
|
std::list<float>stats;
|
|
int statsgrid;
|
|
} typedef FBSmartHomeHKR;
|
|
|
|
|
|
class FBSmartHome {
|
|
private:
|
|
char inbuffer[FB_BUFFER];
|
|
char outbuffer[FB_BUFFER];
|
|
|
|
std::string SID;
|
|
FILE *fsidfile;
|
|
std::string hostname;
|
|
TCP tcp;
|
|
|
|
int XMLPrepare(char *buffer, int len, xmlDocPtr *xmldoc, xmlNodePtr *xmlnode);
|
|
|
|
int XMLReadAttr(FBSmartHomeDevice *dev, std::string objPrefix, xmlDocPtr xmldoc, xmlAttrPtr xmlattr);
|
|
int XMLReadOBJ(FBSmartHomeDevice *dev, std::string objPrefix, xmlDocPtr xmldoc, xmlNodePtr xmlobj);
|
|
int XMLReadAndAddDevice(std::list<FBSmartHomeDevice> *devlist, std::string defType, xmlDocPtr xmldoc,
|
|
xmlNodePtr xmlnode);
|
|
public:
|
|
FBSmartHome ();
|
|
~FBSmartHome ();
|
|
|
|
std::string GetSID() { return SID; };
|
|
|
|
int UseSIDFile (std::string fn);
|
|
int CloseSIDFile ();
|
|
|
|
int Connect(std::string host); // return 0 on success
|
|
int Connect(std::string host, std::string username, std::string password);
|
|
int GetHKR(std::string ain, FBSmartHomeHKR *hkr);
|
|
int SimpleOnOff(std::string ain, int oot); // oot 0=off, 1=on, 2=toggle
|
|
int SetLevel(std::string ain, int level); // level 0...255
|
|
int SetColor(std::string ain, int hue, int sat, int duration);
|
|
std::list<FBSmartHomeLightDefaults> *GetColorDefaults (std::string ain);
|
|
std::list<FBSmartHomeDevice> *GetDevices();
|
|
};
|
|
|
|
#endif
|