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