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" |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame] | 11 | #include "serialize.hpp" |
George Liu | 1c737af | 2020-10-16 09:07:02 +0800 | [diff] [blame] | 12 | #include "utils.hpp" |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 13 | |
| 14 | #include <iostream> |
Vishwanatha Subbanna | b21fda7 | 2016-10-17 17:46:37 +0530 | [diff] [blame] | 15 | |
| 16 | int main(void) |
| 17 | { |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 18 | /** @brief Dbus constructs used by LED Group manager */ |
George Liu | 1c737af | 2020-10-16 09:07:02 +0800 | [diff] [blame] | 19 | auto& bus = phosphor::led::utils::DBusHandler::getBus(); |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 20 | |
George Liu | def5f5a | 2020-04-10 11:23:52 +0800 | [diff] [blame] | 21 | #ifdef LED_USE_JSON |
| 22 | auto systemLedMap = loadJsonConfig(LED_JSON_FILE); |
| 23 | #endif |
| 24 | |
Vishwanatha Subbanna | 11ca8f9 | 2017-02-27 19:33:45 +0530 | [diff] [blame] | 25 | /** @brief Group manager object */ |
| 26 | phosphor::led::Manager manager(bus, systemLedMap); |
| 27 | |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 28 | /** @brief sd_bus object manager */ |
| 29 | sdbusplus::server::manager::manager objManager(bus, OBJPATH); |
| 30 | |
| 31 | /** @brief vector of led groups */ |
| 32 | std::vector<std::unique_ptr<phosphor::led::Group>> groups; |
| 33 | |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame] | 34 | /** @brief store and re-store Group */ |
| 35 | phosphor::led::Serialize serialize(SAVED_GROUPS_FILE); |
| 36 | |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 37 | /** Now create so many dbus objects as there are groups */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 38 | for (auto& grp : systemLedMap) |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 39 | { |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame] | 40 | groups.emplace_back(std::make_unique<phosphor::led::Group>( |
| 41 | bus, grp.first, manager, serialize)); |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | /** @brief Claim the bus */ |
| 45 | bus.request_name(BUSNAME); |
| 46 | |
| 47 | /** @brief Wait for client requests */ |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 48 | while (true) |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 49 | { |
| 50 | /** @brief process dbus calls / signals discarding unhandled */ |
| 51 | bus.process_discard(); |
| 52 | bus.wait(); |
| 53 | } |
Vishwanatha Subbanna | b21fda7 | 2016-10-17 17:46:37 +0530 | [diff] [blame] | 54 | return 0; |
| 55 | } |