From 2401fc41a59f6d71f67a8ef169b2a90c8473a82f Mon Sep 17 00:00:00 2001 From: srikanth simgamsetti Date: Mon, 12 May 2025 09:44:02 +0000 Subject: [PATCH 1/2] [ONEM-40903] Update LEDControl with the new LED states --- LEDControl/LEDControl.cpp | 57 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/LEDControl/LEDControl.cpp b/LEDControl/LEDControl.cpp index 075a8284fd..f173c095cf 100644 --- a/LEDControl/LEDControl.cpp +++ b/LEDControl/LEDControl.cpp @@ -39,7 +39,13 @@ #define FPD_LED_DEVICE_FACTORY_RESET "FACTORY_RESET" #define FPD_LED_DEVICE_USB_UPGRADE "USB_UPGRADE" #define FPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR "DOWNLOAD_ERROR" - +#define FPD_LED_DEVICE_BOOT_IN_PROGRESS "BOOT_IN_PROGRESS" +#define FPD_LED_DEVICE_COLDSTANDBY "COLDSTANDBY" +#define FPD_LED_DEVICE_PSU_FAILURE "PSU_FAILURE" +#define FPD_LED_DEVICE_WPS_SES_OVERLAP "WPS_SES_OVERLAP" +#define FPD_LED_DEVICE_IP_ACQUIRED "IP_ACQUIRED" +#define FPD_LED_DEVICE_NO_IP "NO_IP" +#define FPD_LED_DEVICE_RCU_COMMAND "RCU_COMMAND" namespace WPEFramework @@ -146,6 +152,13 @@ namespace WPEFramework if(states & (1< Date: Tue, 13 May 2025 13:16:07 +0530 Subject: [PATCH 2/2] [ONEM-40903] Update LEDControl.cpp and LEDControl.config --- LEDControl/LEDControl.config | 2 +- LEDControl/LEDControl.cpp | 192 ++++++++++++----------------------- 2 files changed, 65 insertions(+), 129 deletions(-) diff --git a/LEDControl/LEDControl.config b/LEDControl/LEDControl.config index 63f4cf0073..b5a2d771b3 100644 --- a/LEDControl/LEDControl.config +++ b/LEDControl/LEDControl.config @@ -1,4 +1,4 @@ -set (autostart false) +set (autostart ${PLUGIN_LEDCONTROL_AUTOSTART}) set (preconditions Platform) set (callsign "org.rdk.LEDControl") diff --git a/LEDControl/LEDControl.cpp b/LEDControl/LEDControl.cpp index f173c095cf..b9ed356fa8 100644 --- a/LEDControl/LEDControl.cpp +++ b/LEDControl/LEDControl.cpp @@ -36,9 +36,7 @@ #define FPD_LED_DEVICE_WPS_CONNECTING "WPS_CONNECTING" #define FPD_LED_DEVICE_WPS_CONNECTED "WPS_CONNECTED" #define FPD_LED_DEVICE_WPS_ERROR "WPS_ERROR" -#define FPD_LED_DEVICE_FACTORY_RESET "FACTORY_RESET" -#define FPD_LED_DEVICE_USB_UPGRADE "USB_UPGRADE" -#define FPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR "DOWNLOAD_ERROR" +#define FPD_LED_DEVICE_WIFI_ERROR "WIFI_ERROR" #define FPD_LED_DEVICE_BOOT_IN_PROGRESS "BOOT_IN_PROGRESS" #define FPD_LED_DEVICE_COLDSTANDBY "COLDSTANDBY" #define FPD_LED_DEVICE_PSU_FAILURE "PSU_FAILURE" @@ -144,21 +142,19 @@ namespace WPEFramework dsError_t err = dsFPGetSupportedLEDStates (&states); if (!err) { if(!states)supportedLEDStates.emplace_back(FPD_LED_DEVICE_NONE); - if(states & (1< stateToString = { + {dsFPD_LED_DEVICE_NONE, FPD_LED_DEVICE_NONE}, + {dsFPD_LED_DEVICE_ACTIVE, FPD_LED_DEVICE_ACTIVE}, + {dsFPD_LED_DEVICE_STANDBY, FPD_LED_DEVICE_STANDBY}, + {dsFPD_LED_DEVICE_WPS_CONNECTING, FPD_LED_DEVICE_WPS_CONNECTING}, + {dsFPD_LED_DEVICE_WPS_CONNECTED, FPD_LED_DEVICE_WPS_CONNECTED}, + {dsFPD_LED_DEVICE_WPS_ERROR, FPD_LED_DEVICE_WPS_ERROR}, + {dsFPD_LED_DEVICE_WIFI_ERROR, FPD_LED_DEVICE_WIFI_ERROR}, + {dsFPD_LED_DEVICE_BOOT_IN_PROGRESS, FPD_LED_DEVICE_BOOT_IN_PROGRESS}, + {dsFPD_LED_DEVICE_COLDSTANDBY, FPD_LED_DEVICE_COLDSTANDBY}, + {dsFPD_LED_DEVICE_PSU_FAILURE, FPD_LED_DEVICE_PSU_FAILURE}, + {dsFPD_LED_DEVICE_WPS_SES_OVERLAP, FPD_LED_DEVICE_WPS_SES_OVERLAP}, + {dsFPD_LED_DEVICE_IP_ACQUIRED, FPD_LED_DEVICE_IP_ACQUIRED}, + {dsFPD_LED_DEVICE_NO_IP, FPD_LED_DEVICE_NO_IP}, + {dsFPD_LED_DEVICE_RCU_COMMAND, FPD_LED_DEVICE_RCU_COMMAND}, + }; + auto it = stateToString.find(state); + if (it != stateToString.end()) { + response["state"] = it->second; + } else { LOGERR("Unsupported LEDState %d", state); LOGTRACEMETHODFIN(); return WPEFramework::Core::ERROR_BAD_REQUEST; @@ -273,69 +238,40 @@ namespace WPEFramework bool success = false; try { - dsFPDLedState_t state = dsFPD_LED_DEVICE_NONE; - if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_ACTIVE, strlen(FPD_LED_DEVICE_ACTIVE)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_ACTIVE)) ){ - state = dsFPD_LED_DEVICE_ACTIVE; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_STANDBY, strlen(FPD_LED_DEVICE_STANDBY)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_STANDBY)) ){ - state = dsFPD_LED_DEVICE_STANDBY; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_WPS_CONNECTING, strlen(FPD_LED_DEVICE_WPS_CONNECTING)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_WPS_CONNECTING))){ - state = dsFPD_LED_DEVICE_WPS_CONNECTING; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_WPS_CONNECTED, strlen(FPD_LED_DEVICE_WPS_CONNECTED)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_WPS_CONNECTED)) ){ - state = dsFPD_LED_DEVICE_WPS_CONNECTED; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_WPS_ERROR, strlen(FPD_LED_DEVICE_WPS_ERROR)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_WPS_ERROR)) ){ - state = dsFPD_LED_DEVICE_WPS_ERROR; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_FACTORY_RESET, strlen(FPD_LED_DEVICE_FACTORY_RESET)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_FACTORY_RESET)) ){ - state = dsFPD_LED_DEVICE_FACTORY_RESET; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_USB_UPGRADE, strlen(FPD_LED_DEVICE_USB_UPGRADE)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_USB_UPGRADE)) ){ - state = dsFPD_LED_DEVICE_USB_UPGRADE; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR, strlen(FPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR)) ){ - state = dsFPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_BOOT_IN_PROGRESS, strlen(FPD_LED_DEVICE_BOOT_IN_PROGRESS)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_BOOT_IN_PROGRESS)) ){ - state = dsFPD_LED_DEVICE_BOOT_IN_PROGRESS; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_COLDSTANDBY, strlen(FPD_LED_DEVICE_COLDSTANDBY)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_COLDSTANDBY)) ){ - state = dsFPD_LED_DEVICE_COLDSTANDBY; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_PSU_FAILURE, strlen(FPD_LED_DEVICE_PSU_FAILURE)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_PSU_FAILURE)) ){ - state = dsFPD_LED_DEVICE_PSU_FAILURE; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_WPS_SES_OVERLAP, strlen(FPD_LED_DEVICE_WPS_SES_OVERLAP)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_WPS_SES_OVERLAP)) ){ - state = dsFPD_LED_DEVICE_WPS_SES_OVERLAP; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_IP_ACQUIRED, strlen(FPD_LED_DEVICE_IP_ACQUIRED)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_IP_ACQUIRED)) ){ - state = dsFPD_LED_DEVICE_IP_ACQUIRED; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_NO_IP, strlen(FPD_LED_DEVICE_NO_IP)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_NO_IP)) ){ - state = dsFPD_LED_DEVICE_NO_IP; - } else if (0==strncmp(strLedState.c_str(), FPD_LED_DEVICE_RCU_COMMAND, strlen(FPD_LED_DEVICE_RCU_COMMAND)) && - (strlen(strLedState.c_str()) == strlen(FPD_LED_DEVICE_RCU_COMMAND)) ){ - state = dsFPD_LED_DEVICE_RCU_COMMAND; - } else { + static const std::unordered_map stateMap = { + {FPD_LED_DEVICE_ACTIVE, dsFPD_LED_DEVICE_ACTIVE}, + {FPD_LED_DEVICE_STANDBY, dsFPD_LED_DEVICE_STANDBY}, + {FPD_LED_DEVICE_WPS_CONNECTING, dsFPD_LED_DEVICE_WPS_CONNECTING}, + {FPD_LED_DEVICE_WPS_CONNECTED, dsFPD_LED_DEVICE_WPS_CONNECTED}, + {FPD_LED_DEVICE_WPS_ERROR, dsFPD_LED_DEVICE_WPS_ERROR}, + {FPD_LED_DEVICE_WIFI_ERROR, dsFPD_LED_DEVICE_WIFI_ERROR}, + {FPD_LED_DEVICE_BOOT_IN_PROGRESS, dsFPD_LED_DEVICE_BOOT_IN_PROGRESS}, + {FPD_LED_DEVICE_COLDSTANDBY, dsFPD_LED_DEVICE_COLDSTANDBY}, + {FPD_LED_DEVICE_PSU_FAILURE, dsFPD_LED_DEVICE_PSU_FAILURE}, + {FPD_LED_DEVICE_WPS_SES_OVERLAP, dsFPD_LED_DEVICE_WPS_SES_OVERLAP}, + {FPD_LED_DEVICE_IP_ACQUIRED, dsFPD_LED_DEVICE_IP_ACQUIRED}, + {FPD_LED_DEVICE_NO_IP, dsFPD_LED_DEVICE_NO_IP}, + {FPD_LED_DEVICE_RCU_COMMAND, dsFPD_LED_DEVICE_RCU_COMMAND} + }; + + auto it = stateMap.find(strLedState); + if (it == stateMap.end()) { //Invalid parameter LOGERR("UNKNOWN state : %s", strLedState.c_str()); LOGTRACEMETHODFIN(); return WPEFramework::Core::ERROR_BAD_REQUEST; } - if (dsFPD_LED_DEVICE_NONE!=state) { - LOGINFO("dsFPSetLEDState state:%s state:%d", strLedState.c_str(), state); - dsError_t err = dsFPSetLEDState (state); - if (!err) { - success = true; - } else { - LOGERR("dsFPSetLEDState returned error %d", err); - LOGTRACEMETHODFIN(); - return WPEFramework::Core::ERROR_ILLEGAL_STATE; - } - } + + dsFPDLedState_t state = it->second; + LOGINFO("dsFPSetLEDState state:%s state:%d", strLedState.c_str(), state); + dsError_t err = dsFPSetLEDState (state); + if (err == dsERR_NONE) { + success = true; + } else { + LOGERR("dsFPSetLEDState returned error %d", err); + LOGTRACEMETHODFIN(); + return WPEFramework::Core::ERROR_ILLEGAL_STATE; + } } catch (...) {