From 61d0b2ac09a6f4e9fb2dfd9dd797796ae26266cb Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Wed, 20 Jun 2012 17:15:26 +0200 Subject: [PATCH] Implement protocol Comen by hardcoding the last to bits in the housecode --- telldus-core/service/ProtocolComen.cpp | 16 ++++++++++------ telldus-core/service/ProtocolComen.h | 4 +++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/telldus-core/service/ProtocolComen.cpp b/telldus-core/service/ProtocolComen.cpp index 2652fde4..dfc7d38d 100644 --- a/telldus-core/service/ProtocolComen.cpp +++ b/telldus-core/service/ProtocolComen.cpp @@ -8,12 +8,16 @@ #include int ProtocolComen::methods() const { - return (TELLSTICK_TURNON | TELLSTICK_TURNOFF); + return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN); } -std::string ProtocolComen::getStringForMethod(int method, unsigned char level, Controller *) { - int intHouse = getIntParameter(L"house", 1, 33554431); - intHouse <<= 1; // They seem to only accept even codes? - int intCode = getIntParameter(L"unit", 1, 16)-1; - return getStringSelflearningForCode(intHouse, intCode, method, level); +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); } diff --git a/telldus-core/service/ProtocolComen.h b/telldus-core/service/ProtocolComen.h index a9ef9211..f43167a8 100644 --- a/telldus-core/service/ProtocolComen.h +++ b/telldus-core/service/ProtocolComen.h @@ -13,7 +13,9 @@ class ProtocolComen : public ProtocolNexa { public: virtual int methods() const; - virtual std::string getStringForMethod(int method, unsigned char data, Controller *controller); + +protected: + virtual int getIntParameter(const std::wstring &name, int min, int max) const; }; #endif // TELLDUS_CORE_SERVICE_PROTOCOLCOMEN_H_