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
|
||||
ProtocolEverflourish.h
|
||||
ProtocolEverflourish.cpp
|
||||
ProtocolFineoffset.h
|
||||
ProtocolFineoffset.cpp
|
||||
ProtocolFuhaote.h
|
||||
ProtocolFuhaote.cpp
|
||||
ProtocolGroup.h
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "ProtocolBrateck.h"
|
||||
#include "ProtocolComen.h"
|
||||
#include "ProtocolEverflourish.h"
|
||||
#include "ProtocolFineoffset.h"
|
||||
#include "ProtocolFuhaote.h"
|
||||
#include "ProtocolGroup.h"
|
||||
#include "ProtocolHasta.h"
|
||||
|
@ -231,6 +232,12 @@ std::list<std::string> Protocol::decodeData(const std::string &fullData) {
|
|||
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") ) {
|
||||
decoded = ProtocolX10::decodeData(dataMsg);
|
||||
if (decoded != "") {
|
||||
|
|
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