Implemented decoding of Fineoffset new short format. Hopefully this
fixes #92. If not, please reopen. This also requires firmware 5 or later in TellStick Duo.
This commit is contained in:
parent
808385705f
commit
ff7130561c
4 changed files with 71 additions and 4 deletions
|
@ -34,6 +34,8 @@ SET( telldus-service_protocol_SRCS
|
||||||
ProtocolComen.cpp
|
ProtocolComen.cpp
|
||||||
ProtocolEverflourish.h
|
ProtocolEverflourish.h
|
||||||
ProtocolEverflourish.cpp
|
ProtocolEverflourish.cpp
|
||||||
|
ProtocolFineoffset.h
|
||||||
|
ProtocolFineoffset.cpp
|
||||||
ProtocolFuhaote.h
|
ProtocolFuhaote.h
|
||||||
ProtocolFuhaote.cpp
|
ProtocolFuhaote.cpp
|
||||||
ProtocolGroup.h
|
ProtocolGroup.h
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "ProtocolBrateck.h"
|
#include "ProtocolBrateck.h"
|
||||||
#include "ProtocolComen.h"
|
#include "ProtocolComen.h"
|
||||||
#include "ProtocolEverflourish.h"
|
#include "ProtocolEverflourish.h"
|
||||||
|
#include "ProtocolFineoffset.h"
|
||||||
#include "ProtocolFuhaote.h"
|
#include "ProtocolFuhaote.h"
|
||||||
#include "ProtocolGroup.h"
|
#include "ProtocolGroup.h"
|
||||||
#include "ProtocolHasta.h"
|
#include "ProtocolHasta.h"
|
||||||
|
@ -195,10 +196,10 @@ std::list<std::string> Protocol::getParametersForProtocol(const std::wstring &pr
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"yidong")) {
|
} else if (TelldusCore::comparei(protocolName, L"yidong")) {
|
||||||
parameters.push_back("unit");
|
parameters.push_back("unit");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"group")) {
|
} else if (TelldusCore::comparei(protocolName, L"group")) {
|
||||||
parameters.push_back("devices");
|
parameters.push_back("devices");
|
||||||
|
|
||||||
} else if (TelldusCore::comparei(protocolName, L"scene")) {
|
} else if (TelldusCore::comparei(protocolName, L"scene")) {
|
||||||
parameters.push_back("devices");
|
parameters.push_back("devices");
|
||||||
}
|
}
|
||||||
|
@ -209,7 +210,7 @@ std::list<std::string> Protocol::getParametersForProtocol(const std::wstring &pr
|
||||||
std::list<std::string> Protocol::decodeData(const std::string &fullData) {
|
std::list<std::string> Protocol::decodeData(const std::string &fullData) {
|
||||||
std::list<std::string> retval;
|
std::list<std::string> retval;
|
||||||
std::string decoded = "";
|
std::string decoded = "";
|
||||||
|
|
||||||
ControllerMessage dataMsg(fullData);
|
ControllerMessage dataMsg(fullData);
|
||||||
if( TelldusCore::comparei(dataMsg.protocol(), L"arctech") ) {
|
if( TelldusCore::comparei(dataMsg.protocol(), L"arctech") ) {
|
||||||
decoded = ProtocolNexa::decodeData(dataMsg);
|
decoded = ProtocolNexa::decodeData(dataMsg);
|
||||||
|
@ -231,12 +232,18 @@ std::list<std::string> Protocol::decodeData(const std::string &fullData) {
|
||||||
retval.push_back(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"x10") ) {
|
else if(TelldusCore::comparei(dataMsg.protocol(), L"x10") ) {
|
||||||
decoded = ProtocolX10::decodeData(dataMsg);
|
decoded = ProtocolX10::decodeData(dataMsg);
|
||||||
if (decoded != "") {
|
if (decoded != "") {
|
||||||
retval.push_back(decoded);
|
retval.push_back(decoded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
45
telldus-core/service/ProtocolFineoffset.cpp
Normal file
45
telldus-core/service/ProtocolFineoffset.cpp
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#include "ProtocolFineoffset.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
std::string ProtocolFineoffset::decodeData(ControllerMessage &dataMsg)
|
||||||
|
{
|
||||||
|
std::string data = dataMsg.getParameter("data");
|
||||||
|
if (data.length() < 8) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t checksum = strtol(data.substr(data.length()-2).c_str(), NULL, 16);
|
||||||
|
data = data.substr(0, data.length()-2);
|
||||||
|
|
||||||
|
uint8_t humidity = strtol(data.substr(data.length()-2).c_str(), NULL, 16);
|
||||||
|
data = data.substr(0, data.length()-2);
|
||||||
|
|
||||||
|
uint16_t value = strtol(data.substr(data.length()-3).c_str(), NULL, 16);
|
||||||
|
double temperature = (value & 0x7FF)/10.0;
|
||||||
|
|
||||||
|
value >>= 11;
|
||||||
|
if (value & 1) {
|
||||||
|
temperature = -temperature;
|
||||||
|
}
|
||||||
|
data = data.substr(0, data.length()-3);
|
||||||
|
|
||||||
|
uint16_t id = strtol(data.c_str(), NULL, 16) & 0xFF;
|
||||||
|
|
||||||
|
std::stringstream retString;
|
||||||
|
retString << "class:sensor;protocol:fineoffset;id:" << id << ";model:";
|
||||||
|
|
||||||
|
if (humidity <= 100) {
|
||||||
|
retString << "temperaturehumidity;humidity:" << (int)humidity << ";";
|
||||||
|
} else if (humidity == 0xFF) {
|
||||||
|
retString << "temperature;";
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
retString << "temp:" << std::fixed << std::setprecision(1) << temperature << ";";
|
||||||
|
|
||||||
|
return retString.str();
|
||||||
|
}
|
13
telldus-core/service/ProtocolFineoffset.h
Normal file
13
telldus-core/service/ProtocolFineoffset.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef PROTOCOLFINEOFFSET_H
|
||||||
|
#define PROTOCOLFINEOFFSET_H
|
||||||
|
|
||||||
|
#include "ControllerMessage.h"
|
||||||
|
#include "Protocol.h"
|
||||||
|
|
||||||
|
class ProtocolFineoffset : public Protocol
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static std::string decodeData(ControllerMessage &dataMsg);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //PROTOCOLFINEOFFSET_H
|
Loading…
Add table
Add a link
Reference in a new issue