meister anker added read tmeperature
This commit is contained in:
parent
29627726ba
commit
7d549fae01
@ -197,6 +197,7 @@ void DevicePluginIntertechno::executeAction(Device *device, const Action &action
|
|||||||
|
|
||||||
QString familyCode = device->params().value("familyCode").toString();
|
QString familyCode = device->params().value("familyCode").toString();
|
||||||
|
|
||||||
|
// =======================================
|
||||||
// generate bin from family code
|
// generate bin from family code
|
||||||
if(familyCode == "A"){
|
if(familyCode == "A"){
|
||||||
binCode.append("00000000");
|
binCode.append("00000000");
|
||||||
@ -236,6 +237,7 @@ void DevicePluginIntertechno::executeAction(Device *device, const Action &action
|
|||||||
|
|
||||||
QString buttonCode = device->params().value("buttonCode").toString();
|
QString buttonCode = device->params().value("buttonCode").toString();
|
||||||
|
|
||||||
|
// =======================================
|
||||||
// generate bin from button code
|
// generate bin from button code
|
||||||
if(familyCode == "1"){
|
if(familyCode == "1"){
|
||||||
binCode.append("00000000");
|
binCode.append("00000000");
|
||||||
@ -273,9 +275,11 @@ void DevicePluginIntertechno::executeAction(Device *device, const Action &action
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add fix bin nibble (0F)
|
// =======================================
|
||||||
|
// add fix nibble (0F)
|
||||||
binCode.append("0001");
|
binCode.append("0001");
|
||||||
|
|
||||||
|
// =======================================
|
||||||
// add power nibble
|
// add power nibble
|
||||||
if(action.params().value("power").toBool()){
|
if(action.params().value("power").toBool()){
|
||||||
binCode.append("0101");
|
binCode.append("0101");
|
||||||
|
|||||||
@ -23,6 +23,8 @@ QList<DeviceClass> DevicePluginMeisterAnker::supportedDevices() const
|
|||||||
|
|
||||||
QVariantList thermometerParams;
|
QVariantList thermometerParams;
|
||||||
QVariantMap idParam;
|
QVariantMap idParam;
|
||||||
|
|
||||||
|
// =======================================
|
||||||
// id -> first 8 bits of codeword
|
// id -> first 8 bits of codeword
|
||||||
idParam.insert("name", "id");
|
idParam.insert("name", "id");
|
||||||
idParam.insert("type", "string");
|
idParam.insert("type", "string");
|
||||||
@ -107,21 +109,18 @@ void DevicePluginMeisterAnker::receiveData(QList<int> rawData)
|
|||||||
if(rawData.length() != 49){
|
if(rawData.length() != 49){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Device*> deviceList = deviceManager()->findConfiguredDevices(thermometer);
|
|
||||||
if(deviceList.isEmpty()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int delay = rawData.first()/31;
|
|
||||||
QByteArray binCode;
|
QByteArray binCode;
|
||||||
|
int delay = rawData.first()/31;
|
||||||
if(delay > 250 && delay < 260){
|
|
||||||
|
|
||||||
// __
|
// parse rawdate to binary code
|
||||||
// | |________ = 0 1100000000
|
if(delay > 240 && delay < 260){
|
||||||
// __
|
|
||||||
// | |________________ = 1 110000000000000000
|
/* __
|
||||||
|
* | |________ = 0 1100000000
|
||||||
|
* __
|
||||||
|
* | |________________ = 1 110000000000000000
|
||||||
|
*/
|
||||||
|
|
||||||
for(int i = 1; i <= 48; i+=2 ){
|
for(int i = 1; i <= 48; i+=2 ){
|
||||||
if(rawData.at(i) < 1000 && rawData.at(i+1) < 3000 && rawData.at(i+1) > 1000){
|
if(rawData.at(i) < 1000 && rawData.at(i+1) < 3000 && rawData.at(i+1) > 1000){
|
||||||
@ -136,24 +135,49 @@ void DevicePluginMeisterAnker::receiveData(QList<int> rawData)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// decode the signal
|
//qDebug() << "bin code" << binCode;
|
||||||
QList<QByteArray> byteList;
|
|
||||||
for(int i = 4; i <= 24; i+=4){
|
|
||||||
byteList.append(binCode.left(4));
|
|
||||||
binCode = binCode.right(binCode.length() -4);
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray temperatureBin(byteList.at(2) + byteList.at(3));
|
// =======================================
|
||||||
QByteArray batteryBin(byteList.at(4));
|
// { ID },{ temp },{Batt},{,temp}
|
||||||
QByteArray temperatureTenthBin(byteList.at(5));
|
// "XXXX","XXXX","XXXX","XXXX","XXXX","XXXX",
|
||||||
|
|
||||||
QByteArray idCode = binCode.left(8);
|
QString idCode = QString(binCode.left(8));
|
||||||
|
QByteArray temperatureBin = binCode.mid(8,8);
|
||||||
|
QByteArray batteryBin = binCode.mid(16,4);
|
||||||
|
QByteArray temperatureTenthBin = binCode.right(4);
|
||||||
|
|
||||||
|
qDebug() << "id:" << idCode;
|
||||||
|
qDebug() << "battery" << batteryBin;
|
||||||
|
|
||||||
// check if we have a sync signal (id = 11111111)
|
// check if we have a sync signal (id = 11111111)
|
||||||
if(idCode.contains("11111111")){
|
if(idCode == "11111111"){
|
||||||
qDebug() << "temperatursensor sync signal";
|
qDebug() << "temperatursensor sync signal";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check sign of temperature -> if first bit of temperature byte is 1 -> temp is negativ
|
||||||
|
int sign = 0;
|
||||||
|
if(temperatureBin.left(1).toInt() == 1){
|
||||||
|
sign = -1;
|
||||||
|
}else{
|
||||||
|
sign = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// calc temperature
|
||||||
|
float temperature = sign*(temperatureBin.right(7).toInt(0,2) + (float)temperatureTenthBin.toInt(0,2)/10);
|
||||||
|
|
||||||
|
// check if the battery is low
|
||||||
|
bool batteryStatus;
|
||||||
|
if(batteryBin.toInt(0,2) == 0){
|
||||||
|
batteryStatus = true;
|
||||||
|
}else{
|
||||||
|
batteryStatus = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: check if it is the same temperature than the last time
|
||||||
|
// QString timeStamp = QDateTime::currentDateTime().toString("dd.MM.yyyy, hh:mm:ss");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user