blob: 432c7cedb14f9ee3176e7a4d62abfe49c07639e2 [file] [log] [blame]
William A. Kennington III52575252018-02-09 15:54:56 -08001#pragma once
2#include <sdbusplus/bus.hpp>
William A. Kennington IIIb638de22018-02-09 16:12:53 -08003#include <xyz/openbmc_project/State/Watchdog/server.hpp>
William A. Kennington III52575252018-02-09 15:54:56 -08004
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 */
10class WatchdogService {
11 public:
12 WatchdogService();
13
William A. Kennington IIIb638de22018-02-09 16:12:53 -080014 using Action = sdbusplus::xyz::openbmc_project::State::server::Watchdog::Action;
15
William A. Kennington III52575252018-02-09 15:54:56 -080016 /** @brief Contains a copy of the properties enumerated by the
17 * watchdog service.
18 */
19 struct Properties {
William A. Kennington IIIde14a022018-02-09 16:11:18 -080020 bool initialized;
William A. Kennington III52575252018-02-09 15:54:56 -080021 bool enabled;
William A. Kennington IIIb638de22018-02-09 16:12:53 -080022 Action expireAction;
William A. Kennington III52575252018-02-09 15:54:56 -080023 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 IIIde14a022018-02-09 16:11:18 -080034 /** @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 III52575252018-02-09 15:54:56 -080041 /** @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 IIIb638de22018-02-09 16:12:53 -080047 /** @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 III52575252018-02-09 15:54:56 -080053 /** @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};