William A. Kennington III | 5257525 | 2018-02-09 15:54:56 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | #include <sdbusplus/bus.hpp> |
William A. Kennington III | b638de2 | 2018-02-09 16:12:53 -0800 | [diff] [blame] | 3 | #include <xyz/openbmc_project/State/Watchdog/server.hpp> |
William A. Kennington III | 5257525 | 2018-02-09 15:54:56 -0800 | [diff] [blame] | 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 | |
William A. Kennington III | b638de2 | 2018-02-09 16:12:53 -0800 | [diff] [blame] | 14 | using Action = sdbusplus::xyz::openbmc_project::State::server::Watchdog::Action; |
| 15 | |
William A. Kennington III | 5257525 | 2018-02-09 15:54:56 -0800 | [diff] [blame] | 16 | /** @brief Contains a copy of the properties enumerated by the |
| 17 | * watchdog service. |
| 18 | */ |
| 19 | struct Properties { |
William A. Kennington III | de14a02 | 2018-02-09 16:11:18 -0800 | [diff] [blame] | 20 | bool initialized; |
William A. Kennington III | 5257525 | 2018-02-09 15:54:56 -0800 | [diff] [blame] | 21 | bool enabled; |
William A. Kennington III | b638de2 | 2018-02-09 16:12:53 -0800 | [diff] [blame] | 22 | Action expireAction; |
William A. Kennington III | 5257525 | 2018-02-09 15:54:56 -0800 | [diff] [blame] | 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 | |
William A. Kennington III | de14a02 | 2018-02-09 16:11:18 -0800 | [diff] [blame] | 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 | |
William A. Kennington III | 5257525 | 2018-02-09 15:54:56 -0800 | [diff] [blame] | 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 | |
William A. Kennington III | b638de2 | 2018-02-09 16:12:53 -0800 | [diff] [blame] | 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 | |
William A. Kennington III | 5257525 | 2018-02-09 15:54:56 -0800 | [diff] [blame] | 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 | }; |