blob: 4590e310fb2d7d474f8dc2e54599ca0738c10388 [file] [log] [blame]
William A. Kennington III52575252018-02-09 15:54:56 -08001#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 */
9class 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 enabled;
18 uint64_t interval;
19 uint64_t timeRemaining;
20 };
21
22 /** @brief Retrieves a copy of the currently set properties on the
23 * host watchdog
24 *
25 * @return A populated WatchdogProperties struct
26 */
27 Properties getProperties();
28
29 /** @brief Sets the value of the enabled property on the host watchdog
30 *
31 * @param[in] enabled - The new enabled value
32 */
33 void setEnabled(bool enabled);
34
35 /** @brief Sets the value of the interval property on the host watchdog
36 *
37 * @param[in] interval - The new interval value
38 */
39 void setInterval(uint64_t interval);
40
41 /** @brief Sets the value of the timeRemaining property on the host
42 * watchdog
43 *
44 * @param[in] timeRemaining - The new timeRemaining value
45 */
46 void setTimeRemaining(uint64_t timeRemaining);
47
48 private:
49 /** @brief sdbusplus handle */
50 sdbusplus::bus::bus bus;
51 /** @brief The name of the mapped host watchdog service */
52 const std::string wd_service;
53
54 /** @brief Sets the value of the property on the host watchdog
55 *
56 * @param[in] key - The name of the property
57 * @param[in] val - The new value
58 */
59 template <typename T>
60 void setProperty(const std::string& key, const T& val);
61};