Initial commit
This commit is contained in:
commit
12f2c3eeee
78 changed files with 4776 additions and 0 deletions
267
external/tellstick-core/Protocol.cpp
vendored
Normal file
267
external/tellstick-core/Protocol.cpp
vendored
Normal file
|
|
@ -0,0 +1,267 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/Protocol.h"
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "client/telldus-core.h"
|
||||
#include "service/ControllerMessage.h"
|
||||
#include "service/ProtocolBrateck.h"
|
||||
#include "service/ProtocolComen.h"
|
||||
#include "service/ProtocolEverflourish.h"
|
||||
#include "service/ProtocolFineoffset.h"
|
||||
#include "service/ProtocolFuhaote.h"
|
||||
#include "service/ProtocolGroup.h"
|
||||
#include "service/ProtocolHasta.h"
|
||||
#include "service/ProtocolIkea.h"
|
||||
#include "service/ProtocolMandolyn.h"
|
||||
#include "service/ProtocolNexa.h"
|
||||
#include "service/ProtocolOregon.h"
|
||||
#include "service/ProtocolRisingSun.h"
|
||||
#include "service/ProtocolSartano.h"
|
||||
#include "service/ProtocolScene.h"
|
||||
#include "service/ProtocolSilvanChip.h"
|
||||
#include "service/ProtocolUpm.h"
|
||||
#include "service/ProtocolWaveman.h"
|
||||
#include "service/ProtocolX10.h"
|
||||
#include "service/ProtocolYidong.h"
|
||||
#include "common/Strings.h"
|
||||
|
||||
class Protocol::PrivateData {
|
||||
public:
|
||||
ParameterMap parameterList;
|
||||
std::wstring model;
|
||||
};
|
||||
|
||||
Protocol::Protocol() {
|
||||
d = new PrivateData;
|
||||
}
|
||||
|
||||
Protocol::~Protocol(void) {
|
||||
delete d;
|
||||
}
|
||||
|
||||
std::wstring Protocol::model() const {
|
||||
std::wstring strModel = d->model;
|
||||
// Strip anything after : if it is found
|
||||
size_t pos = strModel.find(L":");
|
||||
if (pos != std::wstring::npos) {
|
||||
strModel = strModel.substr(0, pos);
|
||||
}
|
||||
|
||||
return strModel;
|
||||
}
|
||||
|
||||
void Protocol::setModel(const std::wstring &model) {
|
||||
d->model = model;
|
||||
}
|
||||
|
||||
void Protocol::setParameters(const ParameterMap ¶meterList) {
|
||||
d->parameterList = parameterList;
|
||||
}
|
||||
|
||||
std::wstring Protocol::getStringParameter(const std::wstring &name, const std::wstring &defaultValue) const {
|
||||
ParameterMap::const_iterator it = d->parameterList.find(name);
|
||||
if (it == d->parameterList.end()) {
|
||||
return defaultValue;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
int Protocol::getIntParameter(const std::wstring &name, int min, int max) const {
|
||||
std::wstring value = getStringParameter(name, L"");
|
||||
if (value == L"") {
|
||||
return min;
|
||||
}
|
||||
std::wstringstream st;
|
||||
st << value;
|
||||
int intValue = 0;
|
||||
st >> intValue;
|
||||
if (intValue < min) {
|
||||
return min;
|
||||
}
|
||||
if (intValue > max) {
|
||||
return max;
|
||||
}
|
||||
return intValue;
|
||||
}
|
||||
|
||||
bool Protocol::checkBit(int data, int bitno) {
|
||||
return ((data >> bitno)&0x01);
|
||||
}
|
||||
|
||||
|
||||
Protocol *Protocol::getProtocolInstance(const std::wstring &protocolname) {
|
||||
if(TelldusCore::comparei(protocolname, L"arctech")) {
|
||||
return new ProtocolNexa();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"brateck")) {
|
||||
return new ProtocolBrateck();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"comen")) {
|
||||
return new ProtocolComen();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"everflourish")) {
|
||||
return new ProtocolEverflourish();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"fuhaote")) {
|
||||
return new ProtocolFuhaote();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"hasta")) {
|
||||
return new ProtocolHasta();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"ikea")) {
|
||||
return new ProtocolIkea();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"risingsun")) {
|
||||
return new ProtocolRisingSun();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"sartano")) {
|
||||
return new ProtocolSartano();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"silvanchip")) {
|
||||
return new ProtocolSilvanChip();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"upm")) {
|
||||
return new ProtocolUpm();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"waveman")) {
|
||||
return new ProtocolWaveman();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"x10")) {
|
||||
return new ProtocolX10();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"yidong")) {
|
||||
return new ProtocolYidong();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"group")) {
|
||||
return new ProtocolGroup();
|
||||
|
||||
} else if (TelldusCore::comparei(protocolname, L"scene")) {
|
||||
return new ProtocolScene();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::list<std::string> Protocol::getParametersForProtocol(const std::wstring &protocolName) {
|
||||
std::list<std::string> parameters;
|
||||
if(TelldusCore::comparei(protocolName, L"arctech")) {
|
||||
parameters.push_back("house");
|
||||
parameters.push_back("unit");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"brateck")) {
|
||||
parameters.push_back("house");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"comen")) {
|
||||
parameters.push_back("house");
|
||||
parameters.push_back("unit");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"everflourish")) {
|
||||
parameters.push_back("house");
|
||||
parameters.push_back("unit");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"fuhaote")) {
|
||||
parameters.push_back("code");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"hasta")) {
|
||||
parameters.push_back("house");
|
||||
parameters.push_back("unit");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"ikea")) {
|
||||
parameters.push_back("system");
|
||||
parameters.push_back("units");
|
||||
// parameters.push_back("fade");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"risingsun")) {
|
||||
parameters.push_back("house");
|
||||
parameters.push_back("unit");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"sartano")) {
|
||||
parameters.push_back("code");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"silvanchip")) {
|
||||
parameters.push_back("house");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"upm")) {
|
||||
parameters.push_back("house");
|
||||
parameters.push_back("unit");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"waveman")) {
|
||||
parameters.push_back("house");
|
||||
parameters.push_back("unit");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"x10")) {
|
||||
parameters.push_back("house");
|
||||
parameters.push_back("unit");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"yidong")) {
|
||||
parameters.push_back("unit");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"group")) {
|
||||
parameters.push_back("devices");
|
||||
|
||||
} else if (TelldusCore::comparei(protocolName, L"scene")) {
|
||||
parameters.push_back("devices");
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
std::list<std::string> Protocol::decodeData(const std::string &fullData) {
|
||||
std::list<std::string> retval;
|
||||
std::string decoded = "";
|
||||
|
||||
ControllerMessage dataMsg(fullData);
|
||||
if( TelldusCore::comparei(dataMsg.protocol(), L"arctech") ) {
|
||||
decoded = ProtocolNexa::decodeData(dataMsg);
|
||||
if (decoded != "") {
|
||||
retval.push_back(decoded);
|
||||
}
|
||||
decoded = ProtocolWaveman::decodeData(dataMsg);
|
||||
if (decoded != "") {
|
||||
retval.push_back(decoded);
|
||||
}
|
||||
decoded = ProtocolSartano::decodeData(dataMsg);
|
||||
if (decoded != "") {
|
||||
retval.push_back(decoded);
|
||||
}
|
||||
} else if(TelldusCore::comparei(dataMsg.protocol(), L"everflourish") ) {
|
||||
decoded = ProtocolEverflourish::decodeData(dataMsg);
|
||||
if (decoded != "") {
|
||||
retval.push_back(decoded);
|
||||
}
|
||||
} else if(TelldusCore::comparei(dataMsg.protocol(), L"fineoffset") ) {
|
||||
decoded = ProtocolFineoffset::decodeData(dataMsg);
|
||||
if (decoded != "") {
|
||||
retval.push_back(decoded);
|
||||
}
|
||||
} else if(TelldusCore::comparei(dataMsg.protocol(), L"mandolyn") ) {
|
||||
decoded = ProtocolMandolyn::decodeData(dataMsg);
|
||||
if (decoded != "") {
|
||||
retval.push_back(decoded);
|
||||
}
|
||||
} else if(TelldusCore::comparei(dataMsg.protocol(), L"oregon") ) {
|
||||
decoded = ProtocolOregon::decodeData(dataMsg);
|
||||
if (decoded != "") {
|
||||
retval.push_back(decoded);
|
||||
}
|
||||
} else if(TelldusCore::comparei(dataMsg.protocol(), L"x10") ) {
|
||||
decoded = ProtocolX10::decodeData(dataMsg);
|
||||
if (decoded != "") {
|
||||
retval.push_back(decoded);
|
||||
}
|
||||
} else if(TelldusCore::comparei(dataMsg.protocol(), L"hasta") ) {
|
||||
decoded = ProtocolHasta::decodeData(dataMsg);
|
||||
if (decoded != "") {
|
||||
retval.push_back(decoded);
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
46
external/tellstick-core/Protocol.h
vendored
Normal file
46
external/tellstick-core/Protocol.h
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOL_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOL_H_
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include "client/telldus-core.h"
|
||||
|
||||
typedef std::map<std::wstring, std::wstring> ParameterMap;
|
||||
|
||||
class Controller;
|
||||
|
||||
class Protocol {
|
||||
public:
|
||||
Protocol();
|
||||
virtual ~Protocol(void);
|
||||
|
||||
static Protocol *getProtocolInstance(const std::wstring &protocolname);
|
||||
static std::list<std::string> getParametersForProtocol(const std::wstring &protocolName);
|
||||
static std::list<std::string> decodeData(const std::string &fullData);
|
||||
|
||||
virtual int methods() const = 0;
|
||||
std::wstring model() const;
|
||||
void setModel(const std::wstring &model);
|
||||
void setParameters(const ParameterMap ¶meterList);
|
||||
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller) = 0;
|
||||
|
||||
protected:
|
||||
virtual std::wstring getStringParameter(const std::wstring &name, const std::wstring &defaultValue = L"") const;
|
||||
virtual int getIntParameter(const std::wstring &name, int min, int max) const;
|
||||
|
||||
static bool checkBit(int data, int bit);
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
PrivateData *d;
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOL_H_
|
||||
53
external/tellstick-core/ProtocolBrateck.cpp
vendored
Normal file
53
external/tellstick-core/ProtocolBrateck.cpp
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolBrateck.h"
|
||||
#include <string>
|
||||
|
||||
int ProtocolBrateck::methods() const {
|
||||
return TELLSTICK_UP | TELLSTICK_DOWN | TELLSTICK_STOP;
|
||||
}
|
||||
|
||||
std::string ProtocolBrateck::getStringForMethod(int method, unsigned char, Controller *) {
|
||||
const char S = '!';
|
||||
const char L = 'V';
|
||||
const char B1[] = {L, S, L, S, 0};
|
||||
const char BX[] = {S, L, L, S, 0};
|
||||
const char B0[] = {S, L, S, L, 0};
|
||||
const char BUP[] = {L, S, L, S, S, L, S, L, S, L, S, L, S, L, S, L, S, 0};
|
||||
const char BSTOP[] = {S, L, S, L, L, S, L, S, S, L, S, L, S, L, S, L, S, 0};
|
||||
const char BDOWN[] = {S, L, S, L, S, L, S, L, S, L, S, L, L, S, L, S, S, 0};
|
||||
|
||||
std::string strReturn;
|
||||
std::wstring strHouse = this->getStringParameter(L"house", L"");
|
||||
if (strHouse == L"") {
|
||||
return "";
|
||||
}
|
||||
|
||||
for( size_t i = 0; i < strHouse.length(); ++i ) {
|
||||
if (strHouse[i] == '1') {
|
||||
strReturn.insert(0, B1);
|
||||
} else if (strHouse[i] == '-') {
|
||||
strReturn.insert(0, BX);
|
||||
} else if (strHouse[i] == '0') {
|
||||
strReturn.insert(0, B0);
|
||||
}
|
||||
}
|
||||
|
||||
strReturn.insert(0, "S");
|
||||
if (method == TELLSTICK_UP) {
|
||||
strReturn.append(BUP);
|
||||
} else if (method == TELLSTICK_DOWN) {
|
||||
strReturn.append(BDOWN);
|
||||
} else if (method == TELLSTICK_STOP) {
|
||||
strReturn.append(BSTOP);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
strReturn.append("+");
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
19
external/tellstick-core/ProtocolBrateck.h
vendored
Normal file
19
external/tellstick-core/ProtocolBrateck.h
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLBRATECK_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLBRATECK_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
|
||||
class ProtocolBrateck : public Protocol {
|
||||
public:
|
||||
int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLBRATECK_H_
|
||||
23
external/tellstick-core/ProtocolComen.cpp
vendored
Normal file
23
external/tellstick-core/ProtocolComen.cpp
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolComen.h"
|
||||
#include <string>
|
||||
|
||||
int ProtocolComen::methods() const {
|
||||
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN);
|
||||
}
|
||||
|
||||
int ProtocolComen::getIntParameter(const std::wstring &name, int min, int max) const {
|
||||
if (name.compare(L"house") == 0) {
|
||||
int intHouse = Protocol::getIntParameter(L"house", 1, 16777215);
|
||||
// The last two bits must be hardcoded
|
||||
intHouse <<= 2;
|
||||
intHouse += 2;
|
||||
return intHouse;
|
||||
}
|
||||
return Protocol::getIntParameter(name, min, max);
|
||||
}
|
||||
21
external/tellstick-core/ProtocolComen.h
vendored
Normal file
21
external/tellstick-core/ProtocolComen.h
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLCOMEN_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLCOMEN_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/ProtocolNexa.h"
|
||||
|
||||
class ProtocolComen : public ProtocolNexa {
|
||||
public:
|
||||
virtual int methods() const;
|
||||
|
||||
protected:
|
||||
virtual int getIntParameter(const std::wstring &name, int min, int max) const;
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLCOMEN_H_
|
||||
133
external/tellstick-core/ProtocolEverflourish.cpp
vendored
Normal file
133
external/tellstick-core/ProtocolEverflourish.cpp
vendored
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolEverflourish.h"
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "service/ControllerMessage.h"
|
||||
|
||||
int ProtocolEverflourish::methods() const {
|
||||
return TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN;
|
||||
}
|
||||
|
||||
std::string ProtocolEverflourish::getStringForMethod(int method, unsigned char, Controller *) {
|
||||
unsigned int deviceCode = this->getIntParameter(L"house", 0, 16383);
|
||||
unsigned int intCode = this->getIntParameter(L"unit", 1, 4)-1;
|
||||
unsigned char action;
|
||||
|
||||
if (method == TELLSTICK_TURNON) {
|
||||
action = 15;
|
||||
} else if (method == TELLSTICK_TURNOFF) {
|
||||
action = 0;
|
||||
} else if (method == TELLSTICK_LEARN) {
|
||||
action = 10;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
const char ssss = 85;
|
||||
const char sssl = 84; // 0
|
||||
const char slss = 69; // 1
|
||||
|
||||
const char bits[2] = {sssl, slss};
|
||||
int i, check;
|
||||
|
||||
std::string strCode;
|
||||
|
||||
deviceCode = (deviceCode << 2) | intCode;
|
||||
|
||||
check = calculateChecksum(deviceCode);
|
||||
|
||||
char preamble[] = {'R', 5, 'T', 114, 60, 1, 1, 105, ssss, ssss, 0};
|
||||
strCode.append(preamble);
|
||||
|
||||
for(i = 15; i >= 0; i--) {
|
||||
strCode.append(1, bits[(deviceCode >> i)&0x01]);
|
||||
}
|
||||
for(i = 3; i >= 0; i--) {
|
||||
strCode.append(1, bits[(check >> i)&0x01]);
|
||||
}
|
||||
for(i = 3; i >= 0; i--) {
|
||||
strCode.append(1, bits[(action >> i)&0x01]);
|
||||
}
|
||||
|
||||
strCode.append(1, ssss);
|
||||
strCode.append(1, '+');
|
||||
|
||||
return strCode;
|
||||
}
|
||||
|
||||
// The calculation used in this function is provided by Frank Stevenson
|
||||
unsigned int ProtocolEverflourish::calculateChecksum(unsigned int x) {
|
||||
unsigned int bits[16] = {
|
||||
0xf, 0xa, 0x7, 0xe,
|
||||
0xf, 0xd, 0x9, 0x1,
|
||||
0x1, 0x2, 0x4, 0x8,
|
||||
0x3, 0x6, 0xc, 0xb
|
||||
};
|
||||
unsigned int bit = 1;
|
||||
unsigned int res = 0x5;
|
||||
int i;
|
||||
unsigned int lo, hi;
|
||||
|
||||
if ((x & 0x3) == 3) {
|
||||
lo = x & 0x00ff;
|
||||
hi = x & 0xff00;
|
||||
lo += 4;
|
||||
if (lo>0x100) {
|
||||
lo = 0x12;
|
||||
}
|
||||
x = lo | hi;
|
||||
}
|
||||
|
||||
for(i = 0; i < 16; i++) {
|
||||
if (x & bit) {
|
||||
res = res ^ bits[i];
|
||||
}
|
||||
bit = bit << 1;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string ProtocolEverflourish::decodeData(const ControllerMessage &dataMsg) {
|
||||
uint64_t allData;
|
||||
unsigned int house = 0;
|
||||
unsigned int unit = 0;
|
||||
unsigned int method = 0;
|
||||
|
||||
allData = dataMsg.getInt64Parameter("data");
|
||||
|
||||
house = allData & 0xFFFC00;
|
||||
house >>= 10;
|
||||
|
||||
unit = allData & 0x300;
|
||||
unit >>= 8;
|
||||
unit++; // unit from 1 to 4
|
||||
|
||||
method = allData & 0xF;
|
||||
|
||||
if(house > 16383 || unit < 1 || unit > 4) {
|
||||
// not everflourish
|
||||
return "";
|
||||
}
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:command;protocol:everflourish;model:selflearning;house:" << house << ";unit:" << unit << ";method:";
|
||||
if(method == 0) {
|
||||
retString << "turnoff;";
|
||||
} else if(method == 15) {
|
||||
retString << "turnon;";
|
||||
} else if(method == 10) {
|
||||
retString << "learn;";
|
||||
} else {
|
||||
// not everflourish
|
||||
return "";
|
||||
}
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
24
external/tellstick-core/ProtocolEverflourish.h
vendored
Normal file
24
external/tellstick-core/ProtocolEverflourish.h
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLEVERFLOURISH_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLEVERFLOURISH_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
#include "service/ControllerMessage.h"
|
||||
|
||||
class ProtocolEverflourish : public Protocol {
|
||||
public:
|
||||
int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
static std::string decodeData(const ControllerMessage &dataMsg);
|
||||
|
||||
private:
|
||||
static unsigned int calculateChecksum(unsigned int x);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLEVERFLOURISH_H_
|
||||
52
external/tellstick-core/ProtocolFineoffset.cpp
vendored
Normal file
52
external/tellstick-core/ProtocolFineoffset.cpp
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolFineoffset.h"
|
||||
#include <stdlib.h>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "common/Strings.h"
|
||||
|
||||
std::string ProtocolFineoffset::decodeData(const ControllerMessage &dataMsg) {
|
||||
std::string data = dataMsg.getParameter("data");
|
||||
if (data.length() < 8) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Checksum currently not used
|
||||
// uint8_t checksum = (uint8_t)TelldusCore::hexTo64l(data.substr(data.length()-2));
|
||||
data = data.substr(0, data.length()-2);
|
||||
|
||||
uint8_t humidity = (uint8_t)TelldusCore::hexTo64l(data.substr(data.length()-2));
|
||||
data = data.substr(0, data.length()-2);
|
||||
|
||||
uint16_t value = (uint16_t)TelldusCore::hexTo64l(data.substr(data.length()-3));
|
||||
double temperature = (value & 0x7FF)/10.0;
|
||||
|
||||
value >>= 11;
|
||||
if (value & 1) {
|
||||
temperature = -temperature;
|
||||
}
|
||||
data = data.substr(0, data.length()-3);
|
||||
|
||||
uint16_t id = (uint16_t)TelldusCore::hexTo64l(data) & 0xFF;
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:sensor;protocol:fineoffset;id:" << id << ";model:";
|
||||
|
||||
if (humidity <= 100) {
|
||||
retString << "temperaturehumidity;humidity:" << static_cast<int>(humidity) << ";";
|
||||
} else if (humidity == 0xFF) {
|
||||
retString << "temperature;";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
retString << "temp:" << std::fixed << std::setprecision(1) << temperature << ";";
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
19
external/tellstick-core/ProtocolFineoffset.h
vendored
Normal file
19
external/tellstick-core/ProtocolFineoffset.h
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLFINEOFFSET_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLFINEOFFSET_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
#include "service/ControllerMessage.h"
|
||||
|
||||
class ProtocolFineoffset : public Protocol {
|
||||
public:
|
||||
static std::string decodeData(const ControllerMessage &dataMsg);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLFINEOFFSET_H_
|
||||
60
external/tellstick-core/ProtocolFuhaote.cpp
vendored
Normal file
60
external/tellstick-core/ProtocolFuhaote.cpp
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolFuhaote.h"
|
||||
#include <string>
|
||||
|
||||
int ProtocolFuhaote::methods() const {
|
||||
return TELLSTICK_TURNON | TELLSTICK_TURNOFF;
|
||||
}
|
||||
|
||||
std::string ProtocolFuhaote::getStringForMethod(int method, unsigned char, Controller *) {
|
||||
const char S = 19;
|
||||
const char L = 58;
|
||||
const char B0[] = {S, L, L, S, 0};
|
||||
const char B1[] = {L, S, L, S, 0};
|
||||
const char OFF[] = {S, L, S, L, S, L, L, S, 0};
|
||||
const char ON[] = {S, L, L, S, S, L, S, L, 0};
|
||||
|
||||
std::string strReturn = "S";
|
||||
std::wstring strCode = this->getStringParameter(L"code", L"");
|
||||
if (strCode == L"") {
|
||||
return "";
|
||||
}
|
||||
|
||||
// House code
|
||||
for(size_t i = 0; i < 5; ++i) {
|
||||
if (strCode[i] == '0') {
|
||||
strReturn.append(B0);
|
||||
} else if (strCode[i] == '1') {
|
||||
strReturn.append(B1);
|
||||
}
|
||||
}
|
||||
// Unit code
|
||||
for(size_t i = 5; i < 10; ++i) {
|
||||
if (strCode[i] == '0') {
|
||||
strReturn.append(B0);
|
||||
} else if (strCode[i] == '1') {
|
||||
strReturn.append(1, S);
|
||||
strReturn.append(1, L);
|
||||
strReturn.append(1, S);
|
||||
strReturn.append(1, L);
|
||||
}
|
||||
}
|
||||
|
||||
if (method == TELLSTICK_TURNON) {
|
||||
strReturn.append(ON);
|
||||
} else if (method == TELLSTICK_TURNOFF) {
|
||||
strReturn.append(OFF);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
strReturn.append(1, S);
|
||||
strReturn.append("+");
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
19
external/tellstick-core/ProtocolFuhaote.h
vendored
Normal file
19
external/tellstick-core/ProtocolFuhaote.h
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLFUHAOTE_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLFUHAOTE_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
|
||||
class ProtocolFuhaote : public Protocol {
|
||||
public:
|
||||
int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLFUHAOTE_H_
|
||||
16
external/tellstick-core/ProtocolGroup.cpp
vendored
Normal file
16
external/tellstick-core/ProtocolGroup.cpp
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolGroup.h"
|
||||
#include <string>
|
||||
|
||||
int ProtocolGroup::methods() const {
|
||||
return TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM | TELLSTICK_BELL | TELLSTICK_LEARN | TELLSTICK_EXECUTE | TELLSTICK_TOGGLE | TELLSTICK_UP | TELLSTICK_DOWN | TELLSTICK_STOP;
|
||||
}
|
||||
|
||||
std::string ProtocolGroup::getStringForMethod(int method, unsigned char data, Controller *) {
|
||||
return "";
|
||||
}
|
||||
22
external/tellstick-core/ProtocolGroup.h
vendored
Normal file
22
external/tellstick-core/ProtocolGroup.h
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLGROUP_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLGROUP_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
|
||||
class ProtocolGroup : public Protocol {
|
||||
public:
|
||||
virtual int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLGROUP_H_
|
||||
|
||||
|
||||
|
||||
201
external/tellstick-core/ProtocolHasta.cpp
vendored
Normal file
201
external/tellstick-core/ProtocolHasta.cpp
vendored
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolHasta.h"
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "common/Strings.h"
|
||||
|
||||
int ProtocolHasta::methods() const {
|
||||
return TELLSTICK_UP | TELLSTICK_DOWN | TELLSTICK_STOP | TELLSTICK_LEARN;
|
||||
}
|
||||
|
||||
std::string ProtocolHasta::getStringForMethod(int method, unsigned char, Controller *) {
|
||||
if (TelldusCore::comparei(model(), L"selflearningv2")) {
|
||||
return getStringForMethodv2(method);
|
||||
}
|
||||
return getStringForMethodv1(method);
|
||||
}
|
||||
|
||||
std::string ProtocolHasta::getStringForMethodv1(int method) {
|
||||
int house = this->getIntParameter(L"house", 1, 65536);
|
||||
int unit = this->getIntParameter(L"unit", 1, 15);
|
||||
std::string strReturn;
|
||||
|
||||
strReturn.append(1, 164);
|
||||
strReturn.append(1, 1);
|
||||
strReturn.append(1, 164);
|
||||
strReturn.append(1, 1);
|
||||
strReturn.append(1, 164);
|
||||
strReturn.append(1, 164);
|
||||
|
||||
strReturn.append(convertByte( (house & 0xFF) ));
|
||||
strReturn.append(convertByte( (house>>8) & 0xFF ));
|
||||
|
||||
int byte = unit&0x0F;
|
||||
|
||||
if (method == TELLSTICK_UP) {
|
||||
byte |= 0x00;
|
||||
|
||||
} else if (method == TELLSTICK_DOWN) {
|
||||
byte |= 0x10;
|
||||
|
||||
} else if (method == TELLSTICK_STOP) {
|
||||
byte |= 0x50;
|
||||
|
||||
} else if (method == TELLSTICK_LEARN) {
|
||||
byte |= 0x40;
|
||||
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
strReturn.append(convertByte(byte));
|
||||
|
||||
strReturn.append(convertByte(0x0));
|
||||
strReturn.append(convertByte(0x0));
|
||||
|
||||
// Remove the last pulse
|
||||
strReturn.erase(strReturn.end()-1, strReturn.end());
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
std::string ProtocolHasta::convertByte(unsigned char byte) {
|
||||
std::string retval;
|
||||
for(int i = 0; i < 8; ++i) {
|
||||
if (byte & 1) {
|
||||
retval.append(1, 33);
|
||||
retval.append(1, 17);
|
||||
} else {
|
||||
retval.append(1, 17);
|
||||
retval.append(1, 33);
|
||||
}
|
||||
byte >>= 1;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::string ProtocolHasta::getStringForMethodv2(int method) {
|
||||
int house = this->getIntParameter(L"house", 1, 65536);
|
||||
int unit = this->getIntParameter(L"unit", 1, 15);
|
||||
int sum = 0;
|
||||
std::string strReturn;
|
||||
strReturn.append(1, 245);
|
||||
strReturn.append(1, 1);
|
||||
strReturn.append(1, 245);
|
||||
strReturn.append(1, 245);
|
||||
strReturn.append(1, 63);
|
||||
strReturn.append(1, 1);
|
||||
strReturn.append(1, 63);
|
||||
strReturn.append(1, 1);
|
||||
strReturn.append(1, 35);
|
||||
strReturn.append(1, 35);
|
||||
|
||||
strReturn.append(convertBytev2( (house>>8) & 0xFF ));
|
||||
sum = ((house>>8)&0xFF);
|
||||
strReturn.append(convertBytev2( (house & 0xFF) ));
|
||||
sum += (house & 0xFF);
|
||||
|
||||
int byte = unit&0x0F;
|
||||
|
||||
if (method == TELLSTICK_UP) {
|
||||
byte |= 0xC0;
|
||||
|
||||
} else if (method == TELLSTICK_DOWN) {
|
||||
byte |= 0x10;
|
||||
|
||||
} else if (method == TELLSTICK_STOP) {
|
||||
byte |= 0x50;
|
||||
|
||||
} else if (method == TELLSTICK_LEARN) {
|
||||
byte |= 0x40;
|
||||
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
strReturn.append(convertBytev2(byte));
|
||||
sum += byte;
|
||||
|
||||
strReturn.append(convertBytev2(0x01));
|
||||
sum += 0x01;
|
||||
|
||||
int checksum = ((static_cast<int>(sum/256)+1)*256+1) - sum;
|
||||
strReturn.append(convertBytev2(checksum));
|
||||
strReturn.append(1, 63);
|
||||
strReturn.append(1, 35);
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
std::string ProtocolHasta::convertBytev2(unsigned char byte) {
|
||||
std::string retval;
|
||||
for(int i = 0; i < 8; ++i) {
|
||||
if (byte & 1) {
|
||||
retval.append(1, 63);
|
||||
retval.append(1, 35);
|
||||
} else {
|
||||
retval.append(1, 35);
|
||||
retval.append(1, 63);
|
||||
}
|
||||
byte >>= 1;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::string ProtocolHasta::decodeData(const ControllerMessage& dataMsg) {
|
||||
uint64_t allData = dataMsg.getInt64Parameter("data");
|
||||
|
||||
unsigned int house = 0;
|
||||
unsigned int unit = 0;
|
||||
unsigned int method = 0;
|
||||
std::string model;
|
||||
std::string methodstring;
|
||||
|
||||
allData >>= 8;
|
||||
unit = allData & 0xF;
|
||||
allData >>= 4;
|
||||
method = allData & 0xF;
|
||||
allData >>= 4;
|
||||
if(TelldusCore::comparei(dataMsg.model(), L"selflearning")) {
|
||||
// version1
|
||||
house = allData & 0xFFFF;
|
||||
house = ((house << 8) | (house >> 8)) & 0xFFFF;
|
||||
model = "selflearning";
|
||||
if(method == 0) {
|
||||
methodstring = "up";
|
||||
} else if(method == 1) {
|
||||
methodstring = "down";
|
||||
} else if(method == 5) {
|
||||
methodstring = "stop";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
// version2
|
||||
house = allData & 0xFFFF;
|
||||
|
||||
model = "selflearningv2";
|
||||
if(method == 12) {
|
||||
methodstring = "up";
|
||||
} else if(method == 1 || method == 8) { // is method 8 correct?
|
||||
methodstring = "down";
|
||||
} else if(method == 5) {
|
||||
methodstring = "stop";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
if(house < 1 || house > 65535 || unit < 1 || unit > 16) {
|
||||
// not hasta
|
||||
return "";
|
||||
}
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:command;protocol:hasta;model:" << model << ";house:" << house << ";unit:" << unit << ";method:" << methodstring << ";";
|
||||
return retString.str();
|
||||
}
|
||||
27
external/tellstick-core/ProtocolHasta.h
vendored
Normal file
27
external/tellstick-core/ProtocolHasta.h
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLHASTA_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLHASTA_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/ControllerMessage.h"
|
||||
#include "service/Protocol.h"
|
||||
|
||||
class ProtocolHasta : public Protocol {
|
||||
public:
|
||||
int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
static std::string decodeData(const ControllerMessage &dataMsg);
|
||||
|
||||
protected:
|
||||
static std::string convertByte(unsigned char byte);
|
||||
static std::string convertBytev2(unsigned char byte);
|
||||
std::string getStringForMethodv1(int method);
|
||||
std::string getStringForMethodv2(int method);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLHASTA_H_
|
||||
151
external/tellstick-core/ProtocolIkea.cpp
vendored
Normal file
151
external/tellstick-core/ProtocolIkea.cpp
vendored
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolIkea.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include "common/Strings.h"
|
||||
#ifdef _WINDOWS
|
||||
#define strtok_r(s, d, p) strtok_s(s, d, p)
|
||||
#endif
|
||||
|
||||
int ProtocolIkea::methods() const {
|
||||
if (TelldusCore::comparei(model(), L"selflearning-switch")) {
|
||||
return TELLSTICK_TURNON | TELLSTICK_TURNOFF;
|
||||
}
|
||||
return TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM;
|
||||
}
|
||||
|
||||
std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Controller *) {
|
||||
const char B1[] = {84, 84, 0};
|
||||
const char B0[] = {170, 0};
|
||||
|
||||
int intSystem = this->getIntParameter(L"system", 1, 16)-1;
|
||||
int intFadeStyle = TelldusCore::comparei(this->getStringParameter(L"fade", L"true"), L"true");
|
||||
std::wstring wstrUnits = this->getStringParameter(L"units", L"");
|
||||
|
||||
if (method == TELLSTICK_TURNON) {
|
||||
level = 255;
|
||||
} else if (method == TELLSTICK_TURNOFF) {
|
||||
level = 0;
|
||||
} else if (method == TELLSTICK_DIM) {
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (wstrUnits == L"") {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string strUnits(TelldusCore::wideToString(wstrUnits));
|
||||
int intUnits = 0; // Start without any units
|
||||
|
||||
char *tempUnits = new char[strUnits.size()+1];
|
||||
#ifdef _WINDOWS
|
||||
strcpy_s(tempUnits, strUnits.size()+1, strUnits.c_str());
|
||||
#else
|
||||
snprintf(tempUnits, strUnits.size()+1, "%s", strUnits.c_str());
|
||||
#endif
|
||||
|
||||
char *saveptr;
|
||||
char *strToken = strtok_r(tempUnits, ",", &saveptr);
|
||||
do {
|
||||
int intUnit = atoi(strToken);
|
||||
if (intUnit == 10) {
|
||||
intUnit = 0;
|
||||
}
|
||||
intUnits = intUnits | ( 1<<(9-intUnit) );
|
||||
} while ( (strToken = strtok_r(NULL, ",", &saveptr)) != NULL );
|
||||
|
||||
delete[] tempUnits;
|
||||
|
||||
std::string strReturn;
|
||||
strReturn.append(1, 'S');
|
||||
strReturn.append(1, 84);
|
||||
strReturn.append(1, 84);
|
||||
strReturn.append(1, 84);
|
||||
strReturn.append(1, 84);
|
||||
strReturn.append(1, 84);
|
||||
strReturn.append(1, 84);
|
||||
strReturn.append(1, 170);
|
||||
|
||||
std::string strChannels = "";
|
||||
int intCode = (intSystem << 10) | intUnits;
|
||||
int checksum1 = 0;
|
||||
int checksum2 = 0;
|
||||
for (int i = 13; i >= 0; --i) {
|
||||
if ((intCode >> i) & 1) {
|
||||
strChannels.append(B1);
|
||||
if (i % 2 == 0)
|
||||
checksum2++;
|
||||
else
|
||||
checksum1++;
|
||||
} else {
|
||||
strChannels.append(B0);
|
||||
}
|
||||
}
|
||||
strReturn.append(strChannels); // System + Units
|
||||
|
||||
strReturn.append(checksum1 %2 == 0 ? B1 : B0); // 1st checksum
|
||||
strReturn.append(checksum2 %2 == 0 ? B1 : B0); // 2nd checksum
|
||||
|
||||
int intLevel = 0;
|
||||
if (level <= 12) {
|
||||
intLevel = 10; // Level 10 is actually off
|
||||
} else if (level <= 37) {
|
||||
intLevel = 1;
|
||||
} else if (level <= 62) {
|
||||
intLevel = 2;
|
||||
} else if (level <= 87) {
|
||||
intLevel = 3;
|
||||
} else if (level <= 112) {
|
||||
intLevel = 4;
|
||||
} else if (level <= 137) {
|
||||
intLevel = 5;
|
||||
} else if (level <= 162) {
|
||||
intLevel = 6;
|
||||
} else if (level <= 187) {
|
||||
intLevel = 7;
|
||||
} else if (level <= 212) {
|
||||
intLevel = 8;
|
||||
} else if (level <= 237) {
|
||||
intLevel = 9;
|
||||
} else {
|
||||
intLevel = 0; // Level 0 is actually full on
|
||||
}
|
||||
|
||||
int intFade = 0;
|
||||
if (intFadeStyle == 1) {
|
||||
intFade = 11 << 4; // Smooth
|
||||
} else {
|
||||
intFade = 1 << 4; // Instant
|
||||
}
|
||||
|
||||
intCode = intLevel | intFade; // Concat level and fade
|
||||
|
||||
checksum1 = 0;
|
||||
checksum2 = 0;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if ((intCode >> i) & 1) {
|
||||
strReturn.append(B1);
|
||||
if (i % 2 == 0)
|
||||
checksum1++;
|
||||
else
|
||||
checksum2++;
|
||||
} else {
|
||||
strReturn.append(B0);
|
||||
}
|
||||
}
|
||||
|
||||
strReturn.append(checksum1 %2 == 0 ? B1 : B0); // 1st checksum
|
||||
strReturn.append(checksum2 %2 == 0 ? B1 : B0); // 2nd checksum
|
||||
|
||||
strReturn.append("+");
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
19
external/tellstick-core/ProtocolIkea.h
vendored
Normal file
19
external/tellstick-core/ProtocolIkea.h
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLIKEA_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLIKEA_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
|
||||
class ProtocolIkea : public Protocol {
|
||||
public:
|
||||
int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLIKEA_H_
|
||||
46
external/tellstick-core/ProtocolMandolyn.cpp
vendored
Normal file
46
external/tellstick-core/ProtocolMandolyn.cpp
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolMandolyn.h"
|
||||
#include <stdlib.h>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "common/Strings.h"
|
||||
|
||||
std::string ProtocolMandolyn::decodeData(const ControllerMessage &dataMsg) {
|
||||
std::string data = dataMsg.getParameter("data");
|
||||
uint32_t value = (uint32_t)TelldusCore::hexTo64l(data);
|
||||
|
||||
// parity not used
|
||||
// bool parity = value & 0x1;
|
||||
value >>= 1;
|
||||
|
||||
double temp = static_cast<double>(value & 0x7FFF) - static_cast<double>(6400);
|
||||
temp = temp/128.0;
|
||||
value >>= 15;
|
||||
|
||||
uint8_t humidity = (value & 0x7F);
|
||||
value >>= 7;
|
||||
|
||||
// battOk not used
|
||||
// bool battOk = value & 0x1;
|
||||
value >>= 3;
|
||||
|
||||
uint8_t channel = (value & 0x3)+1;
|
||||
value >>= 2;
|
||||
|
||||
uint8_t house = value & 0xF;
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:sensor;protocol:mandolyn;id:"
|
||||
<< house*10+channel
|
||||
<< ";model:temperaturehumidity;"
|
||||
<< "temp:" << std::fixed << std::setprecision(1) << temp
|
||||
<< ";humidity:" << static_cast<int>(humidity) << ";";
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
19
external/tellstick-core/ProtocolMandolyn.h
vendored
Normal file
19
external/tellstick-core/ProtocolMandolyn.h
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLMANDOLYN_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLMANDOLYN_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
#include "service/ControllerMessage.h"
|
||||
|
||||
class ProtocolMandolyn : public Protocol {
|
||||
public:
|
||||
static std::string decodeData(const ControllerMessage &dataMsg);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLMANDOLYN_H_
|
||||
279
external/tellstick-core/ProtocolNexa.cpp
vendored
Normal file
279
external/tellstick-core/ProtocolNexa.cpp
vendored
Normal file
|
|
@ -0,0 +1,279 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolNexa.h"
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "service/TellStick.h"
|
||||
#include "common/Strings.h"
|
||||
|
||||
int ProtocolNexa::lastArctecCodeSwitchWasTurnOff = 0; // TODO(stefan): always removing first turnon now, make more flexible (waveman too)
|
||||
|
||||
int ProtocolNexa::methods() const {
|
||||
if (TelldusCore::comparei(model(), L"codeswitch")) {
|
||||
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF);
|
||||
|
||||
} else if (TelldusCore::comparei(model(), L"selflearning-switch")) {
|
||||
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN);
|
||||
|
||||
} else if (TelldusCore::comparei(model(), L"selflearning-dimmer")) {
|
||||
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM | TELLSTICK_LEARN);
|
||||
|
||||
} else if (TelldusCore::comparei(model(), L"bell")) {
|
||||
return TELLSTICK_BELL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string ProtocolNexa::getStringForMethod(int method, unsigned char data, Controller *controller) {
|
||||
if (TelldusCore::comparei(model(), L"codeswitch")) {
|
||||
return getStringCodeSwitch(method);
|
||||
} else if (TelldusCore::comparei(model(), L"bell")) {
|
||||
return getStringBell();
|
||||
}
|
||||
if ((method == TELLSTICK_TURNON) && TelldusCore::comparei(model(), L"selflearning-dimmer")) {
|
||||
// Workaround for not letting a dimmer do into "dimming mode"
|
||||
return getStringSelflearning(TELLSTICK_DIM, 255);
|
||||
}
|
||||
if (method == TELLSTICK_LEARN) {
|
||||
std::string str = getStringSelflearning(TELLSTICK_TURNON, data);
|
||||
|
||||
// Check to see if we are an old TellStick (fw <= 2, batch <= 8)
|
||||
TellStick *ts = reinterpret_cast<TellStick *>(controller);
|
||||
if (!ts) {
|
||||
return str;
|
||||
}
|
||||
if (ts->pid() == 0x0c30 && ts->firmwareVersion() <= 2) {
|
||||
// Workaround for the bug in early firmwares
|
||||
// The TellStick have a fixed pause (max) between two packets.
|
||||
// It is only correct between the first and second packet.
|
||||
// It seems faster to send two packes at a time and some
|
||||
// receivers seems picky about this when learning.
|
||||
// We also return the last packet so Device::doAction() doesn't
|
||||
// report TELLSTICK_ERROR_METHOD_NOT_SUPPORTED
|
||||
|
||||
str.insert(0, 1, 2); // Repeat two times
|
||||
str.insert(0, 1, 'R');
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
controller->send(str);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
return getStringSelflearning(method, data);
|
||||
}
|
||||
|
||||
std::string ProtocolNexa::getStringCodeSwitch(int method) {
|
||||
std::string strReturn = "S";
|
||||
|
||||
std::wstring house = getStringParameter(L"house", L"A");
|
||||
int intHouse = house[0] - L'A';
|
||||
strReturn.append(getCodeSwitchTuple(intHouse));
|
||||
strReturn.append(getCodeSwitchTuple(getIntParameter(L"unit", 1, 16)-1));
|
||||
|
||||
if (method == TELLSTICK_TURNON) {
|
||||
strReturn.append("$k$k$kk$$kk$$kk$$k+");
|
||||
} else if (method == TELLSTICK_TURNOFF) {
|
||||
strReturn.append(this->getOffCode());
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
std::string ProtocolNexa::getStringBell() {
|
||||
std::string strReturn = "S";
|
||||
|
||||
std::wstring house = getStringParameter(L"house", L"A");
|
||||
int intHouse = house[0] - L'A';
|
||||
strReturn.append(getCodeSwitchTuple(intHouse));
|
||||
strReturn.append("$kk$$kk$$kk$$k$k"); // Unit 7
|
||||
strReturn.append("$kk$$kk$$kk$$kk$$k+"); // Bell
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
std::string ProtocolNexa::getStringSelflearning(int method, unsigned char level) {
|
||||
int intHouse = getIntParameter(L"house", 1, 67108863);
|
||||
int intCode = getIntParameter(L"unit", 1, 16)-1;
|
||||
return getStringSelflearningForCode(intHouse, intCode, method, level);
|
||||
}
|
||||
|
||||
std::string ProtocolNexa::getStringSelflearningForCode(int intHouse, int intCode, int method, unsigned char level) {
|
||||
const unsigned char START[] = {'T', 127, 255, 24, 1, 0};
|
||||
// const char START[] = {'T',130,255,26,24,0};
|
||||
|
||||
std::string strMessage(reinterpret_cast<const char*>(START));
|
||||
strMessage.append(1, (method == TELLSTICK_DIM ? 147 : 132)); // Number of pulses
|
||||
|
||||
std::string m;
|
||||
for (int i = 25; i >= 0; --i) {
|
||||
m.append( intHouse & 1 << i ? "10" : "01" );
|
||||
}
|
||||
m.append("01"); // Group
|
||||
|
||||
// On/off
|
||||
if (method == TELLSTICK_DIM) {
|
||||
m.append("00");
|
||||
} else if (method == TELLSTICK_TURNOFF) {
|
||||
m.append("01");
|
||||
} else if (method == TELLSTICK_TURNON) {
|
||||
m.append("10");
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
for (int i = 3; i >= 0; --i) {
|
||||
m.append( intCode & 1 << i ? "10" : "01" );
|
||||
}
|
||||
|
||||
if (method == TELLSTICK_DIM) {
|
||||
unsigned char newLevel = level/16;
|
||||
for (int i = 3; i >= 0; --i) {
|
||||
m.append(newLevel & 1 << i ? "10" : "01");
|
||||
}
|
||||
}
|
||||
|
||||
// The number of data is odd.
|
||||
// Add this to make it even, otherwise the following loop will not work
|
||||
m.append("0");
|
||||
|
||||
unsigned char code = 9; // b1001, startcode
|
||||
for (unsigned int i = 0; i < m.length(); ++i) {
|
||||
code <<= 4;
|
||||
if (m[i] == '1') {
|
||||
code |= 8; // b1000
|
||||
} else {
|
||||
code |= 10; // b1010
|
||||
// code |= 11; //b1011
|
||||
}
|
||||
if (i % 2 == 0) {
|
||||
strMessage.append(1, code);
|
||||
code = 0;
|
||||
}
|
||||
}
|
||||
strMessage.append("+");
|
||||
|
||||
// for( int i = 0; i < strMessage.length(); ++i ) {
|
||||
// printf("%i,", (unsigned char)strMessage[i]);
|
||||
// }
|
||||
// printf("\n");
|
||||
return strMessage;
|
||||
}
|
||||
|
||||
std::string ProtocolNexa::decodeData(const ControllerMessage& dataMsg) {
|
||||
uint64_t allData = dataMsg.getInt64Parameter("data");
|
||||
|
||||
if(TelldusCore::comparei(dataMsg.model(), L"selflearning")) {
|
||||
// selflearning
|
||||
return decodeDataSelfLearning(allData);
|
||||
} else {
|
||||
// codeswitch
|
||||
return decodeDataCodeSwitch(allData);
|
||||
}
|
||||
}
|
||||
|
||||
std::string ProtocolNexa::decodeDataSelfLearning(uint64_t allData) {
|
||||
unsigned int house = 0;
|
||||
unsigned int unit = 0;
|
||||
unsigned int group = 0;
|
||||
unsigned int method = 0;
|
||||
|
||||
house = allData & 0xFFFFFFC0;
|
||||
house >>= 6;
|
||||
|
||||
group = allData & 0x20;
|
||||
group >>= 5;
|
||||
|
||||
method = allData & 0x10;
|
||||
method >>= 4;
|
||||
|
||||
unit = allData & 0xF;
|
||||
unit++;
|
||||
|
||||
if(house < 1 || house > 67108863 || unit < 1 || unit > 16) {
|
||||
// not arctech selflearning
|
||||
return "";
|
||||
}
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:command;protocol:arctech;model:selflearning;house:" << house << ";unit:" << unit << ";group:" << group << ";method:";
|
||||
if(method == 1) {
|
||||
retString << "turnon;";
|
||||
} else if(method == 0) {
|
||||
retString << "turnoff;";
|
||||
} else {
|
||||
// not arctech selflearning
|
||||
return "";
|
||||
}
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
|
||||
std::string ProtocolNexa::decodeDataCodeSwitch(uint64_t allData) {
|
||||
unsigned int house = 0;
|
||||
unsigned int unit = 0;
|
||||
unsigned int method = 0;
|
||||
|
||||
method = allData & 0xF00;
|
||||
method >>= 8;
|
||||
|
||||
unit = allData & 0xF0;
|
||||
unit >>= 4;
|
||||
unit++;
|
||||
|
||||
house = allData & 0xF;
|
||||
|
||||
if(house > 16 || unit < 1 || unit > 16) {
|
||||
// not arctech codeswitch
|
||||
return "";
|
||||
}
|
||||
|
||||
house = house + 'A'; // house from A to P
|
||||
|
||||
if(method != 6 && lastArctecCodeSwitchWasTurnOff == 1) {
|
||||
lastArctecCodeSwitchWasTurnOff = 0;
|
||||
return ""; // probably a stray turnon or bell (perhaps: only certain time interval since last, check that it's the same house/unit... Will lose
|
||||
// one turnon/bell, but it's better than the alternative...
|
||||
}
|
||||
|
||||
if(method == 6) {
|
||||
lastArctecCodeSwitchWasTurnOff = 1;
|
||||
}
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:command;protocol:arctech;model:codeswitch;house:" << static_cast<char>(house);
|
||||
|
||||
if(method == 6) {
|
||||
retString << ";unit:" << unit << ";method:turnoff;";
|
||||
} else if(method == 14) {
|
||||
retString << ";unit:" << unit << ";method:turnon;";
|
||||
} else if(method == 15) {
|
||||
retString << ";method:bell;";
|
||||
} else {
|
||||
// not arctech codeswitch
|
||||
return "";
|
||||
}
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
|
||||
std::string ProtocolNexa::getCodeSwitchTuple(int intCode) {
|
||||
std::string strReturn = "";
|
||||
for( int i = 0; i < 4; ++i ) {
|
||||
if (intCode & 1) { // Convert 1
|
||||
strReturn.append("$kk$");
|
||||
} else { // Convert 0
|
||||
strReturn.append("$k$k");
|
||||
}
|
||||
intCode >>= 1;
|
||||
}
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
std::string ProtocolNexa::getOffCode() const {
|
||||
return "$k$k$kk$$kk$$k$k$k+";
|
||||
}
|
||||
39
external/tellstick-core/ProtocolNexa.h
vendored
Normal file
39
external/tellstick-core/ProtocolNexa.h
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <string>
|
||||
#include "service/ControllerMessage.h"
|
||||
#include "service/Device.h"
|
||||
|
||||
class ProtocolNexa : public Protocol {
|
||||
public:
|
||||
virtual int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
static std::string decodeData(const ControllerMessage &dataMsg);
|
||||
|
||||
protected:
|
||||
std::string getStringSelflearning(int method, unsigned char data);
|
||||
std::string getStringCodeSwitch(int method);
|
||||
std::string getStringBell();
|
||||
virtual std::string getOffCode() const;
|
||||
static std::string getCodeSwitchTuple(int code);
|
||||
static std::string getStringSelflearningForCode(int house, int unit, int method, unsigned char data);
|
||||
|
||||
private:
|
||||
static int lastArctecCodeSwitchWasTurnOff;
|
||||
static std::string decodeDataCodeSwitch(uint64_t allData);
|
||||
static std::string decodeDataSelfLearning(uint64_t allData);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_
|
||||
347
external/tellstick-core/ProtocolOregon.cpp
vendored
Normal file
347
external/tellstick-core/ProtocolOregon.cpp
vendored
Normal file
|
|
@ -0,0 +1,347 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolOregon.h"
|
||||
#include <stdlib.h>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "common/Strings.h"
|
||||
|
||||
std::string ProtocolOregon::decodeData(const ControllerMessage &dataMsg) {
|
||||
std::string data = dataMsg.getParameter("data");
|
||||
|
||||
std::wstring model = dataMsg.model();
|
||||
if (model.compare(L"0xEA4C") == 0) {
|
||||
return decodeEA4C(data);
|
||||
} else if (model.compare(L"0x1A2D") == 0) {
|
||||
return decode1A2D(data);
|
||||
} else if (model.compare(L"0xF824") == 0) {
|
||||
return decodeF824(data);
|
||||
} else if (model.compare(L"0x1984") == 0 || model.compare(L"0x1994") == 0) {
|
||||
return decode1984(data, model);
|
||||
} else if (model.compare(L"0x2914") == 0) {
|
||||
return decode2914(data);
|
||||
} else if (model.compare(L"0xC844") == 0 || model.compare(L"0xEC40") == 0) {
|
||||
// C844 - pool thermometer
|
||||
return decodeC844(data, model);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string ProtocolOregon::decodeEA4C(const std::string &data) {
|
||||
uint64_t value = TelldusCore::hexTo64l(data);
|
||||
|
||||
uint8_t checksum = 0xE + 0xA + 0x4 + 0xC;
|
||||
checksum -= (value & 0xF) * 0x10;
|
||||
checksum -= 0xA;
|
||||
value >>= 8;
|
||||
|
||||
uint8_t checksumw = (value >> 4) & 0xF;
|
||||
bool neg = value & (1 << 3);
|
||||
int hundred = value & 3;
|
||||
checksum += (value & 0xF);
|
||||
value >>= 8;
|
||||
|
||||
uint8_t temp2 = value & 0xF;
|
||||
uint8_t temp1 = (value >> 4) & 0xF;
|
||||
checksum += temp2 + temp1;
|
||||
value >>= 8;
|
||||
|
||||
uint8_t temp3 = (value >> 4) & 0xF;
|
||||
checksum += (value & 0xF) + temp3;
|
||||
value >>= 8;
|
||||
|
||||
checksum += ((value >> 4) & 0xF) + (value & 0xF);
|
||||
uint8_t address = value & 0xFF;
|
||||
value >>= 8;
|
||||
|
||||
checksum += ((value >> 4) & 0xF) + (value & 0xF);
|
||||
// channel not used
|
||||
// uint8_t channel = (value >> 4) & 0x7;
|
||||
|
||||
if (checksum != checksumw) {
|
||||
return "";
|
||||
}
|
||||
|
||||
double temperature = ((hundred * 1000) + (temp1 * 100) + (temp2 * 10) + temp3)/10.0;
|
||||
if (neg) {
|
||||
temperature = -temperature;
|
||||
}
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:sensor;protocol:oregon;model:EA4C;id:" << static_cast<int>(address)
|
||||
<< ";temp:" << std::fixed << std::setprecision(1) << temperature << ";";
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
|
||||
std::string ProtocolOregon::decode1984(const std::string &data, const std::wstring &model) {
|
||||
// wind
|
||||
uint64_t value = TelldusCore::hexTo64l(data);
|
||||
|
||||
uint8_t crcCheck = value & 0xF; // PROBABLY crc
|
||||
value >>= 4;
|
||||
uint8_t messageChecksum1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t messageChecksum2 = value & 0xF;
|
||||
|
||||
value >>= 4;
|
||||
uint8_t avg1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t avg2 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t avg3 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t gust1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t gust2 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t gust3 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t unknown1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t unknown2 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t direction = value & 0xF;
|
||||
|
||||
value >>= 4;
|
||||
uint8_t battery = value & 0xF; // PROBABLY battery
|
||||
value >>= 4;
|
||||
uint8_t rollingcode = ((value >> 4) & 0xF) + (value & 0xF);
|
||||
uint8_t checksum = ((value >> 4) & 0xF) + (value & 0xF);
|
||||
value >>= 8;
|
||||
uint8_t channel = value & 0xF;
|
||||
checksum += unknown1 + unknown2 + avg1 + avg2 + avg3 + gust1 + gust2 + gust3 + direction + battery + channel;
|
||||
|
||||
if (model.compare(L"0x1984") == 0) {
|
||||
checksum += 0x1 + 0x9 + 0x8 + 0x4;
|
||||
} else {
|
||||
checksum += 0x1 + 0x9 + 0x9 + 0x4;
|
||||
}
|
||||
|
||||
if (((checksum >> 4) & 0xF) != messageChecksum1 || (checksum & 0xF) != messageChecksum2) {
|
||||
// checksum error
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
double avg = ((avg1 * 100) + (avg2 * 10) + avg3)/10.0;
|
||||
double gust = ((gust1 * 100) + (gust2 * 10) + gust3)/10.0;
|
||||
float directiondegree = 22.5 * direction;
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:sensor;protocol:oregon;model:1984;id:" << static_cast<int>(rollingcode)
|
||||
<< ";winddirection:" << directiondegree
|
||||
<< ";windaverage:" << std::fixed << std::setprecision(1) << avg
|
||||
<< ";windgust:" << std::fixed << std::setprecision(1) << gust << ";";
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
|
||||
std::string ProtocolOregon::decode1A2D(const std::string &data) {
|
||||
uint64_t value = TelldusCore::hexTo64l(data);
|
||||
// checksum2 not used yet
|
||||
// uint8_t checksum2 = value & 0xFF;
|
||||
value >>= 8;
|
||||
uint8_t checksum1 = value & 0xFF;
|
||||
value >>= 8;
|
||||
|
||||
uint8_t checksum = ((value >> 4) & 0xF) + (value & 0xF);
|
||||
uint8_t hum1 = value & 0xF;
|
||||
value >>= 8;
|
||||
|
||||
checksum += ((value >> 4) & 0xF) + (value & 0xF);
|
||||
uint8_t neg = value & (1 << 3);
|
||||
uint8_t hum2 = (value >> 4) & 0xF;
|
||||
value >>= 8;
|
||||
|
||||
checksum += ((value >> 4) & 0xF) + (value & 0xF);
|
||||
uint8_t temp2 = value & 0xF;
|
||||
uint8_t temp1 = (value >> 4) & 0xF;
|
||||
value >>= 8;
|
||||
|
||||
checksum += ((value >> 4) & 0xF) + (value & 0xF);
|
||||
uint8_t temp3 = (value >> 4) & 0xF;
|
||||
value >>= 8;
|
||||
|
||||
checksum += ((value >> 4) & 0xF) + (value & 0xF);
|
||||
uint8_t address = value & 0xFF;
|
||||
value >>= 8;
|
||||
|
||||
checksum += ((value >> 4) & 0xF) + (value & 0xF);
|
||||
// channel not used
|
||||
// uint8_t channel = (value >> 4) & 0x7;
|
||||
|
||||
checksum += 0x1 + 0xA + 0x2 + 0xD - 0xA;
|
||||
|
||||
// TODO(micke): Find out how checksum2 works
|
||||
if (checksum != checksum1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
double temperature = ((temp1 * 100) + (temp2 * 10) + temp3)/10.0;
|
||||
if (neg) {
|
||||
temperature = -temperature;
|
||||
}
|
||||
int humidity = (hum1 * 10.0) + hum2;
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:sensor;protocol:oregon;model:1A2D;id:" << static_cast<int>(address)
|
||||
<< ";temp:" << std::fixed << std::setprecision(1) << temperature
|
||||
<< ";humidity:" << humidity << ";";
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
|
||||
std::string ProtocolOregon::decode2914(const std::string &data) {
|
||||
// rain
|
||||
uint64_t value = TelldusCore::hexTo64l(data);
|
||||
|
||||
uint8_t messageChecksum1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t messageChecksum2 = value & 0xF;
|
||||
|
||||
value >>= 4;
|
||||
uint8_t totRain1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t totRain2 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t totRain3 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t totRain4 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t totRain5 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t totRain6 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t rainRate1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t rainRate2 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t rainRate3 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t rainRate4 = value & 0xF;
|
||||
|
||||
value >>= 4;
|
||||
uint8_t battery = value & 0xF; // PROBABLY battery
|
||||
value >>= 4;
|
||||
uint8_t rollingcode = ((value >> 4) & 0xF) + (value & 0xF);
|
||||
uint8_t checksum = ((value >> 4) & 0xF) + (value & 0xF);
|
||||
value >>= 8;
|
||||
uint8_t channel = value & 0xF;
|
||||
checksum += totRain1 + totRain2 + totRain3 + totRain4 + totRain5 + totRain6 + rainRate1 + rainRate2 + rainRate3 + rainRate4 + battery + channel + 0x2 + 0x9 + 0x1 + 0x4;
|
||||
|
||||
if (((checksum >> 4) & 0xF) != messageChecksum1 || (checksum & 0xF) != messageChecksum2) {
|
||||
// checksum error
|
||||
return "";
|
||||
}
|
||||
|
||||
double totRain = ((totRain1 * 100000) + (totRain2 * 10000) + (totRain3 * 1000) + (totRain4 * 100) + (totRain5 * 10) + totRain6)/1000.0*25.4;
|
||||
double rainRate = ((rainRate1 * 1000) + (rainRate2 * 100) + (rainRate3 * 10) + rainRate4)/100.0*25.4;
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:sensor;protocol:oregon;model:2914;id:" << static_cast<int>(rollingcode)
|
||||
<< ";raintotal:" << std::fixed << std::setprecision(1) << totRain
|
||||
<< ";rainrate:" << std::fixed << std::setprecision(1) << rainRate << ";";
|
||||
return retString.str();
|
||||
}
|
||||
|
||||
std::string ProtocolOregon::decodeF824(const std::string &data) {
|
||||
uint64_t value = TelldusCore::hexTo64l(data);
|
||||
|
||||
uint8_t crcCheck = value & 0xF; // PROBABLY crc
|
||||
value >>= 4;
|
||||
uint8_t messageChecksum1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t messageChecksum2 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t unknown = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t hum1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t hum2 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t neg = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t temp1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t temp2 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t temp3 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t battery = value & 0xF; // PROBABLY battery
|
||||
value >>= 4;
|
||||
uint8_t rollingcode = ((value >> 4) & 0xF) + (value & 0xF);
|
||||
uint8_t checksum = ((value >> 4) & 0xF) + (value & 0xF);
|
||||
value >>= 8;
|
||||
uint8_t channel = value & 0xF;
|
||||
checksum += unknown + hum1 + hum2 + neg + temp1 + temp2 + temp3 + battery + channel + 0xF + 0x8 + 0x2 + 0x4;
|
||||
|
||||
if (((checksum >> 4) & 0xF) != messageChecksum1 || (checksum & 0xF) != messageChecksum2) {
|
||||
// checksum error
|
||||
return "";
|
||||
}
|
||||
|
||||
double temperature = ((temp1 * 100) + (temp2 * 10) + temp3)/10.0;
|
||||
if (neg) {
|
||||
temperature = -temperature;
|
||||
}
|
||||
int humidity = (hum1 * 10.0) + hum2;
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:sensor;protocol:oregon;model:F824;id:" << static_cast<int>(rollingcode)
|
||||
<< ";temp:" << std::fixed << std::setprecision(1) << temperature
|
||||
<< ";humidity:" << humidity << ";";
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
|
||||
std::string ProtocolOregon::decodeC844(const std::string &data, const std::wstring &model) {
|
||||
uint64_t value = TelldusCore::hexTo64l(data);
|
||||
|
||||
uint8_t messageChecksum1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t messageChecksum2 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t neg = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t temp1 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t temp2 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t temp3 = value & 0xF;
|
||||
value >>= 4;
|
||||
uint8_t battery = value & 0xF; // PROBABLY battery
|
||||
value >>= 4;
|
||||
uint8_t rollingcode = ((value >> 4) & 0xF) + (value & 0xF);
|
||||
uint8_t checksum = ((value >> 4) & 0xF) + (value & 0xF);
|
||||
value >>= 8;
|
||||
uint8_t channel = value & 0xF;
|
||||
checksum += neg + temp1 + temp2 + temp3 + battery + channel;
|
||||
|
||||
if (model.compare(L"0xC844") == 0) {
|
||||
checksum += 0xC + 0x8 + 0x4 + 0x4;
|
||||
} else {
|
||||
checksum += 0xE + 0xC + 0x4 + 0x0;
|
||||
}
|
||||
|
||||
if (((checksum >> 4) & 0xF) != messageChecksum1 || (checksum & 0xF) != messageChecksum2) {
|
||||
// checksum error
|
||||
return "";
|
||||
}
|
||||
|
||||
double temperature = ((temp1 * 100) + (temp2 * 10) + temp3)/10.0;
|
||||
if (neg) {
|
||||
temperature = -temperature;
|
||||
}
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:sensor;protocol:oregon;model:C844;id:" << static_cast<int>(rollingcode)
|
||||
<< ";temp:" << std::fixed << std::setprecision(1) << temperature << ";";
|
||||
return retString.str();
|
||||
}
|
||||
27
external/tellstick-core/ProtocolOregon.h
vendored
Normal file
27
external/tellstick-core/ProtocolOregon.h
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLOREGON_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLOREGON_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
#include "service/ControllerMessage.h"
|
||||
|
||||
class ProtocolOregon : public Protocol {
|
||||
public:
|
||||
static std::string decodeData(const ControllerMessage &dataMsg);
|
||||
|
||||
protected:
|
||||
static std::string decodeEA4C(const std::string &data);
|
||||
static std::string decode1A2D(const std::string &data);
|
||||
static std::string decodeF824(const std::string &data);
|
||||
static std::string decode1984(const std::string &data, const std::wstring &model);
|
||||
static std::string decode2914(const std::string &data);
|
||||
static std::string decodeC844(const std::string &data, const std::wstring &model);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLOREGON_H_
|
||||
115
external/tellstick-core/ProtocolRisingSun.cpp
vendored
Normal file
115
external/tellstick-core/ProtocolRisingSun.cpp
vendored
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolRisingSun.h"
|
||||
#include <string>
|
||||
#include "common/Strings.h"
|
||||
|
||||
int ProtocolRisingSun::methods() const {
|
||||
if (TelldusCore::comparei(model(), L"selflearning")) {
|
||||
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN);
|
||||
}
|
||||
return TELLSTICK_TURNON | TELLSTICK_TURNOFF;
|
||||
}
|
||||
|
||||
std::string ProtocolRisingSun::getStringForMethod(int method, unsigned char data, Controller *controller) {
|
||||
if (TelldusCore::comparei(model(), L"selflearning")) {
|
||||
return getStringSelflearning(method);
|
||||
}
|
||||
return getStringCodeSwitch(method);
|
||||
}
|
||||
|
||||
std::string ProtocolRisingSun::getStringSelflearning(int method) {
|
||||
int intHouse = this->getIntParameter(L"house", 1, 33554432)-1;
|
||||
int intCode = this->getIntParameter(L"code", 1, 16)-1;
|
||||
|
||||
const char code_on[][7] = {
|
||||
"110110", "001110", "100110", "010110",
|
||||
"111001", "000101", "101001", "011001",
|
||||
"110000", "001000", "100000", "010000",
|
||||
"111100", "000010", "101100", "011100"
|
||||
};
|
||||
const char code_off[][7] = {
|
||||
"111110", "000001", "101110", "011110",
|
||||
"110101", "001101", "100101", "010101",
|
||||
"111000", "000100", "101000", "011000",
|
||||
"110010", "001010", "100010", "010010"
|
||||
};
|
||||
const char l = 120;
|
||||
const char s = 51;
|
||||
|
||||
std::string strCode = "10";
|
||||
int code = intCode;
|
||||
code = (code < 0 ? 0 : code);
|
||||
code = (code > 15 ? 15 : code);
|
||||
if (method == TELLSTICK_TURNON) {
|
||||
strCode.append(code_on[code]);
|
||||
} else if (method == TELLSTICK_TURNOFF) {
|
||||
strCode.append(code_off[code]);
|
||||
} else if (method == TELLSTICK_LEARN) {
|
||||
strCode.append(code_on[code]);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
int house = intHouse;
|
||||
for(int i = 0; i < 25; ++i) {
|
||||
if (house & 1) {
|
||||
strCode.append(1, '1');
|
||||
} else {
|
||||
strCode.append(1, '0');
|
||||
}
|
||||
house >>= 1;
|
||||
}
|
||||
|
||||
std::string strReturn;
|
||||
for(unsigned int i = 0; i < strCode.length(); ++i) {
|
||||
if (strCode[i] == '1') {
|
||||
strReturn.append(1, l);
|
||||
strReturn.append(1, s);
|
||||
} else {
|
||||
strReturn.append(1, s);
|
||||
strReturn.append(1, l);
|
||||
}
|
||||
}
|
||||
|
||||
std::string prefix = "P";
|
||||
prefix.append(1, 5);
|
||||
if (method == TELLSTICK_LEARN) {
|
||||
prefix.append("R");
|
||||
prefix.append( 1, 50 );
|
||||
}
|
||||
prefix.append("S");
|
||||
strReturn.insert(0, prefix);
|
||||
strReturn.append(1, '+');
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
std::string ProtocolRisingSun::getStringCodeSwitch(int method) {
|
||||
std::string strReturn = "S.e";
|
||||
strReturn.append(getCodeSwitchTuple(this->getIntParameter(L"house", 1, 4)-1));
|
||||
strReturn.append(getCodeSwitchTuple(this->getIntParameter(L"unit", 1, 4)-1));
|
||||
if (method == TELLSTICK_TURNON) {
|
||||
strReturn.append("e..ee..ee..ee..e+");
|
||||
} else if (method == TELLSTICK_TURNOFF) {
|
||||
strReturn.append("e..ee..ee..e.e.e+");
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
std::string ProtocolRisingSun::getCodeSwitchTuple(int intToConvert) {
|
||||
std::string strReturn = "";
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
if (i == intToConvert) {
|
||||
strReturn.append( ".e.e" );
|
||||
} else {
|
||||
strReturn.append( "e..e" );
|
||||
}
|
||||
}
|
||||
return strReturn;
|
||||
}
|
||||
24
external/tellstick-core/ProtocolRisingSun.h
vendored
Normal file
24
external/tellstick-core/ProtocolRisingSun.h
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLRISINGSUN_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLRISINGSUN_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
|
||||
class ProtocolRisingSun : public Protocol {
|
||||
public:
|
||||
int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
|
||||
protected:
|
||||
std::string getStringSelflearning(int method);
|
||||
std::string getStringCodeSwitch(int method);
|
||||
static std::string getCodeSwitchTuple(int code);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLRISINGSUN_H_
|
||||
108
external/tellstick-core/ProtocolSartano.cpp
vendored
Normal file
108
external/tellstick-core/ProtocolSartano.cpp
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolSartano.h"
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned __int16 uint16_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
int ProtocolSartano::methods() const {
|
||||
return TELLSTICK_TURNON | TELLSTICK_TURNOFF;
|
||||
}
|
||||
|
||||
std::string ProtocolSartano::getStringForMethod(int method, unsigned char, Controller *) {
|
||||
std::wstring strCode = this->getStringParameter(L"code", L"");
|
||||
return getStringForCode(strCode, method);
|
||||
}
|
||||
|
||||
std::string ProtocolSartano::getStringForCode(const std::wstring &strCode, int method) {
|
||||
std::string strReturn("S");
|
||||
|
||||
for (size_t i = 0; i < strCode.length(); ++i) {
|
||||
if (strCode[i] == L'1') {
|
||||
strReturn.append("$k$k");
|
||||
} else {
|
||||
strReturn.append("$kk$");
|
||||
}
|
||||
}
|
||||
|
||||
if (method == TELLSTICK_TURNON) {
|
||||
strReturn.append("$k$k$kk$$k+");
|
||||
} else if (method == TELLSTICK_TURNOFF) {
|
||||
strReturn.append("$kk$$k$k$k+");
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
std::string ProtocolSartano::decodeData(const ControllerMessage &dataMsg) {
|
||||
uint64_t allDataIn;
|
||||
uint16_t allData = 0;
|
||||
unsigned int code = 0;
|
||||
unsigned int method1 = 0;
|
||||
unsigned int method2 = 0;
|
||||
unsigned int method = 0;
|
||||
|
||||
allDataIn = dataMsg.getInt64Parameter("data");
|
||||
|
||||
uint16_t mask = (1<<11);
|
||||
for(int i = 0; i < 12; ++i) {
|
||||
allData >>= 1;
|
||||
if((allDataIn & mask) == 0) {
|
||||
allData |= (1<<11);
|
||||
}
|
||||
mask >>= 1;
|
||||
}
|
||||
|
||||
code = allData & 0xFFC;
|
||||
code >>= 2;
|
||||
|
||||
method1 = allData & 0x2;
|
||||
method1 >>= 1;
|
||||
|
||||
method2 = allData & 0x1;
|
||||
|
||||
if(method1 == 0 && method2 == 1) {
|
||||
method = 0; // off
|
||||
} else if(method1 == 1 && method2 == 0) {
|
||||
method = 1; // on
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
if(code > 1023) {
|
||||
// not sartano
|
||||
return "";
|
||||
}
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:command;protocol:sartano;model:codeswitch;code:";
|
||||
mask = (1<<9);
|
||||
for(int i = 0; i < 10; i++) {
|
||||
if((code & mask) != 0) {
|
||||
retString << 1;
|
||||
} else {
|
||||
retString << 0;
|
||||
}
|
||||
mask >>= 1;
|
||||
}
|
||||
retString << ";method:";
|
||||
|
||||
if(method == 0) {
|
||||
retString << "turnoff;";
|
||||
} else {
|
||||
retString << "turnon;";
|
||||
}
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
24
external/tellstick-core/ProtocolSartano.h
vendored
Normal file
24
external/tellstick-core/ProtocolSartano.h
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLSARTANO_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLSARTANO_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
#include "service/ControllerMessage.h"
|
||||
|
||||
class ProtocolSartano : public Protocol {
|
||||
public:
|
||||
int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
static std::string decodeData(const ControllerMessage &dataMsg);
|
||||
|
||||
protected:
|
||||
std::string getStringForCode(const std::wstring &code, int method);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLSARTANO_H_
|
||||
16
external/tellstick-core/ProtocolScene.cpp
vendored
Normal file
16
external/tellstick-core/ProtocolScene.cpp
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolScene.h"
|
||||
#include <string>
|
||||
|
||||
int ProtocolScene::methods() const {
|
||||
return TELLSTICK_EXECUTE;
|
||||
}
|
||||
|
||||
std::string ProtocolScene::getStringForMethod(int method, unsigned char data, Controller *) {
|
||||
return "";
|
||||
}
|
||||
22
external/tellstick-core/ProtocolScene.h
vendored
Normal file
22
external/tellstick-core/ProtocolScene.h
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLSCENE_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLSCENE_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
|
||||
class ProtocolScene : public Protocol {
|
||||
public:
|
||||
virtual int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLSCENE_H_
|
||||
|
||||
|
||||
|
||||
146
external/tellstick-core/ProtocolSilvanChip.cpp
vendored
Normal file
146
external/tellstick-core/ProtocolSilvanChip.cpp
vendored
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolSilvanChip.h"
|
||||
#include <string>
|
||||
#include "common/Strings.h"
|
||||
|
||||
int ProtocolSilvanChip::methods() const {
|
||||
if (TelldusCore::comparei(model(), L"kp100")) {
|
||||
return TELLSTICK_UP | TELLSTICK_DOWN | TELLSTICK_STOP | TELLSTICK_LEARN;
|
||||
} else if (TelldusCore::comparei(model(), L"ecosavers")) {
|
||||
return TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN;
|
||||
} else if (TelldusCore::comparei(model(), L"displaymatic")) {
|
||||
return TELLSTICK_UP | TELLSTICK_DOWN | TELLSTICK_STOP;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string ProtocolSilvanChip::getStringForMethod(int method, unsigned char data, Controller *controller) {
|
||||
if (TelldusCore::comparei(model(), L"kp100")) {
|
||||
std::string preamble;
|
||||
preamble.append(1, 100);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 100);
|
||||
|
||||
const std::string one = "\xFF\x1\x2E\x2E";
|
||||
const std::string zero = "\x2E\xFF\x1\x2E";
|
||||
int button = 0;
|
||||
if (method == TELLSTICK_UP) {
|
||||
button = 2;
|
||||
} else if (method == TELLSTICK_DOWN) {
|
||||
button = 8;
|
||||
} else if (method == TELLSTICK_STOP) {
|
||||
button = 4;
|
||||
} else if (method == TELLSTICK_LEARN) {
|
||||
button = 1;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return this->getString(preamble, one, zero, button);
|
||||
} else if (TelldusCore::comparei(model(), L"displaymatic")) {
|
||||
std::string preamble;
|
||||
preamble.append(1, 0x25);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 0x25);
|
||||
const std::string one = "\x69\25";
|
||||
const std::string zero = "\x25\x69";
|
||||
int button = 0;
|
||||
if (method == TELLSTICK_UP) {
|
||||
button = 1;
|
||||
} else if (method == TELLSTICK_DOWN) {
|
||||
button = 4;
|
||||
} else if (method == TELLSTICK_STOP) {
|
||||
button = 2;
|
||||
}
|
||||
return this->getString(preamble, one, zero, button);
|
||||
} else if (TelldusCore::comparei(model(), L"ecosavers")) {
|
||||
std::string preamble;
|
||||
preamble.append(1, 0x25);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 255);
|
||||
preamble.append(1, 1);
|
||||
preamble.append(1, 0x25);
|
||||
const std::string one = "\x69\25";
|
||||
const std::string zero = "\x25\x69";
|
||||
int intUnit = this->getIntParameter(L"unit", 1, 4);
|
||||
int button = 0;
|
||||
if (intUnit == 1) {
|
||||
button = 7;
|
||||
} else if (intUnit == 2) {
|
||||
button = 3;
|
||||
} else if (intUnit == 3) {
|
||||
button = 5;
|
||||
} else if (intUnit == 4) {
|
||||
button = 6;
|
||||
}
|
||||
|
||||
if (method == TELLSTICK_TURNON || method == TELLSTICK_LEARN) {
|
||||
button |= 8;
|
||||
}
|
||||
return this->getString(preamble, one, zero, button);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string ProtocolSilvanChip::getString(const std::string &preamble, const std::string &one, const std::string &zero, int button) {
|
||||
int intHouse = this->getIntParameter(L"house", 1, 1048575);
|
||||
std::string strReturn = preamble;
|
||||
|
||||
for( int i = 19; i >= 0; --i ) {
|
||||
if (intHouse & (1 << i)) {
|
||||
strReturn.append(one);
|
||||
} else {
|
||||
strReturn.append(zero);
|
||||
}
|
||||
}
|
||||
|
||||
for( int i = 3; i >= 0; --i) {
|
||||
if (button & (1 << i)) {
|
||||
strReturn.append(one);
|
||||
} else {
|
||||
strReturn.append(zero);
|
||||
}
|
||||
}
|
||||
|
||||
strReturn.append(zero);
|
||||
return strReturn;
|
||||
}
|
||||
22
external/tellstick-core/ProtocolSilvanChip.h
vendored
Normal file
22
external/tellstick-core/ProtocolSilvanChip.h
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLSILVANCHIP_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLSILVANCHIP_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
|
||||
class ProtocolSilvanChip : public Protocol {
|
||||
public:
|
||||
int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
|
||||
protected:
|
||||
virtual std::string getString(const std::string &preamble, const std::string &one, const std::string &zero, int button);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLSILVANCHIP_H_
|
||||
78
external/tellstick-core/ProtocolUpm.cpp
vendored
Normal file
78
external/tellstick-core/ProtocolUpm.cpp
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolUpm.h"
|
||||
#include <string>
|
||||
|
||||
int ProtocolUpm::methods() const {
|
||||
return TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN;
|
||||
}
|
||||
|
||||
std::string ProtocolUpm::getStringForMethod(int method, unsigned char, Controller *) {
|
||||
const char S = ';';
|
||||
const char L = '~';
|
||||
const char START[] = {S, 0};
|
||||
const char B1[] = {L, S, 0};
|
||||
const char B0[] = {S, L, 0};
|
||||
// const char BON[] = {S,L,L,S,0};
|
||||
// const char BOFF[] = {S,L,S,L,0};
|
||||
|
||||
int intUnit = this->getIntParameter(L"unit", 1, 4)-1;
|
||||
std::string strReturn;
|
||||
|
||||
int code = this->getIntParameter(L"house", 0, 4095);
|
||||
for( size_t i = 0; i < 12; ++i ) {
|
||||
if (code & 1) {
|
||||
strReturn.insert(0, B1);
|
||||
} else {
|
||||
strReturn.insert(0, B0);
|
||||
}
|
||||
code >>= 1;
|
||||
}
|
||||
strReturn.insert(0, START); // Startcode, first
|
||||
|
||||
code = 0;
|
||||
if (method == TELLSTICK_TURNON || method == TELLSTICK_LEARN) {
|
||||
code += 2;
|
||||
} else if (method != TELLSTICK_TURNOFF) {
|
||||
return "";
|
||||
}
|
||||
code <<= 2;
|
||||
code += intUnit;
|
||||
|
||||
int check1 = 0, check2 = 0;
|
||||
for( size_t i = 0; i < 6; ++i ) {
|
||||
if (code & 1) {
|
||||
if (i % 2 == 0) {
|
||||
check1++;
|
||||
} else {
|
||||
check2++;
|
||||
}
|
||||
}
|
||||
if (code & 1) {
|
||||
strReturn.append(B1);
|
||||
} else {
|
||||
strReturn.append(B0);
|
||||
}
|
||||
code >>= 1;
|
||||
}
|
||||
|
||||
if (check1 % 2 == 0) {
|
||||
strReturn.append(B0);
|
||||
} else {
|
||||
strReturn.append(B1);
|
||||
}
|
||||
if (check2 % 2 == 0) {
|
||||
strReturn.append(B0);
|
||||
} else {
|
||||
strReturn.append(B1);
|
||||
}
|
||||
|
||||
strReturn.insert(0, "S");
|
||||
strReturn.append("+");
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
19
external/tellstick-core/ProtocolUpm.h
vendored
Normal file
19
external/tellstick-core/ProtocolUpm.h
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLUPM_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLUPM_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
|
||||
class ProtocolUpm : public Protocol {
|
||||
public:
|
||||
int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLUPM_H_
|
||||
77
external/tellstick-core/ProtocolWaveman.cpp
vendored
Normal file
77
external/tellstick-core/ProtocolWaveman.cpp
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolWaveman.h"
|
||||
#ifdef _MSC_VER
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
int ProtocolWaveman::lastArctecCodeSwitchWasTurnOff = 0;
|
||||
|
||||
int ProtocolWaveman::methods() const {
|
||||
return TELLSTICK_TURNON | TELLSTICK_TURNOFF;
|
||||
}
|
||||
|
||||
std::string ProtocolWaveman::getStringForMethod(int method, unsigned char, Controller *) {
|
||||
return getStringCodeSwitch(method);
|
||||
}
|
||||
|
||||
std::string ProtocolWaveman::getOffCode() const {
|
||||
return "$k$k$k$k$k$k$k$k$k+";
|
||||
}
|
||||
|
||||
std::string ProtocolWaveman::decodeData(const ControllerMessage& dataMsg) {
|
||||
uint64_t allData = 0;
|
||||
unsigned int house = 0;
|
||||
unsigned int unit = 0;
|
||||
unsigned int method = 0;
|
||||
|
||||
allData = dataMsg.getInt64Parameter("data");
|
||||
|
||||
method = allData & 0xF00;
|
||||
method >>= 8;
|
||||
|
||||
unit = allData & 0xF0;
|
||||
unit >>= 4;
|
||||
unit++;
|
||||
|
||||
house = allData & 0xF;
|
||||
|
||||
if(house > 16 || unit < 1 || unit > 16) {
|
||||
// not waveman
|
||||
return "";
|
||||
}
|
||||
|
||||
house = house + 'A'; // house from A to P
|
||||
|
||||
if(method != 6 && lastArctecCodeSwitchWasTurnOff == 1) {
|
||||
lastArctecCodeSwitchWasTurnOff = 0;
|
||||
return ""; // probably a stray turnon or bell (perhaps: only certain time interval since last, check that it's the same house/unit... Will lose
|
||||
// one turnon/bell, but it's better than the alternative...
|
||||
}
|
||||
|
||||
if(method == 6) {
|
||||
lastArctecCodeSwitchWasTurnOff = 1;
|
||||
}
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:command;protocol:waveman;model:codeswitch;house:" << static_cast<char>(house);
|
||||
|
||||
if(method == 0) {
|
||||
retString << ";unit:" << unit << ";method:turnoff;";
|
||||
} else if(method == 14) {
|
||||
retString << ";unit:" << unit << ";method:turnon;";
|
||||
} else {
|
||||
// not waveman
|
||||
return "";
|
||||
}
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
26
external/tellstick-core/ProtocolWaveman.h
vendored
Normal file
26
external/tellstick-core/ProtocolWaveman.h
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLWAVEMAN_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLWAVEMAN_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/ProtocolNexa.h"
|
||||
|
||||
class ProtocolWaveman : public ProtocolNexa {
|
||||
public:
|
||||
int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
static std::string decodeData(const ControllerMessage &dataMsg);
|
||||
|
||||
protected:
|
||||
virtual std::string getOffCode() const;
|
||||
|
||||
private:
|
||||
static int lastArctecCodeSwitchWasTurnOff;
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLWAVEMAN_H_
|
||||
185
external/tellstick-core/ProtocolX10.cpp
vendored
Normal file
185
external/tellstick-core/ProtocolX10.cpp
vendored
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "service/ProtocolX10.h"
|
||||
#ifdef _MSC_VER
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
const unsigned char HOUSES[] = {6, 0xE, 2, 0xA, 1, 9, 5, 0xD, 7, 0xF, 3, 0xB, 0, 8, 4, 0xC};
|
||||
|
||||
int ProtocolX10::methods() const {
|
||||
return TELLSTICK_TURNON | TELLSTICK_TURNOFF;
|
||||
}
|
||||
|
||||
std::string ProtocolX10::getStringForMethod(int method, unsigned char data, Controller *controller) {
|
||||
const unsigned char S = 59, L = 169;
|
||||
const char B0[] = {S, S, 0};
|
||||
const char B1[] = {S, L, 0};
|
||||
const unsigned char START_CODE[] = {'S', 255, 1, 255, 1, 255, 1, 100, 255, 1, 180, 0};
|
||||
const unsigned char STOP_CODE[] = {S, 0};
|
||||
|
||||
std::string strReturn = reinterpret_cast<const char*>(START_CODE);
|
||||
std::string strComplement = "";
|
||||
|
||||
std::wstring strHouse = getStringParameter(L"house", L"A");
|
||||
int intHouse = strHouse[0] - L'A';
|
||||
if (intHouse < 0) {
|
||||
intHouse = 0;
|
||||
} else if (intHouse > 15) {
|
||||
intHouse = 15;
|
||||
}
|
||||
// Translate it
|
||||
intHouse = HOUSES[intHouse];
|
||||
int intCode = getIntParameter(L"unit", 1, 16)-1;
|
||||
|
||||
for( int i = 0; i < 4; ++i ) {
|
||||
if (intHouse & 1) {
|
||||
strReturn.append(B1);
|
||||
strComplement.append(B0);
|
||||
} else {
|
||||
strReturn.append(B0);
|
||||
strComplement.append(B1);
|
||||
}
|
||||
intHouse >>= 1;
|
||||
}
|
||||
strReturn.append( B0 );
|
||||
strComplement.append( B1 );
|
||||
|
||||
if (intCode >= 8) {
|
||||
strReturn.append(B1);
|
||||
strComplement.append(B0);
|
||||
} else {
|
||||
strReturn.append(B0);
|
||||
strComplement.append(B1);
|
||||
}
|
||||
|
||||
strReturn.append( B0 );
|
||||
strComplement.append( B1 );
|
||||
strReturn.append( B0 );
|
||||
strComplement.append( B1 );
|
||||
|
||||
strReturn.append( strComplement );
|
||||
strComplement = "";
|
||||
|
||||
strReturn.append( B0 );
|
||||
strComplement.append( B1 );
|
||||
|
||||
if (intCode >> 2 & 1) { // Bit 2 of intCode
|
||||
strReturn.append(B1);
|
||||
strComplement.append(B0);
|
||||
} else {
|
||||
strReturn.append(B0);
|
||||
strComplement.append(B1);
|
||||
}
|
||||
|
||||
if (method == TELLSTICK_TURNON) {
|
||||
strReturn.append(B0);
|
||||
strComplement.append(B1);
|
||||
} else if (method == TELLSTICK_TURNOFF) {
|
||||
strReturn.append(B1);
|
||||
strComplement.append(B0);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (intCode & 1) { // Bit 0 of intCode
|
||||
strReturn.append(B1);
|
||||
strComplement.append(B0);
|
||||
} else {
|
||||
strReturn.append(B0);
|
||||
strComplement.append(B1);
|
||||
}
|
||||
|
||||
if (intCode >> 1 & 1) { // Bit 1 of intCode
|
||||
strReturn.append(B1);
|
||||
strComplement.append(B0);
|
||||
} else {
|
||||
strReturn.append(B0);
|
||||
strComplement.append(B1);
|
||||
}
|
||||
|
||||
for( int i = 0; i < 3; ++i ) {
|
||||
strReturn.append( B0 );
|
||||
strComplement.append( B1 );
|
||||
}
|
||||
|
||||
strReturn.append( strComplement );
|
||||
strReturn.append( reinterpret_cast<const char*>(STOP_CODE) );
|
||||
strReturn.append("+");
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
std::string ProtocolX10::decodeData(const ControllerMessage& dataMsg) {
|
||||
uint64_t intData = 0, currentBit = 31;
|
||||
bool method = 0;
|
||||
|
||||
intData = dataMsg.getInt64Parameter("data");
|
||||
|
||||
int unit = 0;
|
||||
int rawHouse = 0;
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
rawHouse >>= 1;
|
||||
if (checkBit(intData, currentBit--)) {
|
||||
rawHouse |= 0x8;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkBit(intData, currentBit--) != 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (checkBit(intData, currentBit--)) {
|
||||
unit |= (1<<3);
|
||||
}
|
||||
|
||||
if (checkBit(intData, currentBit--)) {
|
||||
return "";
|
||||
}
|
||||
if (checkBit(intData, currentBit--)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
currentBit = 14;
|
||||
|
||||
if (checkBit(intData, currentBit--)) {
|
||||
unit |= (1<<2);
|
||||
}
|
||||
if (checkBit(intData, currentBit--)) {
|
||||
method = 1;
|
||||
}
|
||||
if (checkBit(intData, currentBit--)) {
|
||||
unit |= (1<<0);
|
||||
}
|
||||
if (checkBit(intData, currentBit--)) {
|
||||
unit |= (1<<1);
|
||||
}
|
||||
|
||||
int intHouse = 0;
|
||||
for(int i = 0; i < 16; ++i) {
|
||||
if (HOUSES[i] == rawHouse) {
|
||||
intHouse = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream retString;
|
||||
retString << "class:command;protocol:x10;model:codeswitch;";
|
||||
retString << "house:" << static_cast<char>('A' + intHouse);
|
||||
retString << ";unit:" << unit+1;
|
||||
retString << ";method:";
|
||||
if(method == 0) {
|
||||
retString << "turnon;";
|
||||
} else {
|
||||
retString << "turnoff;";
|
||||
}
|
||||
|
||||
return retString.str();
|
||||
}
|
||||
22
external/tellstick-core/ProtocolX10.h
vendored
Normal file
22
external/tellstick-core/ProtocolX10.h
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLX10_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLX10_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/Protocol.h"
|
||||
#include "service/ControllerMessage.h"
|
||||
|
||||
class ProtocolX10 : public Protocol {
|
||||
public:
|
||||
int methods() const;
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
|
||||
static std::string decodeData(const ControllerMessage &dataMsg);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLX10_H_
|
||||
31
external/tellstick-core/ProtocolYidong.cpp
vendored
Normal file
31
external/tellstick-core/ProtocolYidong.cpp
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include <string>
|
||||
#include "service/ProtocolYidong.h"
|
||||
|
||||
std::string ProtocolYidong::getStringForMethod(int method, unsigned char, Controller *) {
|
||||
int intCode = this->getIntParameter(L"unit", 1, 4);
|
||||
std::wstring strCode = L"111";
|
||||
|
||||
switch(intCode) {
|
||||
case 1:
|
||||
strCode.append(L"0010");
|
||||
break;
|
||||
case 2:
|
||||
strCode.append(L"0001");
|
||||
break;
|
||||
case 3:
|
||||
strCode.append(L"0100");
|
||||
break;
|
||||
case 4:
|
||||
strCode.append(L"1000");
|
||||
break;
|
||||
}
|
||||
|
||||
strCode.append(L"110");
|
||||
return getStringForCode(strCode, method);
|
||||
}
|
||||
18
external/tellstick-core/ProtocolYidong.h
vendored
Normal file
18
external/tellstick-core/ProtocolYidong.h
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLYIDONG_H_
|
||||
#define TELLDUS_CORE_SERVICE_PROTOCOLYIDONG_H_
|
||||
|
||||
#include <string>
|
||||
#include "service/ProtocolSartano.h"
|
||||
|
||||
class ProtocolYidong : public ProtocolSartano {
|
||||
public:
|
||||
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||
};
|
||||
|
||||
#endif // TELLDUS_CORE_SERVICE_PROTOCOLYIDONG_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue