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