Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
| 3 | #include "group.hpp" |
George Liu | def5f5a | 2020-04-10 11:23:52 +0800 | [diff] [blame] | 4 | #ifdef LED_USE_JSON |
| 5 | #include "json-config.hpp" |
| 6 | #else |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 7 | #include "led-gen.hpp" |
George Liu | def5f5a | 2020-04-10 11:23:52 +0800 | [diff] [blame] | 8 | #endif |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 9 | #include "ledlayout.hpp" |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 10 | #include "manager.hpp" |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 11 | |
| 12 | #include <iostream> |
Vishwanatha Subbanna | b21fda7 | 2016-10-17 17:46:37 +0530 | [diff] [blame] | 13 | |
| 14 | int main(void) |
| 15 | { |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 16 | /** @brief Dbus constructs used by LED Group manager */ |
| 17 | sdbusplus::bus::bus bus = sdbusplus::bus::new_default(); |
| 18 | |
George Liu | def5f5a | 2020-04-10 11:23:52 +0800 | [diff] [blame] | 19 | #ifdef LED_USE_JSON |
| 20 | auto systemLedMap = loadJsonConfig(LED_JSON_FILE); |
| 21 | #endif |
| 22 | |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 23 | /** @brief Group manager object */ |
| 24 | phosphor::led::Manager manager(bus, systemLedMap); |
| 25 | |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 26 | /** @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 Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 33 | for (auto& grp : systemLedMap) |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 34 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 35 | groups.emplace_back( |
| 36 | std::make_unique<phosphor::led::Group>(bus, grp.first, manager)); |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | /** @brief Claim the bus */ |
| 40 | bus.request_name(BUSNAME); |
| 41 | |
| 42 | /** @brief Wait for client requests */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 43 | while (true) |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 44 | { |
| 45 | /** @brief process dbus calls / signals discarding unhandled */ |
| 46 | bus.process_discard(); |
| 47 | bus.wait(); |
| 48 | } |
Vishwanatha Subbanna | b21fda7 | 2016-10-17 17:46:37 +0530 | [diff] [blame] | 49 | return 0; |
| 50 | } |