blob: ea5dd5f6f7462867b5e1728e554577716eefd420 [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:
Patrick Williamse3b4e112022-11-26 09:41:58 -060027 DebugHostSelector(sdbusplus::bus_t& bus, const char* path, EventPtr& event,
Delphine CC Chiuccd7db02023-02-09 14:48:53 +080028 ButtonConfig& buttonCfg) :
Naveen Mosesa6d4e652022-04-13 19:27:25 +053029 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};