blob: fcd09d37e8e0e17a03511d544d3defc4b375e18d [file] [log] [blame]
Kuiying Wang3a044402019-02-19 15:00:11 +08001/*
2// Copyright (c) 2019 Intel Corporation
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16#include "post_code.hpp"
17
18int main(int argc, char* argv[])
19{
20 int ret = 0;
21
22 phosphor::logging::log<phosphor::logging::level::INFO>(
23 "Start post code manager service...");
24
25 sd_event* event = nullptr;
26 ret = sd_event_default(&event);
27 if (ret < 0)
28 {
29 phosphor::logging::log<phosphor::logging::level::ERR>(
30 "Error creating a default sd_event handler");
31 return ret;
32 }
33 EventPtr eventP{event};
34 event = nullptr;
35
36 sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
37 sdbusplus::server::manager_t m{bus, DBUS_OBJECT_NAME};
38
39 bus.request_name(DBUS_INTF_NAME);
40
41 PostCode postCode{bus, DBUS_OBJECT_NAME, eventP};
42
43 try
44 {
45 bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
46 ret = sd_event_loop(eventP.get());
47 if (ret < 0)
48 {
49 phosphor::logging::log<phosphor::logging::level::ERR>(
50 "Error occurred during the sd_event_loop",
51 phosphor::logging::entry("RET=%d", ret));
52 }
53 }
54 catch (std::exception& e)
55 {
56 phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
57 return -1;
58 }
59 return 0;
60}