1 #pragma once 2 #include <sdbusplus/bus.hpp> 3 #include <xyz/openbmc_project/State/Watchdog/server.hpp> 4 5 /** @class WatchdogService 6 * @brief Access to the running OpenBMC watchdog implementation. 7 * @details Easy accessor for servers that implement the 8 * xyz.openbmc_project.State.Watchdog DBus API. 9 */ 10 class WatchdogService { 11 public: 12 WatchdogService(); 13 14 using Action = sdbusplus::xyz::openbmc_project::State::server::Watchdog::Action; 15 16 /** @brief Contains a copy of the properties enumerated by the 17 * watchdog service. 18 */ 19 struct Properties { 20 bool initialized; 21 bool enabled; 22 Action expireAction; 23 uint64_t interval; 24 uint64_t timeRemaining; 25 }; 26 27 /** @brief Retrieves a copy of the currently set properties on the 28 * host watchdog 29 * 30 * @return A populated WatchdogProperties struct 31 */ 32 Properties getProperties(); 33 34 /** @brief Sets the value of the initialized property on the host 35 * watchdog 36 * 37 * @param[in] initialized - The new initializedvalue 38 */ 39 void setInitialized(bool initialized); 40 41 /** @brief Sets the value of the enabled property on the host watchdog 42 * 43 * @param[in] enabled - The new enabled value 44 */ 45 void setEnabled(bool enabled); 46 47 /** @brief Sets the value of the expireAction property on the host watchdog 48 * 49 * @param[in] expireAction - The new expireAction value 50 */ 51 void setExpireAction(Action expireAction); 52 53 /** @brief Sets the value of the interval property on the host watchdog 54 * 55 * @param[in] interval - The new interval value 56 */ 57 void setInterval(uint64_t interval); 58 59 /** @brief Sets the value of the timeRemaining property on the host 60 * watchdog 61 * 62 * @param[in] timeRemaining - The new timeRemaining value 63 */ 64 void setTimeRemaining(uint64_t timeRemaining); 65 66 private: 67 /** @brief sdbusplus handle */ 68 sdbusplus::bus::bus bus; 69 /** @brief The name of the mapped host watchdog service */ 70 const std::string wd_service; 71 72 /** @brief Sets the value of the property on the host watchdog 73 * 74 * @param[in] key - The name of the property 75 * @param[in] val - The new value 76 */ 77 template <typename T> 78 void setProperty(const std::string& key, const T& val); 79 }; 80