mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-02-02 23:57:44 +05:00
refactor: added different timeouts for wired and wireless sensors
This commit is contained in:
@@ -135,8 +135,6 @@ protected:
|
|||||||
tMqtt->disable();
|
tMqtt->disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
Sensors::setConnectionStatusByType(Sensors::Type::MANUAL, !settings.mqtt.enabled || vars.mqtt.connected, false);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (this->ntpStarted) {
|
if (this->ntpStarted) {
|
||||||
this->ntpStarted = false;
|
this->ntpStarted = false;
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const unsigned int disconnectedTimeout = 120000;
|
const unsigned int wiredDisconnectTimeout = 180000u;
|
||||||
|
const unsigned int wirelessDisconnectTimeout = 600000u;
|
||||||
const unsigned short dallasSearchInterval = 60000;
|
const unsigned short dallasSearchInterval = 60000;
|
||||||
const unsigned short dallasPollingInterval = 10000;
|
const unsigned short dallasPollingInterval = 10000;
|
||||||
const unsigned short globalPollingInterval = 15000;
|
const unsigned short globalPollingInterval = 15000;
|
||||||
@@ -1004,12 +1005,16 @@ protected:
|
|||||||
} else if (rSensor.connected && sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
|
} else if (rSensor.connected && sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
|
||||||
Sensors::setConnectionStatusById(sensorId, false, false);
|
Sensors::setConnectionStatusById(sensorId, false, false);
|
||||||
|
|
||||||
} else if (sSensor.type != Sensors::Type::MANUAL && rSensor.connected && (millis() - rSensor.activityTime) > this->disconnectedTimeout) {
|
} else if (rSensor.connected) {
|
||||||
Sensors::setConnectionStatusById(sensorId, false, false);
|
if (sSensor.type == Sensors::Type::MANUAL || sSensor.type == Sensors::Type::BLUETOOTH) {
|
||||||
|
if ((millis() - rSensor.activityTime) > this->wirelessDisconnectTimeout) {
|
||||||
|
Sensors::setConnectionStatusById(sensorId, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
}/* else if (!rSensor.connected) {
|
} else if ((millis() - rSensor.activityTime) > this->wiredDisconnectTimeout) {
|
||||||
rSensor.connected = true;
|
Sensors::setConnectionStatusById(sensorId, false, false);
|
||||||
}*/
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
src/utils.h
19
src/utils.h
@@ -2109,21 +2109,18 @@ bool jsonToSensorResult(const uint8_t sensorId, const JsonVariantConst src) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& dst = Sensors::results[sensorId];
|
|
||||||
bool changed = false;
|
|
||||||
|
|
||||||
// value
|
// value
|
||||||
if (!src[FPSTR(S_VALUE)].isNull()) {
|
if (!src[FPSTR(S_VALUE)].isNull()) {
|
||||||
float value = src[FPSTR(S_VALUE)].as<float>();
|
return Sensors::setValueById(
|
||||||
|
sensorId,
|
||||||
uint8_t vType = static_cast<uint8_t>(Sensors::ValueType::PRIMARY);
|
src[FPSTR(S_VALUE)].as<float>(),
|
||||||
if (fabsf(value - dst.values[vType]) > 0.0001f) {
|
Sensors::ValueType::PRIMARY,
|
||||||
dst.values[vType] = roundf(value, 2);
|
true,
|
||||||
changed = true;
|
true
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void varsToJson(const Variables& src, JsonVariant dst) {
|
void varsToJson(const Variables& src, JsonVariant dst) {
|
||||||
|
|||||||
Reference in New Issue
Block a user