Added protocol Yidong
This commit is contained in:
parent
ba56976c9f
commit
fce9214a71
4 changed files with 120 additions and 73 deletions
|
@ -40,6 +40,8 @@ SET( telldus-service_protocol_SRCS
|
||||||
ProtocolWaveman.cpp
|
ProtocolWaveman.cpp
|
||||||
ProtocolX10.h
|
ProtocolX10.h
|
||||||
ProtocolX10.cpp
|
ProtocolX10.cpp
|
||||||
|
ProtocolYidong.h
|
||||||
|
ProtocolYidong.cpp
|
||||||
)
|
)
|
||||||
SET( telldus-service_HDRS
|
SET( telldus-service_HDRS
|
||||||
ClientCommunicationHandler.h
|
ClientCommunicationHandler.h
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "ProtocolUpm.h"
|
#include "ProtocolUpm.h"
|
||||||
#include "ProtocolWaveman.h"
|
#include "ProtocolWaveman.h"
|
||||||
#include "ProtocolX10.h"
|
#include "ProtocolX10.h"
|
||||||
|
#include "ProtocolYidong.h"
|
||||||
|
|
||||||
#include "Strings.h"
|
#include "Strings.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -24,7 +25,7 @@ public:
|
||||||
|
|
||||||
Protocol::Protocol(){
|
Protocol::Protocol(){
|
||||||
|
|
||||||
d = new PrivateData;
|
d = new PrivateData;
|
||||||
}
|
}
|
||||||
|
|
||||||
Protocol::~Protocol(void) {
|
Protocol::~Protocol(void) {
|
||||||
|
@ -35,7 +36,7 @@ std::wstring Protocol::model() const {
|
||||||
std::wstring strModel = d->model;
|
std::wstring strModel = d->model;
|
||||||
//Strip anything after : if it is found
|
//Strip anything after : if it is found
|
||||||
size_t pos = strModel.find(L":");
|
size_t pos = strModel.find(L":");
|
||||||
if (pos != std::wstring::npos) {
|
if (pos != std::wstring::npos) {
|
||||||
strModel = strModel.substr(0, pos);
|
strModel = strModel.substr(0, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,39 +78,42 @@ int Protocol::getIntParameter(const std::wstring &name, int min, int max) const
|
||||||
}
|
}
|
||||||
|
|
||||||
Protocol *Protocol::getProtocolInstance(const std::wstring &protocolname){
|
Protocol *Protocol::getProtocolInstance(const std::wstring &protocolname){
|
||||||
|
|
||||||
if(TelldusCore::comparei(protocolname, L"arctech")){
|
if(TelldusCore::comparei(protocolname, L"arctech")){
|
||||||
return new ProtocolNexa();
|
return new ProtocolNexa();
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolname, L"brateck")) {
|
} else if (TelldusCore::comparei(protocolname, L"brateck")) {
|
||||||
return new ProtocolBrateck();
|
return new ProtocolBrateck();
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolname, L"everflourish")) {
|
} else if (TelldusCore::comparei(protocolname, L"everflourish")) {
|
||||||
return new ProtocolEverflourish();
|
return new ProtocolEverflourish();
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolname, L"fuhaote")) {
|
} else if (TelldusCore::comparei(protocolname, L"fuhaote")) {
|
||||||
return new ProtocolFuhaote();
|
return new ProtocolFuhaote();
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolname, L"ikea")) {
|
} else if (TelldusCore::comparei(protocolname, L"ikea")) {
|
||||||
return new ProtocolIkea();
|
return new ProtocolIkea();
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolname, L"risingsun")) {
|
} else if (TelldusCore::comparei(protocolname, L"risingsun")) {
|
||||||
return new ProtocolRisingSun();
|
return new ProtocolRisingSun();
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolname, L"sartano")) {
|
} else if (TelldusCore::comparei(protocolname, L"sartano")) {
|
||||||
return new ProtocolSartano();
|
return new ProtocolSartano();
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolname, L"silvanchip")) {
|
} else if (TelldusCore::comparei(protocolname, L"silvanchip")) {
|
||||||
return new ProtocolSilvanChip();
|
return new ProtocolSilvanChip();
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolname, L"upm")) {
|
} else if (TelldusCore::comparei(protocolname, L"upm")) {
|
||||||
return new ProtocolUpm();
|
return new ProtocolUpm();
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolname, L"waveman")) {
|
} else if (TelldusCore::comparei(protocolname, L"waveman")) {
|
||||||
return new ProtocolWaveman();
|
return new ProtocolWaveman();
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolname, L"x10")) {
|
} else if (TelldusCore::comparei(protocolname, L"x10")) {
|
||||||
return new ProtocolX10();
|
return new ProtocolX10();
|
||||||
|
|
||||||
|
} else if (TelldusCore::comparei(protocolname, L"yidong")) {
|
||||||
|
return new ProtocolYidong();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -119,45 +123,48 @@ std::list<std::string> Protocol::getParametersForProtocol(const std::wstring &pr
|
||||||
std::list<std::string> parameters;
|
std::list<std::string> parameters;
|
||||||
|
|
||||||
if(TelldusCore::comparei(protocolName, L"arctech")){
|
if(TelldusCore::comparei(protocolName, L"arctech")){
|
||||||
parameters.push_back("house");
|
parameters.push_back("house");
|
||||||
parameters.push_back("unit");
|
parameters.push_back("unit");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"brateck")) {
|
} else if (TelldusCore::comparei(protocolName, L"brateck")) {
|
||||||
parameters.push_back("house");
|
parameters.push_back("house");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"everflourish")) {
|
} else if (TelldusCore::comparei(protocolName, L"everflourish")) {
|
||||||
parameters.push_back("house");
|
parameters.push_back("house");
|
||||||
parameters.push_back("unit");
|
parameters.push_back("unit");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"fuhaote")) {
|
} else if (TelldusCore::comparei(protocolName, L"fuhaote")) {
|
||||||
parameters.push_back("code");
|
parameters.push_back("code");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"ikea")) {
|
} else if (TelldusCore::comparei(protocolName, L"ikea")) {
|
||||||
parameters.push_back("system");
|
parameters.push_back("system");
|
||||||
parameters.push_back("units");
|
parameters.push_back("units");
|
||||||
//parameters.push_back("fade");
|
//parameters.push_back("fade");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"risingsun")) {
|
} else if (TelldusCore::comparei(protocolName, L"risingsun")) {
|
||||||
parameters.push_back("house");
|
parameters.push_back("house");
|
||||||
parameters.push_back("unit");
|
parameters.push_back("unit");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"sartano")) {
|
} else if (TelldusCore::comparei(protocolName, L"sartano")) {
|
||||||
parameters.push_back("code");
|
parameters.push_back("code");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"silvanchip")) {
|
} else if (TelldusCore::comparei(protocolName, L"silvanchip")) {
|
||||||
parameters.push_back("house");
|
parameters.push_back("house");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"upm")) {
|
} else if (TelldusCore::comparei(protocolName, L"upm")) {
|
||||||
parameters.push_back("house");
|
parameters.push_back("house");
|
||||||
parameters.push_back("unit");
|
parameters.push_back("unit");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"waveman")) {
|
} else if (TelldusCore::comparei(protocolName, L"waveman")) {
|
||||||
parameters.push_back("house");
|
parameters.push_back("house");
|
||||||
parameters.push_back("unit");
|
parameters.push_back("unit");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"x10")) {
|
} else if (TelldusCore::comparei(protocolName, L"x10")) {
|
||||||
parameters.push_back("house");
|
parameters.push_back("house");
|
||||||
parameters.push_back("unit");
|
parameters.push_back("unit");
|
||||||
|
|
||||||
|
} else if (TelldusCore::comparei(protocolName, L"yidong")) {
|
||||||
|
parameters.push_back("unit");
|
||||||
}
|
}
|
||||||
|
|
||||||
return parameters;
|
return parameters;
|
||||||
|
|
26
telldus-core/service/ProtocolYidong.cpp
Normal file
26
telldus-core/service/ProtocolYidong.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include "ProtocolYidong.h"
|
||||||
|
#include <stdio.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");
|
||||||
|
printf("Code: %s\n", std::string(strCode.begin(), strCode.end()).c_str());
|
||||||
|
return getStringForCode(strCode, method);
|
||||||
|
}
|
12
telldus-core/service/ProtocolYidong.h
Normal file
12
telldus-core/service/ProtocolYidong.h
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef PROTOCOLYIDONG_H
|
||||||
|
#define PROTOCOLYIDONG_H
|
||||||
|
|
||||||
|
#include "ProtocolSartano.h"
|
||||||
|
|
||||||
|
class ProtocolYidong : public ProtocolSartano
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //PROTOCOLYIDONG_H
|
Loading…
Add table
Add a link
Reference in a new issue