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
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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue