blob: 53e3a71e65c371b1006191285c4ea11f423c0a9e [file] [log] [blame]
Patrick Venture91ac8d32018-11-01 17:03:22 -07001#include "config.h"
2
3#include "group.hpp"
George Liudef5f5a2020-04-10 11:23:52 +08004#ifdef LED_USE_JSON
5#include "json-config.hpp"
6#else
Patrick Venture91ac8d32018-11-01 17:03:22 -07007#include "led-gen.hpp"
George Liudef5f5a2020-04-10 11:23:52 +08008#endif
Vishwanatha Subbannaed490732016-12-20 15:59:29 +05309#include "ledlayout.hpp"
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053010#include "manager.hpp"
Patrick Venture91ac8d32018-11-01 17:03:22 -070011
12#include <iostream>
Vishwanatha Subbannab21fda72016-10-17 17:46:37 +053013
14int main(void)
15{
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053016 /** @brief Dbus constructs used by LED Group manager */
17 sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
18
George Liudef5f5a2020-04-10 11:23:52 +080019#ifdef LED_USE_JSON
20 auto systemLedMap = loadJsonConfig(LED_JSON_FILE);
21#endif
22
Vishwanatha Subbanna11ca8f92017-02-27 19:33:45 +053023 /** @brief Group manager object */
24 phosphor::led::Manager manager(bus, systemLedMap);
25
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053026 /** @brief sd_bus object manager */
27 sdbusplus::server::manager::manager objManager(bus, OBJPATH);
28
29 /** @brief vector of led groups */
30 std::vector<std::unique_ptr<phosphor::led::Group>> groups;
31
32 /** Now create so many dbus objects as there are groups */
Patrick Venture91ac8d32018-11-01 17:03:22 -070033 for (auto& grp : systemLedMap)
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053034 {
Patrick Venture91ac8d32018-11-01 17:03:22 -070035 groups.emplace_back(
36 std::make_unique<phosphor::led::Group>(bus, grp.first, manager));
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053037 }
38
39 /** @brief Claim the bus */
40 bus.request_name(BUSNAME);
41
42 /** @brief Wait for client requests */
Patrick Venture91ac8d32018-11-01 17:03:22 -070043 while (true)
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053044 {
45 /** @brief process dbus calls / signals discarding unhandled */
46 bus.process_discard();
47 bus.wait();
48 }
Vishwanatha Subbannab21fda72016-10-17 17:46:37 +053049 return 0;
50}