xref: /openbmc/bmcweb/features/redfish/lib/led.hpp (revision 177612aaa0633cf9d5aef0b763a43135cf552d9b)
140e9b92eSEd Tanous // SPDX-License-Identifier: Apache-2.0
240e9b92eSEd Tanous // SPDX-FileCopyrightText: Copyright OpenBMC Authors
340e9b92eSEd Tanous // SPDX-FileCopyrightText: Copyright 2019 Intel Corporation
41c8fba97SJames Feist #pragma once
51c8fba97SJames Feist 
61c8fba97SJames Feist #include "async_resp.hpp"
7d7857201SEd Tanous #include "dbus_singleton.hpp"
81c8fba97SJames Feist #include "dbus_utility.hpp"
9d7857201SEd Tanous #include "error_messages.hpp"
10539d8c6bSEd Tanous #include "generated/enums/chassis.hpp"
11d7857201SEd Tanous #include "logging.hpp"
12d7857201SEd Tanous #include "utils/dbus_utils.hpp"
131c8fba97SJames Feist 
147066dc58SMyung Bae #include <asm-generic/errno.h>
157066dc58SMyung Bae 
167066dc58SMyung Bae #include <boost/system/error_code.hpp>
171e1e598dSJonathan Doman #include <sdbusplus/asio/property.hpp>
18d7857201SEd Tanous #include <sdbusplus/message/native_types.hpp>
19d7857201SEd Tanous 
207066dc58SMyung Bae #include <array>
217066dc58SMyung Bae #include <functional>
22d7857201SEd Tanous #include <memory>
23*177612aaSEd Tanous #include <string>
247066dc58SMyung Bae #include <string_view>
257066dc58SMyung Bae #include <utility>
267e860f15SJohn Edward Broadbent 
271c8fba97SJames Feist namespace redfish
281c8fba97SJames Feist {
297066dc58SMyung Bae static constexpr std::array<std::string_view, 1> ledGroupInterface = {
307066dc58SMyung Bae     "xyz.openbmc_project.Led.Group"};
311c8fba97SJames Feist /**
321c8fba97SJames Feist  * @brief Retrieves identify led group properties over dbus
331c8fba97SJames Feist  *
34ac106bf6SEd Tanous  * @param[in] asyncResp     Shared pointer for generating response message.
351c8fba97SJames Feist  *
361c8fba97SJames Feist  * @return None.
371c8fba97SJames Feist  */
389f8bfa7cSGunnar Mills // TODO (Gunnar): Remove IndicatorLED after enough time has passed
39504af5a0SPatrick Williams inline void getIndicatorLedState(
40504af5a0SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
411c8fba97SJames Feist {
4262598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get led groups");
43deae6a78SEd Tanous     dbus::utility::getProperty<bool>(
44deae6a78SEd Tanous         "xyz.openbmc_project.LED.GroupManager",
451e1e598dSJonathan Doman         "/xyz/openbmc_project/led/groups/enclosure_identify_blink",
461e1e598dSJonathan Doman         "xyz.openbmc_project.Led.Group", "Asserted",
47ac106bf6SEd Tanous         [asyncResp](const boost::system::error_code& ec, const bool blinking) {
481c8fba97SJames Feist             // Some systems may not have enclosure_identify_blink object so
491c8fba97SJames Feist             // proceed to get enclosure_identify state.
501e1e598dSJonathan Doman             if (ec == boost::system::errc::invalid_argument)
511c8fba97SJames Feist             {
5262598e31SEd Tanous                 BMCWEB_LOG_DEBUG(
538ece0e45SEd Tanous                     "Get identity blinking LED failed, mismatch in property type");
54ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
551c8fba97SJames Feist                 return;
561c8fba97SJames Feist             }
571c8fba97SJames Feist 
581e1e598dSJonathan Doman             // Blinking ON, no need to check enclosure_identify assert.
591e1e598dSJonathan Doman             if (!ec && blinking)
601e1e598dSJonathan Doman             {
61539d8c6bSEd Tanous                 asyncResp->res.jsonValue["IndicatorLED"] =
62539d8c6bSEd Tanous                     chassis::IndicatorLED::Blinking;
631e1e598dSJonathan Doman                 return;
641e1e598dSJonathan Doman             }
651e1e598dSJonathan Doman 
66deae6a78SEd Tanous             dbus::utility::getProperty<bool>(
671e1e598dSJonathan Doman                 "xyz.openbmc_project.LED.GroupManager",
681e1e598dSJonathan Doman                 "/xyz/openbmc_project/led/groups/enclosure_identify",
691e1e598dSJonathan Doman                 "xyz.openbmc_project.Led.Group", "Asserted",
70ac106bf6SEd Tanous                 [asyncResp](const boost::system::error_code& ec2,
71ac106bf6SEd Tanous                             const bool ledOn) {
721e1e598dSJonathan Doman                     if (ec2 == boost::system::errc::invalid_argument)
731e1e598dSJonathan Doman                     {
7462598e31SEd Tanous                         BMCWEB_LOG_DEBUG(
758ece0e45SEd Tanous                             "Get enclosure identity led failed, mismatch in property type");
76ac106bf6SEd Tanous                         messages::internalError(asyncResp->res);
771e1e598dSJonathan Doman                         return;
781e1e598dSJonathan Doman                     }
791e1e598dSJonathan Doman 
801e1e598dSJonathan Doman                     if (ec2)
811e1e598dSJonathan Doman                     {
821e1e598dSJonathan Doman                         return;
831e1e598dSJonathan Doman                     }
841e1e598dSJonathan Doman 
851e1e598dSJonathan Doman                     if (ledOn)
861c8fba97SJames Feist                     {
87539d8c6bSEd Tanous                         asyncResp->res.jsonValue["IndicatorLED"] =
88539d8c6bSEd Tanous                             chassis::IndicatorLED::Lit;
891c8fba97SJames Feist                     }
901c8fba97SJames Feist                     else
911c8fba97SJames Feist                     {
92539d8c6bSEd Tanous                         asyncResp->res.jsonValue["IndicatorLED"] =
93539d8c6bSEd Tanous                             chassis::IndicatorLED::Off;
941c8fba97SJames Feist                     }
951e1e598dSJonathan Doman                 });
961e1e598dSJonathan Doman         });
971c8fba97SJames Feist }
981c8fba97SJames Feist 
991c8fba97SJames Feist /**
1001c8fba97SJames Feist  * @brief Sets identify led group properties
1011c8fba97SJames Feist  *
102ac106bf6SEd Tanous  * @param[in] asyncResp     Shared pointer for generating response message.
1031c8fba97SJames Feist  * @param[in] ledState  LED state passed from request
1041c8fba97SJames Feist  *
1051c8fba97SJames Feist  * @return None.
1061c8fba97SJames Feist  */
1079f8bfa7cSGunnar Mills // TODO (Gunnar): Remove IndicatorLED after enough time has passed
108504af5a0SPatrick Williams inline void setIndicatorLedState(
109504af5a0SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
1101c8fba97SJames Feist     const std::string& ledState)
1111c8fba97SJames Feist {
11262598e31SEd Tanous     BMCWEB_LOG_DEBUG("Set led groups");
1131c8fba97SJames Feist     bool ledOn = false;
1141c8fba97SJames Feist     bool ledBlinkng = false;
1151c8fba97SJames Feist 
1161c8fba97SJames Feist     if (ledState == "Lit")
1171c8fba97SJames Feist     {
1181c8fba97SJames Feist         ledOn = true;
1191c8fba97SJames Feist     }
1201c8fba97SJames Feist     else if (ledState == "Blinking")
1211c8fba97SJames Feist     {
1221c8fba97SJames Feist         ledBlinkng = true;
1231c8fba97SJames Feist     }
1241c8fba97SJames Feist     else if (ledState != "Off")
1251c8fba97SJames Feist     {
126ac106bf6SEd Tanous         messages::propertyValueNotInList(asyncResp->res, ledState,
127ac106bf6SEd Tanous                                          "IndicatorLED");
1281c8fba97SJames Feist         return;
1291c8fba97SJames Feist     }
1301c8fba97SJames Feist 
1319ae226faSGeorge Liu     sdbusplus::asio::setProperty(
1329ae226faSGeorge Liu         *crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager",
1339ae226faSGeorge Liu         "/xyz/openbmc_project/led/groups/enclosure_identify_blink",
1349ae226faSGeorge Liu         "xyz.openbmc_project.Led.Group", "Asserted", ledBlinkng,
135ac106bf6SEd Tanous         [asyncResp, ledOn,
1365e7e2dc5SEd Tanous          ledBlinkng](const boost::system::error_code& ec) mutable {
1371c8fba97SJames Feist             if (ec)
1381c8fba97SJames Feist             {
1391c8fba97SJames Feist                 // Some systems may not have enclosure_identify_blink object so
1401c8fba97SJames Feist                 // Lets set enclosure_identify state to true if Blinking is
1411c8fba97SJames Feist                 // true.
1421c8fba97SJames Feist                 if (ledBlinkng)
1431c8fba97SJames Feist                 {
1441c8fba97SJames Feist                     ledOn = true;
1451c8fba97SJames Feist                 }
1461c8fba97SJames Feist             }
14787c44966SAsmitha Karunanithi             setDbusProperty(
148bd79bce8SPatrick Williams                 asyncResp, "IndicatorLED",
149bd79bce8SPatrick Williams                 "xyz.openbmc_project.LED.GroupManager",
15087c44966SAsmitha Karunanithi                 sdbusplus::message::object_path(
15187c44966SAsmitha Karunanithi                     "/xyz/openbmc_project/led/groups/enclosure_identify"),
152e93abac6SGinu George                 "xyz.openbmc_project.Led.Group", "Asserted", ledBlinkng);
1539ae226faSGeorge Liu         });
1541c8fba97SJames Feist }
1559f8bfa7cSGunnar Mills 
1569f8bfa7cSGunnar Mills /**
15759a17e4fSGeorge Liu  * @brief Retrieves identify system led group properties over dbus
1589f8bfa7cSGunnar Mills  *
159ac106bf6SEd Tanous  * @param[in] asyncResp     Shared pointer for generating response message.
1609f8bfa7cSGunnar Mills  *
1619f8bfa7cSGunnar Mills  * @return None.
1629f8bfa7cSGunnar Mills  */
16359a17e4fSGeorge Liu inline void getSystemLocationIndicatorActive(
164ac106bf6SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
1659f8bfa7cSGunnar Mills {
16662598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get LocationIndicatorActive");
167deae6a78SEd Tanous     dbus::utility::getProperty<bool>(
168deae6a78SEd Tanous         "xyz.openbmc_project.LED.GroupManager",
1691e1e598dSJonathan Doman         "/xyz/openbmc_project/led/groups/enclosure_identify_blink",
1701e1e598dSJonathan Doman         "xyz.openbmc_project.Led.Group", "Asserted",
171ac106bf6SEd Tanous         [asyncResp](const boost::system::error_code& ec, const bool blinking) {
1729f8bfa7cSGunnar Mills             // Some systems may not have enclosure_identify_blink object so
1739f8bfa7cSGunnar Mills             // proceed to get enclosure_identify state.
1741e1e598dSJonathan Doman             if (ec == boost::system::errc::invalid_argument)
1759f8bfa7cSGunnar Mills             {
17662598e31SEd Tanous                 BMCWEB_LOG_DEBUG(
1778ece0e45SEd Tanous                     "Get identity blinking LED failed, mismatch in property type");
178ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
1799f8bfa7cSGunnar Mills                 return;
1809f8bfa7cSGunnar Mills             }
1819f8bfa7cSGunnar Mills 
1821e1e598dSJonathan Doman             // Blinking ON, no need to check enclosure_identify assert.
1831e1e598dSJonathan Doman             if (!ec && blinking)
1849f8bfa7cSGunnar Mills             {
185ac106bf6SEd Tanous                 asyncResp->res.jsonValue["LocationIndicatorActive"] = true;
1869f8bfa7cSGunnar Mills                 return;
1871e1e598dSJonathan Doman             }
1881e1e598dSJonathan Doman 
189deae6a78SEd Tanous             dbus::utility::getProperty<bool>(
1909f8bfa7cSGunnar Mills                 "xyz.openbmc_project.LED.GroupManager",
1919f8bfa7cSGunnar Mills                 "/xyz/openbmc_project/led/groups/enclosure_identify",
1921e1e598dSJonathan Doman                 "xyz.openbmc_project.Led.Group", "Asserted",
193ac106bf6SEd Tanous                 [asyncResp](const boost::system::error_code& ec2,
194ac106bf6SEd Tanous                             const bool ledOn) {
1951e1e598dSJonathan Doman                     if (ec2 == boost::system::errc::invalid_argument)
1961e1e598dSJonathan Doman                     {
19762598e31SEd Tanous                         BMCWEB_LOG_DEBUG(
1988ece0e45SEd Tanous                             "Get enclosure identity led failed, mismatch in property type");
199ac106bf6SEd Tanous                         messages::internalError(asyncResp->res);
2001e1e598dSJonathan Doman                         return;
2011e1e598dSJonathan Doman                     }
2021e1e598dSJonathan Doman 
2031e1e598dSJonathan Doman                     if (ec2)
2041e1e598dSJonathan Doman                     {
2051e1e598dSJonathan Doman                         return;
2061e1e598dSJonathan Doman                     }
2071e1e598dSJonathan Doman 
208ac106bf6SEd Tanous                     asyncResp->res.jsonValue["LocationIndicatorActive"] = ledOn;
2091e1e598dSJonathan Doman                 });
2101e1e598dSJonathan Doman         });
2119f8bfa7cSGunnar Mills }
2129f8bfa7cSGunnar Mills 
2139f8bfa7cSGunnar Mills /**
21459a17e4fSGeorge Liu  * @brief Sets identify system led group properties
2159f8bfa7cSGunnar Mills  *
216ac106bf6SEd Tanous  * @param[in] asyncResp     Shared pointer for generating response message.
2179f8bfa7cSGunnar Mills  * @param[in] ledState  LED state passed from request
2189f8bfa7cSGunnar Mills  *
2199f8bfa7cSGunnar Mills  * @return None.
2209f8bfa7cSGunnar Mills  */
22159a17e4fSGeorge Liu inline void setSystemLocationIndicatorActive(
222ac106bf6SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const bool ledState)
2239f8bfa7cSGunnar Mills {
22462598e31SEd Tanous     BMCWEB_LOG_DEBUG("Set LocationIndicatorActive");
2259f8bfa7cSGunnar Mills 
2269ae226faSGeorge Liu     sdbusplus::asio::setProperty(
2279ae226faSGeorge Liu         *crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager",
2289ae226faSGeorge Liu         "/xyz/openbmc_project/led/groups/enclosure_identify_blink",
2299ae226faSGeorge Liu         "xyz.openbmc_project.Led.Group", "Asserted", ledState,
2309ae226faSGeorge Liu         [asyncResp, ledState](const boost::system::error_code& ec) {
2319f8bfa7cSGunnar Mills             if (ec)
2329f8bfa7cSGunnar Mills             {
2339f8bfa7cSGunnar Mills                 // Some systems may not have enclosure_identify_blink object so
2349f8bfa7cSGunnar Mills                 // lets set enclosure_identify state also if
2359f8bfa7cSGunnar Mills                 // enclosure_identify_blink failed
23687c44966SAsmitha Karunanithi                 setDbusProperty(
237e93abac6SGinu George                     asyncResp, "LocationIndicatorActive",
238e93abac6SGinu George                     "xyz.openbmc_project.LED.GroupManager",
23987c44966SAsmitha Karunanithi                     sdbusplus::message::object_path(
24087c44966SAsmitha Karunanithi                         "/xyz/openbmc_project/led/groups/enclosure_identify"),
241e93abac6SGinu George                     "xyz.openbmc_project.Led.Group", "Asserted", ledState);
2429f8bfa7cSGunnar Mills             }
2439ae226faSGeorge Liu         });
2449f8bfa7cSGunnar Mills }
2457066dc58SMyung Bae 
2467066dc58SMyung Bae inline void handleLedGroupSubtree(
2477066dc58SMyung Bae     const std::string& objPath, const boost::system::error_code& ec,
2487066dc58SMyung Bae     const dbus::utility::MapperGetSubTreeResponse& subtree,
2497066dc58SMyung Bae     const std::function<void(const boost::system::error_code& ec,
2507066dc58SMyung Bae                              const std::string& ledGroupPath,
2517066dc58SMyung Bae                              const std::string& service)>& callback)
2527066dc58SMyung Bae {
2537066dc58SMyung Bae     if (ec)
2547066dc58SMyung Bae     {
2557066dc58SMyung Bae         // Callback will handle the error
2567066dc58SMyung Bae         callback(ec, "", "");
2577066dc58SMyung Bae         return;
2587066dc58SMyung Bae     }
2597066dc58SMyung Bae 
2607066dc58SMyung Bae     if (subtree.empty())
2617066dc58SMyung Bae     {
2627066dc58SMyung Bae         // Callback will handle the error
2637066dc58SMyung Bae         BMCWEB_LOG_DEBUG(
2647066dc58SMyung Bae             "No LED group associated with the specified object path: {}",
2657066dc58SMyung Bae             objPath);
2667066dc58SMyung Bae         callback(ec, "", "");
2677066dc58SMyung Bae         return;
2687066dc58SMyung Bae     }
2697066dc58SMyung Bae 
2707066dc58SMyung Bae     if (subtree.size() > 1)
2717066dc58SMyung Bae     {
2727066dc58SMyung Bae         // Callback will handle the error
2737066dc58SMyung Bae         BMCWEB_LOG_DEBUG(
2747066dc58SMyung Bae             "More than one LED group associated with the object {}: {}",
2757066dc58SMyung Bae             objPath, subtree.size());
2767066dc58SMyung Bae         callback(ec, "", "");
2777066dc58SMyung Bae         return;
2787066dc58SMyung Bae     }
2797066dc58SMyung Bae 
2807066dc58SMyung Bae     const auto& [ledGroupPath, serviceMap] = *subtree.begin();
2817066dc58SMyung Bae     const auto& [service, interfaces] = *serviceMap.begin();
2827066dc58SMyung Bae     callback(ec, ledGroupPath, service);
2837066dc58SMyung Bae }
2847066dc58SMyung Bae 
2857066dc58SMyung Bae inline void getLedGroupPath(
2867066dc58SMyung Bae     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
2877066dc58SMyung Bae     const std::string& objPath,
2887066dc58SMyung Bae     std::function<void(const boost::system::error_code& ec,
2897066dc58SMyung Bae                        const std::string& ledGroupPath,
2907066dc58SMyung Bae                        const std::string& service)>&& callback)
2917066dc58SMyung Bae {
2927066dc58SMyung Bae     static constexpr const char* ledObjectPath =
2937066dc58SMyung Bae         "/xyz/openbmc_project/led/groups";
2947066dc58SMyung Bae     sdbusplus::message::object_path ledGroupAssociatedPath =
2957066dc58SMyung Bae         objPath + "/identifying";
2967066dc58SMyung Bae 
2977066dc58SMyung Bae     dbus::utility::getAssociatedSubTree(
2987066dc58SMyung Bae         ledGroupAssociatedPath, sdbusplus::message::object_path(ledObjectPath),
2997066dc58SMyung Bae         0, ledGroupInterface,
3007066dc58SMyung Bae         [asyncResp, objPath, callback{std::move(callback)}](
3017066dc58SMyung Bae             const boost::system::error_code& ec,
3027066dc58SMyung Bae             const dbus::utility::MapperGetSubTreeResponse& subtree) {
3037066dc58SMyung Bae             handleLedGroupSubtree(objPath, ec, subtree, callback);
3047066dc58SMyung Bae         });
3057066dc58SMyung Bae }
3067066dc58SMyung Bae 
3077066dc58SMyung Bae inline void afterGetLedState(
3087066dc58SMyung Bae     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
3097066dc58SMyung Bae     const boost::system::error_code& ec, bool assert)
3107066dc58SMyung Bae {
3117066dc58SMyung Bae     if (ec)
3127066dc58SMyung Bae     {
3137066dc58SMyung Bae         if (ec.value() != EBADR)
3147066dc58SMyung Bae         {
3157066dc58SMyung Bae             BMCWEB_LOG_ERROR("DBUS response error for get ledState {}",
3167066dc58SMyung Bae                              ec.value());
3177066dc58SMyung Bae             messages::internalError(asyncResp->res);
3187066dc58SMyung Bae         }
3197066dc58SMyung Bae         return;
3207066dc58SMyung Bae     }
3217066dc58SMyung Bae 
3227066dc58SMyung Bae     asyncResp->res.jsonValue["LocationIndicatorActive"] = assert;
3237066dc58SMyung Bae }
3247066dc58SMyung Bae 
3257066dc58SMyung Bae inline void getLedState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
3267066dc58SMyung Bae                         const boost::system::error_code& ec,
3277066dc58SMyung Bae                         const std::string& ledGroupPath,
3287066dc58SMyung Bae                         const std::string& service)
3297066dc58SMyung Bae {
3307066dc58SMyung Bae     if (ec)
3317066dc58SMyung Bae     {
3327066dc58SMyung Bae         if (ec.value() != EBADR)
3337066dc58SMyung Bae         {
3347066dc58SMyung Bae             BMCWEB_LOG_ERROR("DBUS response error {}", ec.value());
3357066dc58SMyung Bae             messages::internalError(asyncResp->res);
3367066dc58SMyung Bae         }
3377066dc58SMyung Bae         return;
3387066dc58SMyung Bae     }
3397066dc58SMyung Bae 
3407066dc58SMyung Bae     if (ledGroupPath.empty() || service.empty())
3417066dc58SMyung Bae     {
3427066dc58SMyung Bae         // No LED group associated, not an error
3437066dc58SMyung Bae         return;
3447066dc58SMyung Bae     }
3457066dc58SMyung Bae 
3467066dc58SMyung Bae     sdbusplus::asio::getProperty<bool>(
3477066dc58SMyung Bae         *crow::connections::systemBus, service, ledGroupPath,
3487066dc58SMyung Bae         "xyz.openbmc_project.Led.Group", "Asserted",
3497066dc58SMyung Bae         std::bind_front(afterGetLedState, asyncResp));
3507066dc58SMyung Bae }
3517066dc58SMyung Bae 
3527066dc58SMyung Bae /**
3537066dc58SMyung Bae  * @brief Retrieves identify led group properties over dbus
3547066dc58SMyung Bae  *
3557066dc58SMyung Bae  * @param[in] asyncResp Shared pointer for generating response
3567066dc58SMyung Bae  * message.
3577066dc58SMyung Bae  * @param[in] objPath   Object path on PIM
3587066dc58SMyung Bae  *
3597066dc58SMyung Bae  * @return None.
3607066dc58SMyung Bae  */
3617066dc58SMyung Bae inline void getLocationIndicatorActive(
3627066dc58SMyung Bae     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
3637066dc58SMyung Bae     const std::string& objPath)
3647066dc58SMyung Bae {
3657066dc58SMyung Bae     BMCWEB_LOG_DEBUG("Get LocationIndicatorActive for {}", objPath);
3667066dc58SMyung Bae     getLedGroupPath(asyncResp, objPath,
3677066dc58SMyung Bae                     [asyncResp](const boost::system::error_code& ec,
3687066dc58SMyung Bae                                 const std::string& ledGroupPath,
3697066dc58SMyung Bae                                 const std::string& service) {
3707066dc58SMyung Bae                         getLedState(asyncResp, ec, ledGroupPath, service);
3717066dc58SMyung Bae                     });
3727066dc58SMyung Bae }
3737066dc58SMyung Bae 
3747066dc58SMyung Bae inline void setLedState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
3757066dc58SMyung Bae                         bool ledState, const boost::system::error_code& ec,
3767066dc58SMyung Bae                         const std::string& ledGroupPath,
3777066dc58SMyung Bae                         const std::string& service)
3787066dc58SMyung Bae {
3797066dc58SMyung Bae     if (ec)
3807066dc58SMyung Bae     {
3817066dc58SMyung Bae         if (ec.value() == EBADR)
3827066dc58SMyung Bae         {
3837066dc58SMyung Bae             messages::propertyUnknown(asyncResp->res,
3847066dc58SMyung Bae                                       "LocationIndicatorActive");
3857066dc58SMyung Bae             return;
3867066dc58SMyung Bae         }
3877066dc58SMyung Bae         BMCWEB_LOG_ERROR("DBUS response error {}", ec.value());
3887066dc58SMyung Bae         messages::internalError(asyncResp->res);
3897066dc58SMyung Bae         return;
3907066dc58SMyung Bae     }
3917066dc58SMyung Bae 
3927066dc58SMyung Bae     if (ledGroupPath.empty() || service.empty())
3937066dc58SMyung Bae     {
3947066dc58SMyung Bae         messages::propertyUnknown(asyncResp->res, "LocationIndicatorActive");
3957066dc58SMyung Bae         return;
3967066dc58SMyung Bae     }
3977066dc58SMyung Bae 
3987066dc58SMyung Bae     setDbusProperty(asyncResp, "LocationIndicatorActive", service, ledGroupPath,
3997066dc58SMyung Bae                     "xyz.openbmc_project.Led.Group", "Asserted", ledState);
4007066dc58SMyung Bae }
4017066dc58SMyung Bae 
4027066dc58SMyung Bae /**
4037066dc58SMyung Bae  * @brief Sets identify led group properties
4047066dc58SMyung Bae  *
4057066dc58SMyung Bae  * @param[in] asyncResp     Shared pointer for generating response
4067066dc58SMyung Bae  * message.
4077066dc58SMyung Bae  * @param[in] objPath       Object path on PIM
4087066dc58SMyung Bae  * @param[in] ledState      LED state passed from request
4097066dc58SMyung Bae  *
4107066dc58SMyung Bae  * @return None.
4117066dc58SMyung Bae  */
4127066dc58SMyung Bae inline void setLocationIndicatorActive(
4137066dc58SMyung Bae     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
4147066dc58SMyung Bae     const std::string& objPath, bool ledState)
4157066dc58SMyung Bae {
4167066dc58SMyung Bae     BMCWEB_LOG_DEBUG("Set LocationIndicatorActive for {}", objPath);
4177066dc58SMyung Bae     getLedGroupPath(
4187066dc58SMyung Bae         asyncResp, objPath,
4197066dc58SMyung Bae         [asyncResp, ledState](const boost::system::error_code& ec,
4207066dc58SMyung Bae                               const std::string& ledGroupPath,
4217066dc58SMyung Bae                               const std::string& service) {
4227066dc58SMyung Bae             setLedState(asyncResp, ledState, ec, ledGroupPath, service);
4237066dc58SMyung Bae         });
4247066dc58SMyung Bae }
4257066dc58SMyung Bae 
4261c8fba97SJames Feist } // namespace redfish
427