Merge PR #557: OneWire: Make owfs more robust against occational read errors
This commit is contained in:
commit
20c51eea0c
@ -185,8 +185,12 @@ void IntegrationPluginOneWire::setupThing(ThingSetupInfo *info)
|
|||||||
qCDebug(dcOneWire) << "Setup one wire switch" << thing->params();
|
qCDebug(dcOneWire) << "Setup one wire switch" << thing->params();
|
||||||
if (m_owfsInterface) {
|
if (m_owfsInterface) {
|
||||||
QByteArray address = thing->paramValue(singleChannelSwitchThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(singleChannelSwitchThingAddressParamTypeId).toByteArray();
|
||||||
thing->setStateValue(singleChannelSwitchDigitalOutputStateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A));
|
|
||||||
thing->setStateValue(singleChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
thing->setStateValue(singleChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
|
bool ok;
|
||||||
|
bool output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(singleChannelSwitchDigitalOutputStateTypeId, output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return info->finish(Thing::ThingErrorNoError);
|
return info->finish(Thing::ThingErrorNoError);
|
||||||
|
|
||||||
@ -194,9 +198,16 @@ void IntegrationPluginOneWire::setupThing(ThingSetupInfo *info)
|
|||||||
qCDebug(dcOneWire) << "Setup one wire dual switch" << thing->params();
|
qCDebug(dcOneWire) << "Setup one wire dual switch" << thing->params();
|
||||||
if (m_owfsInterface) {
|
if (m_owfsInterface) {
|
||||||
QByteArray address = thing->paramValue(dualChannelSwitchThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(dualChannelSwitchThingAddressParamTypeId).toByteArray();
|
||||||
thing->setStateValue(dualChannelSwitchDigitalOutput1StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A));
|
|
||||||
thing->setStateValue(dualChannelSwitchDigitalOutput2StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_B));
|
|
||||||
thing->setStateValue(dualChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
thing->setStateValue(dualChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
|
bool ok;
|
||||||
|
bool output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(dualChannelSwitchDigitalOutput1StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_B, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(dualChannelSwitchDigitalOutput2StateTypeId, output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return info->finish(Thing::ThingErrorNoError);
|
return info->finish(Thing::ThingErrorNoError);
|
||||||
|
|
||||||
@ -204,15 +215,40 @@ void IntegrationPluginOneWire::setupThing(ThingSetupInfo *info)
|
|||||||
qCDebug(dcOneWire) << "Setup one wire eight channel switch" << thing->params();
|
qCDebug(dcOneWire) << "Setup one wire eight channel switch" << thing->params();
|
||||||
if (m_owfsInterface) {
|
if (m_owfsInterface) {
|
||||||
QByteArray address = thing->paramValue(eightChannelSwitchThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(eightChannelSwitchThingAddressParamTypeId).toByteArray();
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput1StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A));
|
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput2StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_B));
|
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput3StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_C));
|
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput4StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_D));
|
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput5StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_E));
|
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput6StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_F));
|
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput7StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_G));
|
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput8StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_H));
|
|
||||||
thing->setStateValue(eightChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
thing->setStateValue(eightChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
|
bool ok;
|
||||||
|
bool output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput1StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_B, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput2StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_C, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput3StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_D, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput4StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_E, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput5StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_F, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput6StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_G, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput7StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_H, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput8StateTypeId, output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return info->finish(Thing::ThingErrorNoError);
|
return info->finish(Thing::ThingErrorNoError);
|
||||||
} else {
|
} else {
|
||||||
@ -323,7 +359,11 @@ void IntegrationPluginOneWire::setupOwfsTemperatureSensor(ThingSetupInfo *info)
|
|||||||
QByteArray address = thing->paramValue(temperatureSensorThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(temperatureSensorThingAddressParamTypeId).toByteArray();
|
||||||
if (m_owfsInterface) {
|
if (m_owfsInterface) {
|
||||||
thing->setStateValue(temperatureSensorConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
thing->setStateValue(temperatureSensorConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
thing->setStateValue(temperatureSensorTemperatureStateTypeId, m_owfsInterface->getTemperature(address));
|
bool ok;
|
||||||
|
double temp = m_owfsInterface->getTemperature(address, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(temperatureSensorTemperatureStateTypeId, temp);
|
||||||
|
}
|
||||||
return info->finish(Thing::ThingErrorNoError);
|
return info->finish(Thing::ThingErrorNoError);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcOneWire()) << "OWFS interface is not available";
|
qCWarning(dcOneWire()) << "OWFS interface is not available";
|
||||||
@ -337,8 +377,15 @@ void IntegrationPluginOneWire::setupOwfsTemperatureHumiditySensor(ThingSetupInfo
|
|||||||
QByteArray address = thing->paramValue(temperatureHumiditySensorThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(temperatureHumiditySensorThingAddressParamTypeId).toByteArray();
|
||||||
if (m_owfsInterface) {
|
if (m_owfsInterface) {
|
||||||
thing->setStateValue(temperatureHumiditySensorConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
thing->setStateValue(temperatureHumiditySensorConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
thing->setStateValue(temperatureHumiditySensorTemperatureStateTypeId, m_owfsInterface->getTemperature(address));
|
bool ok;
|
||||||
thing->setStateValue(temperatureHumiditySensorHumidityStateTypeId, m_owfsInterface->getHumidity(address));
|
double temp = m_owfsInterface->getTemperature(address, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(temperatureHumiditySensorTemperatureStateTypeId, temp);
|
||||||
|
}
|
||||||
|
double humidity = m_owfsInterface->getHumidity(address, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(temperatureHumiditySensorHumidityStateTypeId, humidity);
|
||||||
|
}
|
||||||
return info->finish(Thing::ThingErrorNoError);
|
return info->finish(Thing::ThingErrorNoError);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcOneWire()) << "OWFS interface is not available";
|
qCWarning(dcOneWire()) << "OWFS interface is not available";
|
||||||
@ -354,13 +401,15 @@ void IntegrationPluginOneWire::onPluginTimer()
|
|||||||
|
|
||||||
} else if (thing->thingClassId() == temperatureSensorThingClassId) {
|
} else if (thing->thingClassId() == temperatureSensorThingClassId) {
|
||||||
QByteArray address = thing->paramValue(temperatureSensorThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(temperatureSensorThingAddressParamTypeId).toByteArray();
|
||||||
|
bool ok = true;
|
||||||
double temperature = 0;
|
double temperature = 0;
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
|
|
||||||
if (!thing->parentId().isNull()) {
|
if (!thing->parentId().isNull()) {
|
||||||
if (m_owfsInterface) {
|
if (m_owfsInterface) {
|
||||||
temperature = m_owfsInterface->getTemperature(address);
|
|
||||||
connected = m_owfsInterface->isConnected(address);
|
connected = m_owfsInterface->isConnected(address);
|
||||||
|
bool ok;
|
||||||
|
temperature = m_owfsInterface->getTemperature(address, &ok);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcOneWire()) << "onPlugInTimer: OWFS interface not setup for thing" << thing->name();
|
qCWarning(dcOneWire()) << "onPlugInTimer: OWFS interface not setup for thing" << thing->name();
|
||||||
}
|
}
|
||||||
@ -370,40 +419,85 @@ void IntegrationPluginOneWire::onPluginTimer()
|
|||||||
connected = m_w1Interface->deviceAvailable(address);
|
connected = m_w1Interface->deviceAvailable(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
thing->setStateValue(temperatureSensorTemperatureStateTypeId, temperature);
|
thing->setStateValue(temperatureSensorTemperatureStateTypeId, temperature);
|
||||||
|
}
|
||||||
thing->setStateValue(temperatureSensorConnectedStateTypeId, connected);
|
thing->setStateValue(temperatureSensorConnectedStateTypeId, connected);
|
||||||
} else if (thing->thingClassId() == temperatureHumiditySensorThingClassId) {
|
} else if (thing->thingClassId() == temperatureHumiditySensorThingClassId) {
|
||||||
if (!m_owfsInterface)
|
if (!m_owfsInterface)
|
||||||
continue;
|
continue;
|
||||||
QByteArray address = thing->paramValue(temperatureHumiditySensorThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(temperatureHumiditySensorThingAddressParamTypeId).toByteArray();
|
||||||
thing->setStateValue(temperatureHumiditySensorTemperatureStateTypeId, m_owfsInterface->getTemperature(address));
|
bool ok;
|
||||||
thing->setStateValue(temperatureHumiditySensorHumidityStateTypeId, m_owfsInterface->getHumidity(address));
|
double temp = m_owfsInterface->getTemperature(address, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(temperatureHumiditySensorTemperatureStateTypeId, temp);
|
||||||
|
}
|
||||||
|
double humidity = m_owfsInterface->getHumidity(address, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(temperatureHumiditySensorHumidityStateTypeId, humidity);
|
||||||
|
}
|
||||||
thing->setStateValue(temperatureHumiditySensorConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
thing->setStateValue(temperatureHumiditySensorConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
} else if (thing->thingClassId() == singleChannelSwitchThingClassId) {
|
} else if (thing->thingClassId() == singleChannelSwitchThingClassId) {
|
||||||
if (!m_owfsInterface)
|
if (!m_owfsInterface)
|
||||||
continue;
|
continue;
|
||||||
QByteArray address = thing->paramValue(singleChannelSwitchThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(singleChannelSwitchThingAddressParamTypeId).toByteArray();
|
||||||
thing->setStateValue(singleChannelSwitchDigitalOutputStateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A));
|
bool ok;
|
||||||
|
bool output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(singleChannelSwitchDigitalOutputStateTypeId, output);
|
||||||
|
}
|
||||||
thing->setStateValue(singleChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
thing->setStateValue(singleChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
} else if (thing->thingClassId() == dualChannelSwitchThingClassId) {
|
} else if (thing->thingClassId() == dualChannelSwitchThingClassId) {
|
||||||
if (!m_owfsInterface)
|
if (!m_owfsInterface)
|
||||||
continue;
|
continue;
|
||||||
QByteArray address = thing->paramValue(dualChannelSwitchThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(dualChannelSwitchThingAddressParamTypeId).toByteArray();
|
||||||
thing->setStateValue(dualChannelSwitchDigitalOutput1StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A));
|
bool ok;
|
||||||
thing->setStateValue(dualChannelSwitchDigitalOutput2StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_B));
|
bool output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(dualChannelSwitchDigitalOutput1StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_B, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(dualChannelSwitchDigitalOutput2StateTypeId, output);
|
||||||
|
}
|
||||||
thing->setStateValue(dualChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
thing->setStateValue(dualChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
} else if (thing->thingClassId() == eightChannelSwitchThingClassId) {
|
} else if (thing->thingClassId() == eightChannelSwitchThingClassId) {
|
||||||
if (!m_owfsInterface)
|
if (!m_owfsInterface)
|
||||||
continue;
|
continue;
|
||||||
QByteArray address = thing->paramValue(eightChannelSwitchThingAddressParamTypeId).toByteArray();
|
QByteArray address = thing->paramValue(eightChannelSwitchThingAddressParamTypeId).toByteArray();
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput1StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A));
|
bool ok;
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput2StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_B));
|
bool output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_A, &ok);
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput3StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_C));
|
if (ok) {
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput4StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_D));
|
thing->setStateValue(eightChannelSwitchDigitalOutput1StateTypeId, output);
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput5StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_E));
|
}
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput6StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_F));
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_B, &ok);
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput7StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_G));
|
if (ok) {
|
||||||
thing->setStateValue(eightChannelSwitchDigitalOutput8StateTypeId, m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_H));
|
thing->setStateValue(eightChannelSwitchDigitalOutput2StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_C, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput3StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_D, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput4StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_E, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput5StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_F, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput6StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_G, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput7StateTypeId, output);
|
||||||
|
}
|
||||||
|
output = m_owfsInterface->getSwitchOutput(address, Owfs::SwitchChannel::PIO_H, &ok);
|
||||||
|
if (ok) {
|
||||||
|
thing->setStateValue(eightChannelSwitchDigitalOutput8StateTypeId, output);
|
||||||
|
}
|
||||||
thing->setStateValue(eightChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
thing->setStateValue(eightChannelSwitchConnectedStateTypeId, m_owfsInterface->isConnected(address));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,8 @@
|
|||||||
#include "owfs.h"
|
#include "owfs.h"
|
||||||
#include "w1.h"
|
#include "w1.h"
|
||||||
|
|
||||||
|
#include "extern-plugininfo.h"
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
class IntegrationPluginOneWire : public IntegrationPlugin
|
class IntegrationPluginOneWire : public IntegrationPlugin
|
||||||
|
|||||||
@ -175,18 +175,18 @@ void Owfs::setValue(const QByteArray &address, const QByteArray &type, const QBy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double Owfs::getTemperature(const QByteArray &address)
|
double Owfs::getTemperature(const QByteArray &address, bool *ok)
|
||||||
{
|
{
|
||||||
QByteArray temperature = getValue(address, "temperature");
|
QByteArray temperature = getValue(address, "temperature");
|
||||||
qDebug(dcOneWire()) << "Temperature" << temperature << temperature.replace(',','.').toDouble();
|
qDebug(dcOneWire()) << "Temperature" << temperature << temperature.replace(',','.').toDouble();
|
||||||
return temperature.toDouble();
|
return temperature.toDouble(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Owfs::getHumidity(const QByteArray &address)
|
double Owfs::getHumidity(const QByteArray &address, bool *ok)
|
||||||
{
|
{
|
||||||
QByteArray humidity = getValue(address, "humidity");
|
QByteArray humidity = getValue(address, "humidity");
|
||||||
qDebug(dcOneWire()) << "Humidity" << humidity << humidity.replace(',','.').toDouble();
|
qDebug(dcOneWire()) << "Humidity" << humidity << humidity.replace(',','.').toDouble();
|
||||||
return humidity.toDouble();
|
return humidity.toDouble(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Owfs::getType(const QByteArray &address)
|
QByteArray Owfs::getType(const QByteArray &address)
|
||||||
@ -195,7 +195,7 @@ QByteArray Owfs::getType(const QByteArray &address)
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Owfs::getSwitchOutput(const QByteArray &address, SwitchChannel channel)
|
bool Owfs::getSwitchOutput(const QByteArray &address, SwitchChannel channel, bool *ok)
|
||||||
{
|
{
|
||||||
QByteArray c;
|
QByteArray c;
|
||||||
c.append("PIO.");
|
c.append("PIO.");
|
||||||
@ -227,10 +227,10 @@ bool Owfs::getSwitchOutput(const QByteArray &address, SwitchChannel channel)
|
|||||||
}
|
}
|
||||||
QByteArray state = getValue(address, c);
|
QByteArray state = getValue(address, c);
|
||||||
qDebug(dcOneWire()) << "Switch state" << state.toInt();
|
qDebug(dcOneWire()) << "Switch state" << state.toInt();
|
||||||
return state.toInt();
|
return state.toInt(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Owfs::getSwitchInput(const QByteArray &address, SwitchChannel channel)
|
bool Owfs::getSwitchInput(const QByteArray &address, SwitchChannel channel, bool *ok)
|
||||||
{
|
{
|
||||||
QByteArray c;
|
QByteArray c;
|
||||||
c.append("sensed.");
|
c.append("sensed.");
|
||||||
@ -262,7 +262,7 @@ bool Owfs::getSwitchInput(const QByteArray &address, SwitchChannel channel)
|
|||||||
}
|
}
|
||||||
QByteArray state = getValue(address, c);
|
QByteArray state = getValue(address, c);
|
||||||
qDebug(dcOneWire()) << "Switch state" << state.toInt();
|
qDebug(dcOneWire()) << "Switch state" << state.toInt();
|
||||||
return state.toInt();
|
return state.toInt(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Owfs::setSwitchOutput(const QByteArray &address, SwitchChannel channel, bool state)
|
void Owfs::setSwitchOutput(const QByteArray &address, SwitchChannel channel, bool state)
|
||||||
|
|||||||
@ -75,12 +75,12 @@ public:
|
|||||||
bool interfaceIsAvailable();
|
bool interfaceIsAvailable();
|
||||||
bool isConnected(const QByteArray &address);
|
bool isConnected(const QByteArray &address);
|
||||||
|
|
||||||
double getTemperature(const QByteArray &address);
|
double getTemperature( const QByteArray &address, bool *ok);
|
||||||
double getHumidity(const QByteArray &address);
|
double getHumidity(const QByteArray &address, bool *ok);
|
||||||
QByteArray getType(const QByteArray &address);
|
QByteArray getType(const QByteArray &address);
|
||||||
bool getSwitchOutput(const QByteArray &address, SwitchChannel channel);
|
bool getSwitchOutput(const QByteArray &address, SwitchChannel channel, bool *ok);
|
||||||
void setSwitchOutput(const QByteArray &address, SwitchChannel channel, bool state);
|
void setSwitchOutput(const QByteArray &address, SwitchChannel channel, bool state);
|
||||||
bool getSwitchInput(const QByteArray &address, SwitchChannel channel);
|
bool getSwitchInput(const QByteArray &address, SwitchChannel channel, bool *ok);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QByteArray m_path;
|
QByteArray m_path;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user