mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Command returns as enum
This commit is contained in:
10
src/mqtt.cpp
10
src/mqtt.cpp
@@ -348,10 +348,10 @@ void Mqtt::on_message(const char * fulltopic, const char * payload, size_t len)
|
||||
// LOG_INFO(F("devicetype= %d, topic = %s, cmd = %s, message = %s), mf.device_type_, topic, cmd_only, message);
|
||||
// call command, assume admin authentication is allowed
|
||||
uint8_t cmd_return = Command::call(mf.device_type_, cmd_only, message, true);
|
||||
if (cmd_return == 2) {
|
||||
if (cmd_return == CommandRet::NOT_FOUND) {
|
||||
LOG_ERROR(F("No matching cmd (%s) in topic %s"), cmd_only, topic);
|
||||
Mqtt::publish(F_(response), "unknown");
|
||||
} else if (cmd_return == 3) {
|
||||
} else if (cmd_return == CommandRet::ERROR) {
|
||||
LOG_ERROR(F("Invalid data with cmd (%s) in topic %s"), cmd_only, topic);
|
||||
Mqtt::publish(F_(response), "unknown");
|
||||
}
|
||||
@@ -381,7 +381,7 @@ void Mqtt::on_message(const char * fulltopic, const char * payload, size_t len)
|
||||
n = doc["id"];
|
||||
}
|
||||
|
||||
uint8_t cmd_return = 1; // OK
|
||||
uint8_t cmd_return = CommandRet::OK;
|
||||
JsonVariant data = doc["data"];
|
||||
|
||||
if (data.is<const char *>()) {
|
||||
@@ -402,10 +402,10 @@ void Mqtt::on_message(const char * fulltopic, const char * payload, size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd_return == 2) {
|
||||
if (cmd_return == CommandRet::NOT_FOUND) {
|
||||
LOG_ERROR(F("No matching cmd (%s)"), command);
|
||||
Mqtt::publish(F_(response), "unknown");
|
||||
} else if (cmd_return == 3) {
|
||||
} else if (cmd_return == CommandRet::ERROR) {
|
||||
LOG_ERROR(F("Invalid data for cmd (%s)"), command);
|
||||
Mqtt::publish(F_(response), "unknown");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user