minor refactoring of network code

This commit is contained in:
technyon
2023-02-18 19:14:38 +01:00
parent 9e92ea8cb3
commit d0fbaefd77
7 changed files with 18 additions and 13 deletions

View File

@@ -90,16 +90,14 @@ void NetworkLock::onMqttDataReceived(const char* topic, byte* payload, const uns
{
char* value = (char*)payload;
bool processActions = _network->mqttConnectionState() >= 2;
if(processActions && comparePrefixedPath(topic, mqtt_topic_reset) && strcmp(value, "1") == 0)
if(comparePrefixedPath(topic, mqtt_topic_reset) && strcmp(value, "1") == 0)
{
Log->println(F("Restart requested via MQTT."));
delay(200);
restartEsp(RestartReason::RequestedViaMqtt);
}
if(processActions && comparePrefixedPath(topic, mqtt_topic_lock_action))
if(comparePrefixedPath(topic, mqtt_topic_lock_action))
{
if(strcmp(value, "") == 0 || strcmp(value, "--") == 0 || strcmp(value, "ack") == 0 || strcmp(value, "unknown_action") == 0) return;
@@ -113,7 +111,7 @@ void NetworkLock::onMqttDataReceived(const char* topic, byte* payload, const uns
publishString(mqtt_topic_lock_action, success ? "ack" : "unknown_action");
}
if(processActions && comparePrefixedPath(topic, mqtt_topic_keypad_command_action))
if(comparePrefixedPath(topic, mqtt_topic_keypad_command_action))
{
if(_keypadCommandReceivedReceivedCallback != nullptr)
{