1
This commit is contained in:
parent
c382b0a3f4
commit
d1de25f32c
@ -117,7 +117,25 @@ struct AppConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto& m = j["mqtt_server"];
|
auto& m = j["mqtt_server"];
|
||||||
cfg.mqtt.vehicle_id = std::to_string(m.value("veh_id", 0));
|
if (m.contains("veh_id"))
|
||||||
|
{
|
||||||
|
if (m["veh_id"].is_string())
|
||||||
|
{
|
||||||
|
cfg.mqtt.vehicle_id = m["veh_id"].get<std::string>();
|
||||||
|
}
|
||||||
|
else if (m["veh_id"].is_number_integer())
|
||||||
|
{
|
||||||
|
cfg.mqtt.vehicle_id = std::to_string(m["veh_id"].get<int>());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw std::runtime_error("mqtt_server.veh_id must be string or integer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw std::runtime_error("mqtt_server.veh_id missing");
|
||||||
|
}
|
||||||
cfg.mqtt.server_ip = m.value("address", "");
|
cfg.mqtt.server_ip = m.value("address", "");
|
||||||
cfg.mqtt.server_port = m.value("port", 1883);
|
cfg.mqtt.server_port = m.value("port", 1883);
|
||||||
cfg.mqtt.need_username_pwd = m.value("need_username_pwd", true);
|
cfg.mqtt.need_username_pwd = m.value("need_username_pwd", true);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user