blob: 425ab35514d51002f76529339755d93c2b0b7c29 [file] [log] [blame]
Alexander Hansenaa300642025-02-04 15:51:52 +01001#include "example_device.hpp"
2
3#include <sdbusplus/async/context.hpp>
4
5using namespace phosphor::software::example_device;
6
7// NOLINTBEGIN(readability-static-accessed-through-instance)
8sdbusplus::async::task<void> init(ExampleCodeUpdater& updater)
9// NOLINTEND(readability-static-accessed-through-instance)
10{
11 co_await updater.initDevice("", "", ExampleDevice::defaultConfig);
12
13 co_return;
14}
15
16int main()
17{
18 sdbusplus::async::context ctx;
19
20 ExampleCodeUpdater updater(ctx);
21
22 /*
23 * In Concrete updaters, the initDevices() function needs to be called,
24 * which in turn invokes the virtual initDevice() function implemented here.
25 * However, in ExampleUpdater, the initDevice() function is called directly
26 * because there is no example configuration from EM to consume, which would
27 * otherwise cause the initDevices() API to throw an error. Therefore,
28 * calling initDevice() directly in this case.
29 */
30
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}