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