Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame] | 1 | #include "example_device.hpp" |
| 2 | |
| 3 | #include <sdbusplus/async/context.hpp> |
| 4 | |
| 5 | using namespace phosphor::software::example_device; |
| 6 | |
| 7 | // NOLINTBEGIN(readability-static-accessed-through-instance) |
| 8 | sdbusplus::async::task<void> init(ExampleCodeUpdater& updater) |
| 9 | // NOLINTEND(readability-static-accessed-through-instance) |
| 10 | { |
Alexander Hansen | 85aed22 | 2025-02-18 11:23:47 +0100 | [diff] [blame^] | 11 | /* |
| 12 | * In Concrete updaters, the initDevices() function needs to be called, |
| 13 | * which in turn invokes the virtual initDevice() function implemented here. |
| 14 | * However, in ExampleUpdater, the initDevice() function is called directly |
| 15 | * because there is no example configuration from EM to consume, which would |
| 16 | * otherwise cause the initDevices() API to throw an error. Therefore, |
| 17 | * calling initDevice() directly in this case. |
| 18 | */ |
| 19 | |
Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame] | 20 | co_await updater.initDevice("", "", ExampleDevice::defaultConfig); |
| 21 | |
| 22 | co_return; |
| 23 | } |
| 24 | |
| 25 | int main() |
| 26 | { |
| 27 | sdbusplus::async::context ctx; |
| 28 | |
| 29 | ExampleCodeUpdater updater(ctx); |
| 30 | |
Alexander Hansen | aa30064 | 2025-02-04 15:51:52 +0100 | [diff] [blame] | 31 | // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Branch) |
| 32 | ctx.spawn(init(updater)); |
| 33 | |
| 34 | std::string busName = "xyz.openbmc_project.Software.ExampleDevice"; |
| 35 | ctx.get_bus().request_name(busName.c_str()); |
| 36 | |
| 37 | ctx.run(); |
| 38 | |
| 39 | return 0; |
| 40 | } |