实现MQTT功能, 修改HTTP接口

This commit is contained in:
lixiaoyuan
2025-09-04 19:31:04 +08:00
parent 61ed4f355f
commit d81bcd9983
30 changed files with 2029 additions and 697 deletions

View File

@@ -32,7 +32,7 @@ bool Config::init(std::string filename)
}
else
{
spdlog::info("[config] parse database failed: not found. host={}", option.database.host);
spdlog::info("[config] parse database failed: not found.");
}
if (jsonroot.contains("http"))
@@ -43,6 +43,21 @@ bool Config::init(std::string filename)
option.http.useToken = !token.empty();
NJson::read(json, "port", option.http.port);
}
else
{
spdlog::info("[config] parse http failed: not found.");
}
if (jsonroot.contains("mqtt"))
{
NJsonNode json = jsonroot.at("mqtt");
NJson::read(json, "host", option.mqtt.host);
NJson::read(json, "username", option.mqtt.username);
NJson::read(json, "password", option.mqtt.password);
}
else
{
spdlog::info("[config] parse mqtt failed: not found.");
}
return true;
}