Update to libnymea-gpio changes

This commit is contained in:
Michael Zanetti 2021-11-21 22:29:41 +01:00
parent 74290ca1a3
commit af0c5532a4
2 changed files with 7 additions and 7 deletions

2
debian/control vendored
View File

@ -6,7 +6,7 @@ Build-depends: libboblight-dev,
debhelper (>= 0.0.0), debhelper (>= 0.0.0),
libnymea-dev (>= 0.26~), libnymea-dev (>= 0.26~),
libnymea-mqtt-dev, libnymea-mqtt-dev,
libnymea-gpio-dev (>= 1.0.4~), libnymea-gpio-dev (>= 1.0.5~),
libnymea-zigbee-dev, libnymea-zigbee-dev,
libqt5serialport5-dev, libqt5serialport5-dev,
libqt5websockets5-dev, libqt5websockets5-dev,

View File

@ -237,15 +237,15 @@ void IntegrationPluginGpio::setupThing(ThingSetupInfo *info)
// Gpio input // Gpio input
if (thing->thingClassId() == gpioInputRpiThingClassId || thing->thingClassId() == gpioInputBbbThingClassId) { if (thing->thingClassId() == gpioInputRpiThingClassId || thing->thingClassId() == gpioInputBbbThingClassId) {
GpioMonitor *monitor = new GpioMonitor(thing->paramValue(m_gpioParamTypeIds.value(thing->thingClassId())).toInt(), this); GpioMonitor *monitor = new GpioMonitor(thing->paramValue(m_gpioParamTypeIds.value(thing->thingClassId())).toInt(), this);
monitor->setActiveLow(thing->paramValue(m_activeLowParamTypeIds.value(thing->thingClassId())).toBool()); bool activeLow = thing->paramValue(m_activeLowParamTypeIds.value(thing->thingClassId())).toBool();
if (!monitor->enable()) { if (!monitor->enable(activeLow)) {
qCWarning(dcGpioController()) << "Could not enable gpio monitor for thing" << thing->name(); qCWarning(dcGpioController()) << "Could not enable gpio monitor for thing" << thing->name();
//: Error setting up GPIO thing //: Error setting up GPIO thing
monitor->deleteLater(); monitor->deleteLater();
return info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Enabling GPIO monitor failed.")); return info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Enabling GPIO monitor failed."));
} }
connect(monitor, &GpioMonitor::interruptOccurred, thing, [thing](bool value){ connect(monitor, &GpioMonitor::valueChanged, thing, [thing](bool value){
if (thing->thingClassId() == gpioInputRpiThingClassId) { if (thing->thingClassId() == gpioInputRpiThingClassId) {
thing->setStateValue(gpioInputRpiPowerStateTypeId, value); thing->setStateValue(gpioInputRpiPowerStateTypeId, value);
} else if (thing->thingClassId() == gpioInputBbbThingClassId) { } else if (thing->thingClassId() == gpioInputBbbThingClassId) {
@ -267,15 +267,15 @@ void IntegrationPluginGpio::setupThing(ThingSetupInfo *info)
// Counter // Counter
if (thing->thingClassId() == counterRpiThingClassId || thing->thingClassId() == counterBbbThingClassId) { if (thing->thingClassId() == counterRpiThingClassId || thing->thingClassId() == counterBbbThingClassId) {
GpioMonitor *monitor = new GpioMonitor(thing->paramValue(m_gpioParamTypeIds.value(thing->thingClassId())).toInt(), this); GpioMonitor *monitor = new GpioMonitor(thing->paramValue(m_gpioParamTypeIds.value(thing->thingClassId())).toInt(), this);
monitor->setActiveLow(thing->paramValue(m_activeLowParamTypeIds.value(thing->thingClassId())).toBool()); bool activeLow = thing->paramValue(m_activeLowParamTypeIds.value(thing->thingClassId())).toBool();
if (!monitor->enable()) { if (!monitor->enable(activeLow)) {
qCWarning(dcGpioController()) << "Could not enable gpio monitor for thing" << thing->name(); qCWarning(dcGpioController()) << "Could not enable gpio monitor for thing" << thing->name();
monitor->deleteLater(); monitor->deleteLater();
//: Error setting up GPIO thing //: Error setting up GPIO thing
return info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Enabling GPIO monitor failed.")); return info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Enabling GPIO monitor failed."));
} }
connect(monitor, &GpioMonitor::interruptOccurred, thing, [this, thing](bool value){ connect(monitor, &GpioMonitor::valueChanged, thing, [this, thing](bool value){
if (thing->thingClassId() == counterRpiThingClassId || thing->thingClassId() == counterBbbThingClassId) { if (thing->thingClassId() == counterRpiThingClassId || thing->thingClassId() == counterBbbThingClassId) {
if (value) { if (value) {
m_counterValues[thing->id()] += 1; m_counterValues[thing->id()] += 1;