1 #pragma once 2 3 #include <boost/asio/io_context.hpp> 4 #include <boost/container/flat_map.hpp> 5 #include <nlohmann/json.hpp> 6 #include <sdbusplus/asio/connection.hpp> 7 8 // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) 9 extern boost::asio::io_context io; 10 11 using DBusValueVariant = 12 std::variant<std::string, int64_t, uint64_t, double, int32_t, uint32_t, 13 int16_t, uint16_t, uint8_t, bool, std::vector<uint8_t>>; 14 using DBusInterface = boost::container::flat_map<std::string, DBusValueVariant>; 15 using DBusObject = boost::container::flat_map<std::string, DBusInterface>; 16 17 constexpr const char* configurationOutDir = "/var/configuration/"; 18 constexpr const char* versionHashFile = "/var/configuration/version"; 19 constexpr const char* versionFile = "/etc/os-release"; 20 21 namespace em_utils 22 { 23 24 namespace properties 25 { 26 constexpr const char* interface = "org.freedesktop.DBus.Properties"; 27 constexpr const char* get = "Get"; 28 } // namespace properties 29 30 namespace power 31 { 32 const static constexpr char* busname = "xyz.openbmc_project.State.Host"; 33 const static constexpr char* interface = "xyz.openbmc_project.State.Host"; 34 const static constexpr char* path = "/xyz/openbmc_project/state/host0"; 35 const static constexpr char* property = "CurrentHostState"; 36 } // namespace power 37 38 bool isPowerOn(); 39 void setupPowerMatch(const std::shared_ptr<sdbusplus::asio::connection>& conn); 40 bool fwVersionIsSame(); 41 42 std::optional<std::string> templateCharReplace( 43 nlohmann::json::iterator& keyPair, const DBusObject& object, size_t index, 44 const std::optional<std::string>& replaceStr = std::nullopt); 45 46 std::optional<std::string> templateCharReplace( 47 nlohmann::json::iterator& keyPair, const DBusInterface& interface, 48 size_t index, const std::optional<std::string>& replaceStr = std::nullopt); 49 50 } // namespace em_utils 51