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 14*7066dc58SMyung Bae #include <asm-generic/errno.h> 15*7066dc58SMyung Bae 16*7066dc58SMyung Bae #include <boost/system/error_code.hpp> 171e1e598dSJonathan Doman #include <sdbusplus/asio/property.hpp> 18d7857201SEd Tanous #include <sdbusplus/message/native_types.hpp> 19d7857201SEd Tanous 20*7066dc58SMyung Bae #include <array> 21*7066dc58SMyung Bae #include <functional> 22d7857201SEd Tanous #include <memory> 23*7066dc58SMyung Bae #include <string_view> 24*7066dc58SMyung Bae #include <utility> 257e860f15SJohn Edward Broadbent 261c8fba97SJames Feist namespace redfish 271c8fba97SJames Feist { 28*7066dc58SMyung Bae static constexpr std::array<std::string_view, 1> ledGroupInterface = { 29*7066dc58SMyung Bae "xyz.openbmc_project.Led.Group"}; 301c8fba97SJames Feist /** 311c8fba97SJames Feist * @brief Retrieves identify led group properties over dbus 321c8fba97SJames Feist * 33ac106bf6SEd Tanous * @param[in] asyncResp Shared pointer for generating response message. 341c8fba97SJames Feist * 351c8fba97SJames Feist * @return None. 361c8fba97SJames Feist */ 379f8bfa7cSGunnar Mills // TODO (Gunnar): Remove IndicatorLED after enough time has passed 38504af5a0SPatrick Williams inline void getIndicatorLedState( 39504af5a0SPatrick Williams const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 401c8fba97SJames Feist { 4162598e31SEd Tanous BMCWEB_LOG_DEBUG("Get led groups"); 42deae6a78SEd Tanous dbus::utility::getProperty<bool>( 43deae6a78SEd Tanous "xyz.openbmc_project.LED.GroupManager", 441e1e598dSJonathan Doman "/xyz/openbmc_project/led/groups/enclosure_identify_blink", 451e1e598dSJonathan Doman "xyz.openbmc_project.Led.Group", "Asserted", 46ac106bf6SEd Tanous [asyncResp](const boost::system::error_code& ec, const bool blinking) { 471c8fba97SJames Feist // Some systems may not have enclosure_identify_blink object so 481c8fba97SJames Feist // proceed to get enclosure_identify state. 491e1e598dSJonathan Doman if (ec == boost::system::errc::invalid_argument) 501c8fba97SJames Feist { 5162598e31SEd Tanous BMCWEB_LOG_DEBUG( 528ece0e45SEd Tanous "Get identity blinking LED failed, mismatch in property type"); 53ac106bf6SEd Tanous messages::internalError(asyncResp->res); 541c8fba97SJames Feist return; 551c8fba97SJames Feist } 561c8fba97SJames Feist 571e1e598dSJonathan Doman // Blinking ON, no need to check enclosure_identify assert. 581e1e598dSJonathan Doman if (!ec && blinking) 591e1e598dSJonathan Doman { 60539d8c6bSEd Tanous asyncResp->res.jsonValue["IndicatorLED"] = 61539d8c6bSEd Tanous chassis::IndicatorLED::Blinking; 621e1e598dSJonathan Doman return; 631e1e598dSJonathan Doman } 641e1e598dSJonathan Doman 65deae6a78SEd Tanous dbus::utility::getProperty<bool>( 661e1e598dSJonathan Doman "xyz.openbmc_project.LED.GroupManager", 671e1e598dSJonathan Doman "/xyz/openbmc_project/led/groups/enclosure_identify", 681e1e598dSJonathan Doman "xyz.openbmc_project.Led.Group", "Asserted", 69ac106bf6SEd Tanous [asyncResp](const boost::system::error_code& ec2, 70ac106bf6SEd Tanous const bool ledOn) { 711e1e598dSJonathan Doman if (ec2 == boost::system::errc::invalid_argument) 721e1e598dSJonathan Doman { 7362598e31SEd Tanous BMCWEB_LOG_DEBUG( 748ece0e45SEd Tanous "Get enclosure identity led failed, mismatch in property type"); 75ac106bf6SEd Tanous messages::internalError(asyncResp->res); 761e1e598dSJonathan Doman return; 771e1e598dSJonathan Doman } 781e1e598dSJonathan Doman 791e1e598dSJonathan Doman if (ec2) 801e1e598dSJonathan Doman { 811e1e598dSJonathan Doman return; 821e1e598dSJonathan Doman } 831e1e598dSJonathan Doman 841e1e598dSJonathan Doman if (ledOn) 851c8fba97SJames Feist { 86539d8c6bSEd Tanous asyncResp->res.jsonValue["IndicatorLED"] = 87539d8c6bSEd Tanous chassis::IndicatorLED::Lit; 881c8fba97SJames Feist } 891c8fba97SJames Feist else 901c8fba97SJames Feist { 91539d8c6bSEd Tanous asyncResp->res.jsonValue["IndicatorLED"] = 92539d8c6bSEd Tanous chassis::IndicatorLED::Off; 931c8fba97SJames Feist } 941e1e598dSJonathan Doman }); 951e1e598dSJonathan Doman }); 961c8fba97SJames Feist } 971c8fba97SJames Feist 981c8fba97SJames Feist /** 991c8fba97SJames Feist * @brief Sets identify led group properties 1001c8fba97SJames Feist * 101ac106bf6SEd Tanous * @param[in] asyncResp Shared pointer for generating response message. 1021c8fba97SJames Feist * @param[in] ledState LED state passed from request 1031c8fba97SJames Feist * 1041c8fba97SJames Feist * @return None. 1051c8fba97SJames Feist */ 1069f8bfa7cSGunnar Mills // TODO (Gunnar): Remove IndicatorLED after enough time has passed 107504af5a0SPatrick Williams inline void setIndicatorLedState( 108504af5a0SPatrick Williams const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 1091c8fba97SJames Feist const std::string& ledState) 1101c8fba97SJames Feist { 11162598e31SEd Tanous BMCWEB_LOG_DEBUG("Set led groups"); 1121c8fba97SJames Feist bool ledOn = false; 1131c8fba97SJames Feist bool ledBlinkng = false; 1141c8fba97SJames Feist 1151c8fba97SJames Feist if (ledState == "Lit") 1161c8fba97SJames Feist { 1171c8fba97SJames Feist ledOn = true; 1181c8fba97SJames Feist } 1191c8fba97SJames Feist else if (ledState == "Blinking") 1201c8fba97SJames Feist { 1211c8fba97SJames Feist ledBlinkng = true; 1221c8fba97SJames Feist } 1231c8fba97SJames Feist else if (ledState != "Off") 1241c8fba97SJames Feist { 125ac106bf6SEd Tanous messages::propertyValueNotInList(asyncResp->res, ledState, 126ac106bf6SEd Tanous "IndicatorLED"); 1271c8fba97SJames Feist return; 1281c8fba97SJames Feist } 1291c8fba97SJames Feist 1309ae226faSGeorge Liu sdbusplus::asio::setProperty( 1319ae226faSGeorge Liu *crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager", 1329ae226faSGeorge Liu "/xyz/openbmc_project/led/groups/enclosure_identify_blink", 1339ae226faSGeorge Liu "xyz.openbmc_project.Led.Group", "Asserted", ledBlinkng, 134ac106bf6SEd Tanous [asyncResp, ledOn, 1355e7e2dc5SEd Tanous ledBlinkng](const boost::system::error_code& ec) mutable { 1361c8fba97SJames Feist if (ec) 1371c8fba97SJames Feist { 1381c8fba97SJames Feist // Some systems may not have enclosure_identify_blink object so 1391c8fba97SJames Feist // Lets set enclosure_identify state to true if Blinking is 1401c8fba97SJames Feist // true. 1411c8fba97SJames Feist if (ledBlinkng) 1421c8fba97SJames Feist { 1431c8fba97SJames Feist ledOn = true; 1441c8fba97SJames Feist } 1451c8fba97SJames Feist } 14687c44966SAsmitha Karunanithi setDbusProperty( 147bd79bce8SPatrick Williams asyncResp, "IndicatorLED", 148bd79bce8SPatrick Williams "xyz.openbmc_project.LED.GroupManager", 14987c44966SAsmitha Karunanithi sdbusplus::message::object_path( 15087c44966SAsmitha Karunanithi "/xyz/openbmc_project/led/groups/enclosure_identify"), 151e93abac6SGinu George "xyz.openbmc_project.Led.Group", "Asserted", ledBlinkng); 1529ae226faSGeorge Liu }); 1531c8fba97SJames Feist } 1549f8bfa7cSGunnar Mills 1559f8bfa7cSGunnar Mills /** 15659a17e4fSGeorge Liu * @brief Retrieves identify system led group properties over dbus 1579f8bfa7cSGunnar Mills * 158ac106bf6SEd Tanous * @param[in] asyncResp Shared pointer for generating response message. 1599f8bfa7cSGunnar Mills * 1609f8bfa7cSGunnar Mills * @return None. 1619f8bfa7cSGunnar Mills */ 16259a17e4fSGeorge Liu inline void getSystemLocationIndicatorActive( 163ac106bf6SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 1649f8bfa7cSGunnar Mills { 16562598e31SEd Tanous BMCWEB_LOG_DEBUG("Get LocationIndicatorActive"); 166deae6a78SEd Tanous dbus::utility::getProperty<bool>( 167deae6a78SEd Tanous "xyz.openbmc_project.LED.GroupManager", 1681e1e598dSJonathan Doman "/xyz/openbmc_project/led/groups/enclosure_identify_blink", 1691e1e598dSJonathan Doman "xyz.openbmc_project.Led.Group", "Asserted", 170ac106bf6SEd Tanous [asyncResp](const boost::system::error_code& ec, const bool blinking) { 1719f8bfa7cSGunnar Mills // Some systems may not have enclosure_identify_blink object so 1729f8bfa7cSGunnar Mills // proceed to get enclosure_identify state. 1731e1e598dSJonathan Doman if (ec == boost::system::errc::invalid_argument) 1749f8bfa7cSGunnar Mills { 17562598e31SEd Tanous BMCWEB_LOG_DEBUG( 1768ece0e45SEd Tanous "Get identity blinking LED failed, mismatch in property type"); 177ac106bf6SEd Tanous messages::internalError(asyncResp->res); 1789f8bfa7cSGunnar Mills return; 1799f8bfa7cSGunnar Mills } 1809f8bfa7cSGunnar Mills 1811e1e598dSJonathan Doman // Blinking ON, no need to check enclosure_identify assert. 1821e1e598dSJonathan Doman if (!ec && blinking) 1839f8bfa7cSGunnar Mills { 184ac106bf6SEd Tanous asyncResp->res.jsonValue["LocationIndicatorActive"] = true; 1859f8bfa7cSGunnar Mills return; 1861e1e598dSJonathan Doman } 1871e1e598dSJonathan Doman 188deae6a78SEd Tanous dbus::utility::getProperty<bool>( 1899f8bfa7cSGunnar Mills "xyz.openbmc_project.LED.GroupManager", 1909f8bfa7cSGunnar Mills "/xyz/openbmc_project/led/groups/enclosure_identify", 1911e1e598dSJonathan Doman "xyz.openbmc_project.Led.Group", "Asserted", 192ac106bf6SEd Tanous [asyncResp](const boost::system::error_code& ec2, 193ac106bf6SEd Tanous const bool ledOn) { 1941e1e598dSJonathan Doman if (ec2 == boost::system::errc::invalid_argument) 1951e1e598dSJonathan Doman { 19662598e31SEd Tanous BMCWEB_LOG_DEBUG( 1978ece0e45SEd Tanous "Get enclosure identity led failed, mismatch in property type"); 198ac106bf6SEd Tanous messages::internalError(asyncResp->res); 1991e1e598dSJonathan Doman return; 2001e1e598dSJonathan Doman } 2011e1e598dSJonathan Doman 2021e1e598dSJonathan Doman if (ec2) 2031e1e598dSJonathan Doman { 2041e1e598dSJonathan Doman return; 2051e1e598dSJonathan Doman } 2061e1e598dSJonathan Doman 207ac106bf6SEd Tanous asyncResp->res.jsonValue["LocationIndicatorActive"] = ledOn; 2081e1e598dSJonathan Doman }); 2091e1e598dSJonathan Doman }); 2109f8bfa7cSGunnar Mills } 2119f8bfa7cSGunnar Mills 2129f8bfa7cSGunnar Mills /** 21359a17e4fSGeorge Liu * @brief Sets identify system led group properties 2149f8bfa7cSGunnar Mills * 215ac106bf6SEd Tanous * @param[in] asyncResp Shared pointer for generating response message. 2169f8bfa7cSGunnar Mills * @param[in] ledState LED state passed from request 2179f8bfa7cSGunnar Mills * 2189f8bfa7cSGunnar Mills * @return None. 2199f8bfa7cSGunnar Mills */ 22059a17e4fSGeorge Liu inline void setSystemLocationIndicatorActive( 221ac106bf6SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const bool ledState) 2229f8bfa7cSGunnar Mills { 22362598e31SEd Tanous BMCWEB_LOG_DEBUG("Set LocationIndicatorActive"); 2249f8bfa7cSGunnar Mills 2259ae226faSGeorge Liu sdbusplus::asio::setProperty( 2269ae226faSGeorge Liu *crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager", 2279ae226faSGeorge Liu "/xyz/openbmc_project/led/groups/enclosure_identify_blink", 2289ae226faSGeorge Liu "xyz.openbmc_project.Led.Group", "Asserted", ledState, 2299ae226faSGeorge Liu [asyncResp, ledState](const boost::system::error_code& ec) { 2309f8bfa7cSGunnar Mills if (ec) 2319f8bfa7cSGunnar Mills { 2329f8bfa7cSGunnar Mills // Some systems may not have enclosure_identify_blink object so 2339f8bfa7cSGunnar Mills // lets set enclosure_identify state also if 2349f8bfa7cSGunnar Mills // enclosure_identify_blink failed 23587c44966SAsmitha Karunanithi setDbusProperty( 236e93abac6SGinu George asyncResp, "LocationIndicatorActive", 237e93abac6SGinu George "xyz.openbmc_project.LED.GroupManager", 23887c44966SAsmitha Karunanithi sdbusplus::message::object_path( 23987c44966SAsmitha Karunanithi "/xyz/openbmc_project/led/groups/enclosure_identify"), 240e93abac6SGinu George "xyz.openbmc_project.Led.Group", "Asserted", ledState); 2419f8bfa7cSGunnar Mills } 2429ae226faSGeorge Liu }); 2439f8bfa7cSGunnar Mills } 244*7066dc58SMyung Bae 245*7066dc58SMyung Bae inline void handleLedGroupSubtree( 246*7066dc58SMyung Bae const std::string& objPath, const boost::system::error_code& ec, 247*7066dc58SMyung Bae const dbus::utility::MapperGetSubTreeResponse& subtree, 248*7066dc58SMyung Bae const std::function<void(const boost::system::error_code& ec, 249*7066dc58SMyung Bae const std::string& ledGroupPath, 250*7066dc58SMyung Bae const std::string& service)>& callback) 251*7066dc58SMyung Bae { 252*7066dc58SMyung Bae if (ec) 253*7066dc58SMyung Bae { 254*7066dc58SMyung Bae // Callback will handle the error 255*7066dc58SMyung Bae callback(ec, "", ""); 256*7066dc58SMyung Bae return; 257*7066dc58SMyung Bae } 258*7066dc58SMyung Bae 259*7066dc58SMyung Bae if (subtree.empty()) 260*7066dc58SMyung Bae { 261*7066dc58SMyung Bae // Callback will handle the error 262*7066dc58SMyung Bae BMCWEB_LOG_DEBUG( 263*7066dc58SMyung Bae "No LED group associated with the specified object path: {}", 264*7066dc58SMyung Bae objPath); 265*7066dc58SMyung Bae callback(ec, "", ""); 266*7066dc58SMyung Bae return; 267*7066dc58SMyung Bae } 268*7066dc58SMyung Bae 269*7066dc58SMyung Bae if (subtree.size() > 1) 270*7066dc58SMyung Bae { 271*7066dc58SMyung Bae // Callback will handle the error 272*7066dc58SMyung Bae BMCWEB_LOG_DEBUG( 273*7066dc58SMyung Bae "More than one LED group associated with the object {}: {}", 274*7066dc58SMyung Bae objPath, subtree.size()); 275*7066dc58SMyung Bae callback(ec, "", ""); 276*7066dc58SMyung Bae return; 277*7066dc58SMyung Bae } 278*7066dc58SMyung Bae 279*7066dc58SMyung Bae const auto& [ledGroupPath, serviceMap] = *subtree.begin(); 280*7066dc58SMyung Bae const auto& [service, interfaces] = *serviceMap.begin(); 281*7066dc58SMyung Bae callback(ec, ledGroupPath, service); 282*7066dc58SMyung Bae } 283*7066dc58SMyung Bae 284*7066dc58SMyung Bae inline void getLedGroupPath( 285*7066dc58SMyung Bae const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 286*7066dc58SMyung Bae const std::string& objPath, 287*7066dc58SMyung Bae std::function<void(const boost::system::error_code& ec, 288*7066dc58SMyung Bae const std::string& ledGroupPath, 289*7066dc58SMyung Bae const std::string& service)>&& callback) 290*7066dc58SMyung Bae { 291*7066dc58SMyung Bae static constexpr const char* ledObjectPath = 292*7066dc58SMyung Bae "/xyz/openbmc_project/led/groups"; 293*7066dc58SMyung Bae sdbusplus::message::object_path ledGroupAssociatedPath = 294*7066dc58SMyung Bae objPath + "/identifying"; 295*7066dc58SMyung Bae 296*7066dc58SMyung Bae dbus::utility::getAssociatedSubTree( 297*7066dc58SMyung Bae ledGroupAssociatedPath, sdbusplus::message::object_path(ledObjectPath), 298*7066dc58SMyung Bae 0, ledGroupInterface, 299*7066dc58SMyung Bae [asyncResp, objPath, callback{std::move(callback)}]( 300*7066dc58SMyung Bae const boost::system::error_code& ec, 301*7066dc58SMyung Bae const dbus::utility::MapperGetSubTreeResponse& subtree) { 302*7066dc58SMyung Bae handleLedGroupSubtree(objPath, ec, subtree, callback); 303*7066dc58SMyung Bae }); 304*7066dc58SMyung Bae } 305*7066dc58SMyung Bae 306*7066dc58SMyung Bae inline void afterGetLedState( 307*7066dc58SMyung Bae const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 308*7066dc58SMyung Bae const boost::system::error_code& ec, bool assert) 309*7066dc58SMyung Bae { 310*7066dc58SMyung Bae if (ec) 311*7066dc58SMyung Bae { 312*7066dc58SMyung Bae if (ec.value() != EBADR) 313*7066dc58SMyung Bae { 314*7066dc58SMyung Bae BMCWEB_LOG_ERROR("DBUS response error for get ledState {}", 315*7066dc58SMyung Bae ec.value()); 316*7066dc58SMyung Bae messages::internalError(asyncResp->res); 317*7066dc58SMyung Bae } 318*7066dc58SMyung Bae return; 319*7066dc58SMyung Bae } 320*7066dc58SMyung Bae 321*7066dc58SMyung Bae asyncResp->res.jsonValue["LocationIndicatorActive"] = assert; 322*7066dc58SMyung Bae } 323*7066dc58SMyung Bae 324*7066dc58SMyung Bae inline void getLedState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 325*7066dc58SMyung Bae const boost::system::error_code& ec, 326*7066dc58SMyung Bae const std::string& ledGroupPath, 327*7066dc58SMyung Bae const std::string& service) 328*7066dc58SMyung Bae { 329*7066dc58SMyung Bae if (ec) 330*7066dc58SMyung Bae { 331*7066dc58SMyung Bae if (ec.value() != EBADR) 332*7066dc58SMyung Bae { 333*7066dc58SMyung Bae BMCWEB_LOG_ERROR("DBUS response error {}", ec.value()); 334*7066dc58SMyung Bae messages::internalError(asyncResp->res); 335*7066dc58SMyung Bae } 336*7066dc58SMyung Bae return; 337*7066dc58SMyung Bae } 338*7066dc58SMyung Bae 339*7066dc58SMyung Bae if (ledGroupPath.empty() || service.empty()) 340*7066dc58SMyung Bae { 341*7066dc58SMyung Bae // No LED group associated, not an error 342*7066dc58SMyung Bae return; 343*7066dc58SMyung Bae } 344*7066dc58SMyung Bae 345*7066dc58SMyung Bae sdbusplus::asio::getProperty<bool>( 346*7066dc58SMyung Bae *crow::connections::systemBus, service, ledGroupPath, 347*7066dc58SMyung Bae "xyz.openbmc_project.Led.Group", "Asserted", 348*7066dc58SMyung Bae std::bind_front(afterGetLedState, asyncResp)); 349*7066dc58SMyung Bae } 350*7066dc58SMyung Bae 351*7066dc58SMyung Bae /** 352*7066dc58SMyung Bae * @brief Retrieves identify led group properties over dbus 353*7066dc58SMyung Bae * 354*7066dc58SMyung Bae * @param[in] asyncResp Shared pointer for generating response 355*7066dc58SMyung Bae * message. 356*7066dc58SMyung Bae * @param[in] objPath Object path on PIM 357*7066dc58SMyung Bae * 358*7066dc58SMyung Bae * @return None. 359*7066dc58SMyung Bae */ 360*7066dc58SMyung Bae inline void getLocationIndicatorActive( 361*7066dc58SMyung Bae const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 362*7066dc58SMyung Bae const std::string& objPath) 363*7066dc58SMyung Bae { 364*7066dc58SMyung Bae BMCWEB_LOG_DEBUG("Get LocationIndicatorActive for {}", objPath); 365*7066dc58SMyung Bae getLedGroupPath(asyncResp, objPath, 366*7066dc58SMyung Bae [asyncResp](const boost::system::error_code& ec, 367*7066dc58SMyung Bae const std::string& ledGroupPath, 368*7066dc58SMyung Bae const std::string& service) { 369*7066dc58SMyung Bae getLedState(asyncResp, ec, ledGroupPath, service); 370*7066dc58SMyung Bae }); 371*7066dc58SMyung Bae } 372*7066dc58SMyung Bae 373*7066dc58SMyung Bae inline void setLedState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 374*7066dc58SMyung Bae bool ledState, const boost::system::error_code& ec, 375*7066dc58SMyung Bae const std::string& ledGroupPath, 376*7066dc58SMyung Bae const std::string& service) 377*7066dc58SMyung Bae { 378*7066dc58SMyung Bae if (ec) 379*7066dc58SMyung Bae { 380*7066dc58SMyung Bae if (ec.value() == EBADR) 381*7066dc58SMyung Bae { 382*7066dc58SMyung Bae messages::propertyUnknown(asyncResp->res, 383*7066dc58SMyung Bae "LocationIndicatorActive"); 384*7066dc58SMyung Bae return; 385*7066dc58SMyung Bae } 386*7066dc58SMyung Bae BMCWEB_LOG_ERROR("DBUS response error {}", ec.value()); 387*7066dc58SMyung Bae messages::internalError(asyncResp->res); 388*7066dc58SMyung Bae return; 389*7066dc58SMyung Bae } 390*7066dc58SMyung Bae 391*7066dc58SMyung Bae if (ledGroupPath.empty() || service.empty()) 392*7066dc58SMyung Bae { 393*7066dc58SMyung Bae messages::propertyUnknown(asyncResp->res, "LocationIndicatorActive"); 394*7066dc58SMyung Bae return; 395*7066dc58SMyung Bae } 396*7066dc58SMyung Bae 397*7066dc58SMyung Bae setDbusProperty(asyncResp, "LocationIndicatorActive", service, ledGroupPath, 398*7066dc58SMyung Bae "xyz.openbmc_project.Led.Group", "Asserted", ledState); 399*7066dc58SMyung Bae } 400*7066dc58SMyung Bae 401*7066dc58SMyung Bae /** 402*7066dc58SMyung Bae * @brief Sets identify led group properties 403*7066dc58SMyung Bae * 404*7066dc58SMyung Bae * @param[in] asyncResp Shared pointer for generating response 405*7066dc58SMyung Bae * message. 406*7066dc58SMyung Bae * @param[in] objPath Object path on PIM 407*7066dc58SMyung Bae * @param[in] ledState LED state passed from request 408*7066dc58SMyung Bae * 409*7066dc58SMyung Bae * @return None. 410*7066dc58SMyung Bae */ 411*7066dc58SMyung Bae inline void setLocationIndicatorActive( 412*7066dc58SMyung Bae const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 413*7066dc58SMyung Bae const std::string& objPath, bool ledState) 414*7066dc58SMyung Bae { 415*7066dc58SMyung Bae BMCWEB_LOG_DEBUG("Set LocationIndicatorActive for {}", objPath); 416*7066dc58SMyung Bae getLedGroupPath( 417*7066dc58SMyung Bae asyncResp, objPath, 418*7066dc58SMyung Bae [asyncResp, ledState](const boost::system::error_code& ec, 419*7066dc58SMyung Bae const std::string& ledGroupPath, 420*7066dc58SMyung Bae const std::string& service) { 421*7066dc58SMyung Bae setLedState(asyncResp, ledState, ec, ledGroupPath, service); 422*7066dc58SMyung Bae }); 423*7066dc58SMyung Bae } 424*7066dc58SMyung Bae 4251c8fba97SJames Feist } // namespace redfish 426