blob: bdd9dfae88b8dee1af2acf19a664b4d0df3b4dc7 [file] [log] [blame]
Naveen Mosesa6d4e652022-04-13 19:27:25 +05301
2#pragma once
3#include "config.h"
4
5#include "button_factory.hpp"
6#include "button_interface.hpp"
7#include "common.hpp"
8#include "gpio.hpp"
9#include "xyz/openbmc_project/Chassis/Buttons/Button/server.hpp"
10#include "xyz/openbmc_project/Chassis/Common/error.hpp"
11
12#include <unistd.h>
13
14#include <phosphor-logging/elog-errors.hpp>
15#include <phosphor-logging/lg2.hpp>
16
17static constexpr std::string_view DEBUG_SELECTOR_BUTTON =
18 "DEBUG_SELECTOR_BUTTON";
19
20class DebugHostSelector final :
21 public sdbusplus::server::object_t<
22 sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Button>,
23 public ButtonIface
24
25{
26 public:
27 DebugHostSelector(sdbusplus::bus::bus& bus, const char* path,
28 EventPtr& event, buttonConfig& buttonCfg) :
29 sdbusplus::server::object_t<
30 sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Button>(
31 bus, path, action::defer_emit),
32 ButtonIface(bus, event, buttonCfg)
33 {
34 init();
35 emit_object_added();
36 }
37
38 ~DebugHostSelector()
39 {
40 deInit();
41 }
42
43 void simPress() override;
44 void simRelease() override;
45 void simLongPress() override;
46 void handleEvent(sd_event_source* es, int fd, uint32_t revents) override;
47
48 static constexpr std::string_view getFormFactorName()
49 {
50 return DEBUG_SELECTOR_BUTTON;
51 }
52
53 static const char* getDbusObjectPath()
54 {
55 return DBG_HS_DBUS_OBJECT_NAME;
56 }
57};