diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 00000000..8950612a --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,21 @@ +### Review Comment Linking Guidelines + +When writing review comments based on custom instructions located in .github/instructions/**.instructions.md, include a direct GitHub link to the exact violated guideline in the respective instruction file. Use the following format: + + Refer: https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/.instructions.md#guideline-section-name + +## Examples + +Refer: https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Plugin.instructions.md#interface-implementation + +Refer: https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Pluginlifecycle.instructions.md#deactivated + +Refer: https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Pluginimplementation.instructions.md#inter-plugin-communication + +Refer: https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Pluginmodule.instructions.md#module-name-convention + +Refer: https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Pluginconfig.instructions.md#plugin-configuration + +Refer: https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Plugincmake.instructions.md#namespace-usage + +Refer: https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/PluginOnboardingCompliance.instructions.md#coverity-scan-inclusion-and-test-workflow-updates-for-new-plugins diff --git a/.github/instructions/Plugin.instructions.md b/.github/instructions/Plugin.instructions.md new file mode 100644 index 00000000..6286c399 --- /dev/null +++ b/.github/instructions/Plugin.instructions.md @@ -0,0 +1,203 @@ +--- +description: Guidelines for C++ files and header files that share the same name as their parent folder. +applyTo: "**/*.cpp,**/*.h" +--- + +# Instructions summary + 1. [Interface Implementation](https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Plugin.instructions.md#interface-implementation) + 2. [Service Registration](https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Plugin.instructions.md#service-registration) + 3. [JSON-RPC Stub Registration](https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Plugin.instructions.md#json-rpc-stub-registration) + 4. [Handling Out-of-Process Plugin Failures](https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Plugin.instructions.md#handling-out-of-process-plugin-failures) + +### Interface Implementation + +### Requirement + +Each plugin must implement the appropriate Thunder interfaces. + +-> PluginHost::IPlugin – Mandatory for all plugins. + +-> PluginHost::IDispatcher or derive from PluginHost::JSONRPC – Mandatory If the plugin handles JSON-RPC. + +-> Custom interfaces (like IHdcpProfile for HdcpProfile plugin) must be added to ThunderInterfaces for RPC. + +-> PluginHost::IWeb – If the plugin handles web requests. + + +### Example + +```cpp +BEGIN_INTERFACE_MAP(HdcpProfile) + INTERFACE_ENTRY(PluginHost::IPlugin) + INTERFACE_ENTRY(PluginHost::IDispatcher) + INTERFACE_AGGREGATE(Exchange::IHdcpProfile, _hdcpProfile) +END_INTERFACE_MAP +``` + +### Service Registration + +### Requirement + +All Thunder services must be registered using the SERVICE_REGISTRATION macro with name, major, minor and patch versions of service. Register the service using the following macro: + +``` +SERVICE_REGISTRATION(ServiceName, MAJOR, MINOR, PATCH) +``` + +For better readability, it is always good to define the following plugin metadata which is not mandatory: + +- **Precondition** - List of Thunder subsystems that must be active in order for the plugin to activate. This can also be set in Plugin.conf.in file. + +- **Terminations** - List of Thunder subsystems that will cause the plugin to deactivate if they are marked inactive whilst the plugin is running. + +- **Controls** - List of the subsystems that are controlled by the plugin. + +### Example + +```cpp +namespace WPEFramework { + namespace { + static Plugin::Metadata metadata( + API_VERSION_NUMBER_MAJOR, + API_VERSION_NUMBER_MINOR, + API_VERSION_NUMBER_PATCH, + {}, // Preconditions + {}, // Terminations + {} // Controls + ); + } + + namespace Plugin { + // Register HdcpProfile service with Thunder + SERVICE_REGISTRATION(HdcpProfile,API_VERSION_NUMBER_MAJOR,API_VERSION_NUMBER_MINOR,API_VERSION_NUMBER_PATCH); + } +} +``` + +### JSON-RPC Stub Registration + +### Requirement + +If the plugin includes , , and and inherits from PluginHost::JsonRPC, then it provides JSON‑RPC support and uses autogenerated JSON‑RPC stubs. + +These autogenerated stubs are the Exchange::J* C++ classes (for example, Exchange::JHdcpProfile and JsonData_HdcpProfile.h) that are produced by the Thunder JSON‑RPC code generator from the IPluginName* interface headers; they expose the C++ interface over JSON‑RPC so you do not have to call Register() for each method manually. + +Plugins using autogenerated JSON-RPC stubs (Exchange::J* classes) must register and unregister them in Initialize() and Deinitialize() methods.It should not be done in constructor and destructor. + +In Initialize(): + +```cpp +Exchange::JHdcpProfile::Register(*this, _hdcpProfile); +``` + +In Deinitialize(): + +```cpp +Exchange::JHdcpProfile::Unregister(*this); +``` + +It is strongly recommended to use the autogenerated JSON-RPC stubs rather than registering the json-rpc methods manually as below. + +```cpp +RDKShell::RDKShell() + ... +{ + ..... + Register(RDKSHELL_METHOD_MOVE_TO_FRONT, &RDKShell::moveToFrontWrapper, this); + Register(RDKSHELL_METHOD_MOVE_TO_BACK, &RDKShell::moveToBackWrapper, this); + ... +} +``` + +### Handling Out-of-Process Plugin Failures + +### Requirement + +- If the plugin runs as out-of-process, then it should implement RPC::IRemoteConnection::INotification interface inside your plugin. + +### Example + +```cpp +class TestPlugin : public PluginHost::IPlugin, public PluginHost::JSONRPC { +private: + class Notification : public RPC::IRemoteConnection::INotification { + public: + explicit Notification(TestPlugin* parent) + : _parent(*parent) + { + ASSERT(parent != nullptr); + } + + ~Notification() override = default; + + Notification(Notification&&) = delete; + Notification(const Notification&) = delete; + Notification& operator=(Notification&&) = delete; + Notification& operator=(const Notification&) = delete; + + public: + void Activated(RPC::IRemoteConnection* /* connection */) override + { + } + void Deactivated(RPC::IRemoteConnection* connection) override + { + _parent.Deactivated(connection); + } + + BEGIN_INTERFACE_MAP(Notification) + INTERFACE_ENTRY(RPC::IRemoteConnection::INotification) + END_INTERFACE_MAP + + private: + TestPlugin& _parent; + }; + +public: + TestPlugin() + : _connectionId(0) + , _service(nullptr) + , _testPlugin(nullptr) + , _notification(this) + { + } + ~TestPlugin() override = default; + + TestPlugin(TestPlugin&&) = delete; + TestPlugin(const TestPlugin&) = delete; + TestPlugin& operator=(TestPlugin&&) = delete; + TestPlugin& operator=(const TestPlugin&) = delete; + + BEGIN_INTERFACE_MAP(TestPlugin) + INTERFACE_ENTRY(PluginHost::IPlugin) + INTERFACE_ENTRY(PluginHost::IDispatcher) + INTERFACE_AGGREGATE(Exchange::ITestPlugin, _testPlugin) + END_INTERFACE_MAP + +public: + // IPlugin methods + const string Initialize(PluginHost::IShell* service) override; + void Deinitialize(PluginHost::IShell* service) override; + string Information() const override; + +private: + void Deactivated(RPC::IRemoteConnection* connection); + +private: + uint32_t _connectionId; + PluginHost::IShell* _service; + Exchange::ITestPlugin* _testPlugin; + Core::Sink _notification; +}; +``` + +- It should be registered during Initialize() to get itself notified when the remote process connects or disconnects. + +### Example + +```cpp +const string TestPlugin::Initialize(PluginHost::IShell* service) +{ + // Register for COM-RPC connection/disconnection notifications + _service->Register(&_notification); +} +``` diff --git a/.github/instructions/PluginOnboardingCompliance.instructions.md b/.github/instructions/PluginOnboardingCompliance.instructions.md new file mode 100644 index 00000000..839ac4ca --- /dev/null +++ b/.github/instructions/PluginOnboardingCompliance.instructions.md @@ -0,0 +1,67 @@ +--- +applyTo: "CMakeLists.txt" +--- + +## Requirement + +### Coverity Scan Inclusion and Test Workflow Updates for New Plugins + +When adding a new plugin in `CMakeLists.txt`, you **must** also update the following to guarantee the plugin is included in all required test and Coverity analysis workflows: + +- **CI Workflow Files:** + - `L1-tests.yml` + - `L2-tests.yml` + - `L2-tests-oop.yml` +- **Coverity Build Script:** + - `cov_build.sh` + +**Example:** + +1. **CMake Plugin Registration Example** + + If you add your plugin in `CMakeLists.txt` as: + ```cmake + if (PLUGIN_RESOURCEMANAGER) + add_subdirectory(ResourceManager) + endif() + if (PLUGIN_MY_NEW_PLUGIN) + add_subdirectory(MyNewPlugin) + endif() + ``` +2. **Update Coverity Build Script** + + Add your plugin’s flag in the build command in `cov_build.sh`: + ```bash + cmake \ + -DPLUGIN_CORE=ON \ + -DPLUGIN_LEGACY=ON \ + # <-- NEW PLUGIN FLAG + -DPLUGIN_MY_NEW_PLUGIN=ON \ + . + ``` + This ensures Coverity runs on your new plugin. + +3. **Update Test Workflow YAMLs** + + Ensure each test workflow references your new plugin using the **DPLUGIN_** CMake flag in their build/test step. For example, in `L1-tests.yml`: + ```yaml + jobs: + build-test: + runs-on: ubuntu-22.04 + steps: + - name: Configure with new plugin + run: | + cmake \ + -DPLUGIN_CORE=ON \ + -DPLUGIN_MY_NEW_PLUGIN=ON \ + . + - name: Run tests + run: | + ctest + ``` + Repeat similar additions in `L2-tests.yml` and `L2-tests-oop.yml`. + +**Summary:** +Whenever a new plugin is registered via `CMakeLists.txt`, always update: +- `cov_build.sh` (add plugin flag to Coverity scan build step) +- All test CI workflows (`L1-tests.yml`, `L2-tests.yml`, `L2-tests-oop.yml`) to include your plugin flag so that your plugin’s code quality and tests are assured! diff --git a/.github/instructions/Plugincmake.instructions.md b/.github/instructions/Plugincmake.instructions.md new file mode 100644 index 00000000..c576a5e2 --- /dev/null +++ b/.github/instructions/Plugincmake.instructions.md @@ -0,0 +1,44 @@ +--- +applyTo: "**/CMakeLists.txt" +--- + +### NAMESPACE Usage + +### Requirement + +All CMake targets, install paths, export sets,find_package and references must use the ${NAMESPACE} variable instead of hardcoded framework names (e.g., WPEFrameworkCore, WPEFrameworkPlugins). +This ensures smooth upgrades (e.g., WPEFramework → Thunder) and prevents regressions. + +### Correct Example + +```cmake +set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) + +find_package(${NAMESPACE}Plugins REQUIRED) + +find_package(${NAMESPACE}Definitions REQUIRED) + +target_link_libraries(${MODULE_NAME} + PRIVATE + CompileSettingsDebug::CompileSettingsDebug + ${NAMESPACE}Plugins::${NAMESPACE}Plugins + ${NAMESPACE}Definitions::${NAMESPACE}Definitions) +``` + + +### Incorrect Example + +```cmake +set(MODULE_NAME WPEFramework${PLUGIN_NAME}) + +find_package(WPEFrameworkPlugins REQUIRED) + +find_package(WPEFrameworkDefinitions REQUIRED) + +target_link_libraries(${MODULE_NAME} + PRIVATE + CompileSettingsDebug::CompileSettingsDebug + WPEFrameworkPlugins::WPEFrameworkPlugins + WPEFrameworkDefinitions::WPEFrameworkDefinitions) +``` + diff --git a/.github/instructions/Pluginconfig.instructions.md b/.github/instructions/Pluginconfig.instructions.md new file mode 100644 index 00000000..fd7206af --- /dev/null +++ b/.github/instructions/Pluginconfig.instructions.md @@ -0,0 +1,49 @@ +--- +applyTo: "**/*.config,**/*.conf.in" +--- + +### Plugin Configuration + +### Requirement + +- Each plugin must define .conf.in file that includes the following mandatory properties: + + - **autostart**: Indicates whether the plugin should start automatically when the framework boots. This should be set to false by default. + + - **callsign**: A unique identifier used to reference the plugin within the framework. Every callsign must be defined with a prefix of org.rdk and it must be followed by the ENT Service name written in PascalCase (e.g., org.rdk.PersistentStore). + + - **Custom properties**: Any additional configuration parameters required by the plugin. These are passed during activation via PluginHost::IShell::ConfigLine(). The following structural configuration elements are commonly defined: + - startuporder - Specifies the order in which plugins are started, relative to others. + - precondition - If these aren't met, the plugin stays in the Preconditions state and activates automatically once they are satisfied. It is recommended to define the precondition if the plugin depends on other subsystems being active. + - mode - Defines the execution mode of the plugin. + +### Plugin Mode Determination + +If the plugin's mode is set to OFF, it is treated as in-process. + +If no mode is specified, the plugin defaults to in-process. + +If the mode is explicitly set to LOCAL, the plugin runs out-of-process. + +The plugin mode is configured in the plugin's CMakeLists.txt file. + +- **locator** - Update with the name of the library (.so) that contains the actual plugin Implementation code. + +### Example + +.conf.in + +``` +precondition = ["Platform"] +callsign = "org.rdk.HdcpProfile" +autostart = "@PLUGIN_HDCPPROFILE_AUTOSTART@" +startuporder = "@PLUGIN_HDCPPROFILE_STARTUPORDER@" + +configuration = JSON() +rootobject = JSON() + +rootobject.add("mode", "@PLUGIN_HDCPPROFILE_MODE@") +rootobject.add("locator", "lib@PLUGIN_IMPLEMENTATION@.so") + +configuration.add("root", rootobject) +``` diff --git a/.github/instructions/Pluginimplementation.instructions.md b/.github/instructions/Pluginimplementation.instructions.md new file mode 100644 index 00000000..0b31d9f6 --- /dev/null +++ b/.github/instructions/Pluginimplementation.instructions.md @@ -0,0 +1,256 @@ +--- +applyTo: "**/*Implementation.cpp,**/*Implementation.h,**/*.cpp,**/*.h" +--- + +# Instruction Summary + 1. [Inter-Plugin Communication](https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Pluginimplementation.instructions.md#inter-plugin-communication) + 2. [On-Demand Plugin Interface Acquisition](https://github.com/rdkcentral/entservices-peripherals/blob/develop/.github/instructions/Pluginimplementation.instructions.md#on-demand-plugin-interface-acquisition) + +### Inter-Plugin Communication + +### Requirement + +Plugins should use COM-RPC (e.g., use QueryInterfaceByCallsign or QueryInterface) to access other plugins. + +### Example + +Telemetry Plugin accessing UserSettings(via COM-RPC) through the IShell Interface API **QueryInterfaceByCallsign()** exposed for each Plugin - (Refer https://github.com/rdkcentral/entservices-infra/blob/7988b8a719e594782f041309ce2d079cf6f52863/Telemetry/TelemetryImplementation.cpp#L160 ) + +```cpp +_userSettingsPlugin = _service->QueryInterfaceByCallsign(USERSETTINGS_CALLSIGN); +``` + +QueryInterface: + +```cpp +_userSettingsPlugin = _service->QueryInterface(); +``` + +should not use JSON-RPC or LinkType for inter-plugin communication, as they introduce unnecessary overhead. + +### Incorrect Example + +LinkType: +```cpp +_telemetry = Core::ProxyType::Create(_T("org.rdk.telemetry"), _T(""), "token=" + token); +``` + +JSON-RPC: +```cpp +uint32_t ret = m_SystemPluginObj->Invoke(THUNDER_RPC_TIMEOUT, _T("getFriendlyName"), params, Result); +``` + +Use COM-RPC for plugin event registration by passing a C++ callback interface pointer for low-latency communication. It is important to register for StateChange notifications to monitor the notifying plugin's lifecycle. This allows you to safely release the interface pointer upon deactivation and prevents accessing a non-existent service. + +### Example + +**1. Initialize the Listener and Start Monitoring** + +```cpp +// Assuming you have a list of all target callsigns you want to monitor +const std::vector MonitoredCallsigns = { + "AudioTargetPlugin", + "NetworkTargetPlugin", + "InputTargetPlugin" +}; + +void Initialize(PluginHost::IShell* service) override { + + _service = service; + _service->AddRef(); + + // 1. Tell the Framework to send ALL state changes to *this* object + // This enables the StateChange() method to work for ALL plugins. + _service->Register(this); + + // 2. Check if the target plugins are ALREADY running (First-Time check) + for (const std::string& callsign : MonitoredCallsigns) { + + // Query the framework for the current instance of the target plugin + PluginHost::IShell* target = _service->QueryInterfaceByCallsign(callsign.c_str()); + + if (target != nullptr) { + // If the plugin is found and ACTIVATED, register immediately + if (target->State() == PluginHost::IShell::ACTIVATED) { + printf("LOG: Initial check found %s active. Registering events.\n", callsign.c_str()); + + // Use the multi-target registration method + RegisterWithTarget(callsign, target); + } + + // Release the IShell pointer obtained from QueryInterfaceByCallsign + target->Release(); + } + } +} +``` + +**2. Handle Activation (The Re-registration Step)** + +Always use if (plugin->Callsign() == "YourTargetCallsign") as the initial gate in your StateChange method. This guarantees that all subsequent logs and re-registration/cleanup logic are executed only for the plugin you are actively monitoring. + +```cpp +// StateChange() called when TargetPlugin comes online +void StateChange(PluginHost::IShell* plugin) override { + + const string& callsign = plugin->Callsign(); + + // --- Step 1: Handle DEACTIVATED (Cleanup) --- + if (plugin->State() == PluginHost::IShell::DEACTIVATED) { + + // Find if this specific callsign is in our map (if we were connected) + auto it = _targetPlugins.find(callsign); + + if (it != _targetPlugins.end()) { + printf("LOG: %s DEACTIVATED. Releasing interface.\n", callsign.c_str()); + + // Unregister and Release the specific pointer for this callsign + it->second->Unregister(this->QueryInterface()); + it->second->Release(); + + // Remove the entry from the map + _targetPlugins.erase(it); + } + } + + // --- Step 2: Handle ACTIVATED (Re-registration) --- + else if (plugin->State() == PluginHost::IShell::ACTIVATED) { + + // Use a list/set of monitored callsigns (e.g., {"Audio", "Network", "Input"}) + // Assuming 'isMonitoredPlugin(callsign)' is a method that checks your watchlist + if (isMonitoredPlugin(callsign)) { + + // Check if we are already connected (not found in the map) + if (_targetPlugins.find(callsign) == _targetPlugins.end()) { + + printf("LOG: %s ACTIVATED. Establishing new COM-RPC link.\n", callsign.c_str()); + + // Call the helper method to get the new pointer and register + RegisterWithTarget(callsign, plugin); + } + } + } +} +``` + +**3. COM-RPC Subscription** + +```cpp +void RegisterWithTarget(const string& callsign, PluginHost::IShell* plugin) { + + // 1. Get the new, valid interface pointer + Exchange::IMyTargetPlugin* newPtr = plugin->QueryInterface(); + + if (newPtr != nullptr) { + // 2. Register the callback + newPtr->Register(this->QueryInterface()); + + // 3. Store the new pointer in the map, indexed by callsign + _targetPlugins[callsign] = newPtr; + } +} +``` + +If the notifying plugin supports only JSON-RPC, then use a specialized smart link type when subscribing to its events. This method allows the framework to efficiently handle Plugin statechange events. + +### Example + +```cpp +/** + * @file Network.cpp + * @brief Example implementation showing JSON-RPC SmartLinkType setup and event subscription. + */ + +#define NETWORK_MANAGER_CALLSIGN "org.rdk.NetworkManager" + +void Initialize(PluginHost::IShell* service) override { + + // ... other initialization code ... + + // This state check ensures the environment is ready for JSON-RPC access. + if(PluginHost::IShell::state::ACTIVATED == state) + { + Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T("127.0.0.1:9998"))); + + // **SMART LINK TYPE INSTANTIATION:** + // This creates an object that acts as a client proxy for the JSON-RPC-only service. + // It handles sending JSON-RPC requests and receiving/deserializing JSON-RPC events. + // The type arguments specify the JSON interface (org.rdk.Network) and the CallSign. + m_networkmanager = make_shared >( + _T(NETWORK_MANAGER_CALLSIGN), + _T("org.rdk.Network"), + query + ); + + subscribeToEvents(); + } +} + +void Network::subscribeToEvents(void) { + uint32_t errCode = Core::ERROR_GENERAL; + + // Check if the smart link object was successfully created. + if (m_networkmanager) { + + if (!m_subsIfaceStateChange) { + + // **SMART LINK EVENT SUBSCRIPTION:** + // Using the SmartLinkType's Subscribe method, which internally constructs and + // sends the required JSON-RPC "Controller.1.subscribe" request to the target plugin. + // It automatically registers the local C++ callback (&Network::onInterfaceStateChange) + // to receive and process the JSON event payload. + errCode = m_networkmanager->Subscribe( + 5000, + _T("onInterfaceStateChange"), + &Network::onInterfaceStateChange + ); + + if (Core::ERROR_NONE == errCode) { + m_subsIfaceStateChange = true; + } else { + NMLOG_ERROR ("Subscribe to onInterfaceStateChange failed, errCode: %u", errCode); + } + } + } +} +``` + +### On-Demand Plugin Interface Acquisition + +### Requirement + +When a Thunder plugin needs to communicate with another plugin (via JSON-RPC or COM-RPC), do not create and hold the other plugin's interface instance throughout the plugin lifecycle. +Instead, create the instance only when needed and release it immediately after use. If the other plugin gets deactivated, your stored interface becomes stale. Calling methods on a stale interface leads to undefined behavior, crashes, or deadlocks. Thunder does not automatically invalidate your pointer when the remote plugin goes down. + +### Example + +```cpp +void MyPlugin::setNumber() { + .... + WPEFramework::Exchange::IOtherPlugin* other = shell->QueryInterfaceByCallsign("org.rdk.OtherPlugin"); + + if (other != nullptr) { + other->PerformAction(); + other->Release(); // Release immediately after use + } +} +``` + +### Incorrect Example + +```cpp +void MyPlugin::Initialize() { + _otherPlugin = shell->QueryInterfaceByCallsign(); +} + +void MyPlugin::Deinitialize() { + if (_otherPlugin) { + _otherPlugin->Release(); + _otherPlugin = nullptr; + } +} + +void MyPlugin::DoSomething() { + _otherPlugin->PerformAction(); // Risky if other plugin is deactivated! +} +``` diff --git a/.github/instructions/Pluginlifecycle.instructions.md b/.github/instructions/Pluginlifecycle.instructions.md new file mode 100644 index 00000000..27a0af8c --- /dev/null +++ b/.github/instructions/Pluginlifecycle.instructions.md @@ -0,0 +1,269 @@ +--- +description: Guidelines for C++ files and header files that share the same name as their parent folder. +applyTo: "**/*.cpp,**/*.h" +--- + + +### Mandatory Lifecycle Methods + +Every plugin must implement: + +- Initialize(IShell* service) → Called when the plugin is activated. + +- Deinitialize(IShell* service) → Called when the plugin is deactivated. + +### Initialization + +### Requirement + +- Initialize() must handle all setup logic; constructors should remain minimal. +- It must validate inputs and acquire necessary references. + +### Example + +```cpp +const string HdcpProfile::Initialize(PluginHost::IShell* service) { + ..... + if (_hdcpProfile != nullptr) { + ... + Exchange::IConfiguration* configure = _hdcpProfile->QueryInterface(); + ... + } + .... +} +``` + +- Plugin should register your listener object twice: + + - Framework Service (_service): Use _service->Register(listener) to receive general plugin state change notifications (like ACTIVATED/DEACTIVATED). + + Example: _service->Register(&_hdcpProfileNotification); + + - Target Plugin Interface (_hdcpProfile): Use _hdcpProfile->Register(listener) to receive the plugin's specific custom events (e.g., onProfileChanged).This registration serves as the internal bridge that captures C++ events from the implementation, allowing the plugin to translate and broadcast them as JSON-RPC notifications to external subscribers. + + Example: _hdcpProfile->Register(&_hdcpProfileNotification); + +- It must return a non-empty string on failure with a clear error message. + +**Example:** + +```cpp +const string HdcpProfile::Initialize(PluginHost::IShell* service) { + ... + message = _T("HdcpProfile could not be configured"); + ... + message = _T("HdcpProfile implementation did not provide a configuration interface"); + ... + message = _T("HdcpProfile plugin could not be initialized"); + ... +} +``` + +- Threads or async tasks should be started here if needed, with proper tracking. + +**Example:** + +```cpp +Core::hresult NativeJSImplementation::Initialize(string waylandDisplay) +{ + std::cout << "initialize called on nativejs implementation " << std::endl; + mRenderThread = std::thread([=](std::string waylandDisplay) { + mNativeJSRenderer = std::make_shared(waylandDisplay); + mNativeJSRenderer->run(); + std::cout << "After launch application execution ... " << std::endl; + mNativeJSRenderer.reset(); + }, waylandDisplay); + return (Core::ERROR_NONE); +} +``` + +- Before executing Initialize, ensure all private member variables are in a reset state (either initialized by the constructor or cleared by a prior Deinitialize). Validate this by asserting their default values. + +**Example:** + +```cpp +const string HdcpProfile::Initialize(PluginHost::IShell *service) +{ + ASSERT(_server == nullptr); + ASSERT(_impl == nullptr); + ASSERT(_connectionId == 0); +} +``` + +- If a plugin needs to keep the `IShell` pointer beyond the scope of `Initialize()` (for example, by storing it in a member variable to access other plugins via COM-RPC or JSON-RPC throughout the plugin's lifecycle), then it **must** call `AddRef()` on the service instance before storing it, to increment its reference count. If the plugin only uses the `service` pointer within `Initialize()` and does not store it for later use, then `AddRef()` **must not** be called on the `IShell` instance. + +**Example:** + +```cpp +const string HdcpProfile::Initialize(PluginHost::IShell *service) +{ + ... + _service = service; + _service->AddRef(); + // _service will be used to access other plugins via COM-RPC or JSON-RPC in later methods. + ... +} +``` + +- Only one Initialize() method must exist — avoid overloads or split logic. + +### Deinitialize and Cleanup + +### Requirement + +- Deinitialize() must clean up all resources acquired during Initialize(). It must release resources in reverse order of initialization. +- Every pointer or instance must be checked for nullptr before cleanup. + +**Example:** + +```cpp +void HdcpProfile::Deinitialize(PluginHost::IShell* service) { + ... + if (_service != nullptr) { + _service->Release(); + _service = nullptr; + } + ... +} +``` + +- All acquired interfaces must be explicitly Released(). + +**Example:** + +```cpp +void HdcpProfile::Deinitialize(PluginHost::IShell* service) { + ... + if (_hdcpProfile != nullptr) { + .... + // Release interface + RPC::IRemoteConnection* connection = service->RemoteConnection(_connectionId); + connection->Terminate(); + connection->Release(); + .... + } + ... +} +``` + +- Unregister your listener from both the Target Plugin interface and the Framework Shell before releasing the pointers. + +**Example:** + +```cpp +void HdcpProfile::Deinitialize(PluginHost::IShell* service) { + ... + // 1. Unregister from the Target Plugin (stops custom events) + if (_hdcpProfile != nullptr) { + _hdcpProfile->Unregister(&_hdcpProfileNotification); + } + // 2. Unregister from the Framework Shell (stops state change events) + if (_service != nullptr) { + _service->Unregister(&_hdcpProfileNotification); + } + ... +} +``` + +- Remote connections must be terminated after releasing plugin references. + +**Example:** + +```cpp +void HdcpProfile::Deinitialize(PluginHost::IShell* service) { + ... + if (_hdcpProfile != nullptr) { + .... + if (nullptr != connection) { + // Trigger the cleanup sequence for out-of-process code, + // which ensures that unresponsive processes are terminated + // if they do not stop gracefully. + connection->Terminate(); + connection->Release(); + } + .... + } +} +``` + +- Threads must be joined or safely terminated. + +**Example:** + +```cpp +Core::hresult NativeJSImplementation::Deinitialize() { + LOGINFO("deinitializing NativeJS process"); + if (mNativeJSRenderer) { + mNativeJSRenderer->terminate(); + if (mRenderThread.joinable()) { + mRenderThread.join(); + } + } + return (Core::ERROR_NONE); +} +``` + +- Internal state (e.g., _connectionId, _service) and private members should be reset to their default state. + +**Example:** + +```cpp +void HdcpProfile::Deinitialize(PluginHost::IShell* service) { + ... + if (connection != nullptr) { + connection->Terminate(); + connection->Release(); + } + ... + if (_service != nullptr) { + _service->Release(); + _service = nullptr; + } +} +``` + +- If AddRef() was called on the IShell instance in Initialize(), then it should call Release() on the IShell instance to decrement its reference count. + +**Example:** + +```cpp +void HdcpProfile::Deinitialize(PluginHost::IShell* service) { + ... + if (_service != nullptr) { + _service->Release(); + _service = nullptr; + } + ... +} +``` + +- All cleanup steps should be logged for traceability. + +**Example:** + +```cpp +void HdcpProfile::Deinitialize(PluginHost::IShell* service) { + ... + SYSLOG(Logging::Shutdown, (_T("HdcpProfile de-initialized"))); + ... +} +``` + + +### Deactivated + +Each plugin should implement the deactivated method. In Deactivated, it should be checked if remote connectionId matches your plugin's connectionId. If it matches your plugin's connectionId, the plugin should submit a deactivation job to handle the out-of-process failure gracefully. + +### Example + +```cpp +void XCast::Deactivated(RPC::IRemoteConnection *connection) +{ + if (connection->Id() == _connectionId) + { + ASSERT(nullptr != _service); + Core::IWorkerPool::Instance().Submit(PluginHost::IShell::Job::Create(_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::FAILURE)); + } +} +``` + diff --git a/.github/instructions/Pluginmodule.instructions.md b/.github/instructions/Pluginmodule.instructions.md new file mode 100644 index 00000000..2d636a9b --- /dev/null +++ b/.github/instructions/Pluginmodule.instructions.md @@ -0,0 +1,34 @@ +--- +applyTo: "**/Module.cpp,**/Module.h" +--- + + +### Module Name Convention + +### Requirement + +- Every plugin must define MODULE_NAME because Thunder uses it to identify the plugin. +- Every plugin must also define MODULE_NAME_DECLARATION() macro since it generates identifiers such as the module name string, SHA value, and version for the module, enabling the system to recognize and link it. +- The MODULE_NAME should always start with the prefix Plugin_. + +### Example + +1. In Module.h: + + ```cpp + // Rest of the code + #ifndef MODULE_NAME + #define MODULE_NAME Plugin_IOController + #endif + // Rest of the code + ``` + +2. In Module.cpp: + + ```cpp + #include "Module.h" + + MODULE_NAME_DECLARATION(BUILD_REFERENCE) + + // Rest of the code + ``` \ No newline at end of file diff --git a/.github/workflows/L1-tests.yml b/.github/workflows/L1-tests.yml index 1c7005f5..4736415e 100755 --- a/.github/workflows/L1-tests.yml +++ b/.github/workflows/L1-tests.yml @@ -13,10 +13,12 @@ on: env: BUILD_TYPE: Debug + REPO_NAME: "peripherals" THUNDER_REF: "R4.4.1" INTERFACES_REF: "develop" AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME}} AUTOMATICS_PASSCODE: ${{ secrets. AUTOMATICS_PASSCODE}} + ENABLE_CACHE: "false" jobs: L1-tests: @@ -40,30 +42,30 @@ jobs: # https://github.com/actions/cache # https://docs.github.com/en/rest/actions/cache # Modify the key if changing the list. - if: ${{ !env.ACT }} + if: ${{ !env.ACT && env.ENABLE_CACHE == 'true' }} id: cache uses: actions/cache@v3 with: path: | - thunder/build/Thunder - thunder/build/entservices-apis - thunder/build/ThunderTools - thunder/install - !thunder/install/etc/WPEFramework/plugins - !thunder/install/usr/bin/RdkServicesTest - !thunder/install/usr/include/gmock - !thunder/install/usr/include/gtest - !thunder/install/usr/lib/libgmockd.a - !thunder/install/usr/lib/libgmock_maind.a - !thunder/install/usr/lib/libgtestd.a - !thunder/install/usr/lib/libgtest_maind.a - !thunder/install/usr/lib/cmake/GTest - !thunder/install/usr/lib/pkgconfig/gmock.pc - !thunder/install/usr/lib/pkgconfig/gmock_main.pc - !thunder/install/usr/lib/pkgconfig/gtest.pc - !thunder/install/usr/lib/pkgconfig/gtest_main.pc - !thunder/install/usr/lib/wpeframework/plugins - key: ${{ runner.os }}-${{ env.THUNDER_REF }}-${{ env.INTERFACES_REF }}-4 + build/Thunder + build/entservices-apis + build/ThunderTools + install + !install/etc/WPEFramework/plugins + !install/usr/bin/RdkServicesTest + !install/usr/include/gmock + !install/usr/include/gtest + !install/usr/lib/libgmockd.a + !install/usr/lib/libgmock_maind.a + !install/usr/lib/libgtestd.a + !install/usr/lib/libgtest_maind.a + !install/usr/lib/cmake/GTest + !install/usr/lib/pkgconfig/gmock.pc + !install/usr/lib/pkgconfig/gmock_main.pc + !install/usr/lib/pkgconfig/gtest.pc + !install/usr/lib/pkgconfig/gtest_main.pc + !install/usr/lib/wpeframework/plugins + key: ${{ runner.os }}-${{ env.REPO_NAME }}-${{ env.THUNDER_REF }}-${{ env.INTERFACES_REF }}-4 - name: Set up Python uses: actions/setup-python@v4 @@ -103,7 +105,6 @@ jobs: sudo ninja -C build install - name: Checkout Thunder - if: steps.cache.outputs.cache-hit != 'true' uses: actions/checkout@v3 with: repository: rdkcentral/Thunder @@ -149,6 +150,7 @@ jobs: ref: v1.15.0 - name: Apply patches ThunderTools + if: steps.cache.outputs.cache-hit != 'true' run: | cd $GITHUB_WORKSPACE/ThunderTools patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/00010-R4.4-Add-support-for-project-dir.patch @@ -170,6 +172,7 @@ jobs: cmake --install build/ThunderTools - name: Apply patches Thunder + if: steps.cache.outputs.cache-hit != 'true' run: | cd $GITHUB_WORKSPACE/Thunder patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/Use_Legact_Alt_Based_On_ThunderTools_R4.4.3.patch @@ -198,7 +201,6 @@ jobs: cmake --install build/Thunder - name: Checkout entservices-apis - if: steps.cache.outputs.cache-hit != 'true' uses: actions/checkout@v3 with: repository: rdkcentral/entservices-apis @@ -406,8 +408,6 @@ jobs: -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/ccec/drivers -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/network -I $GITHUB_WORKSPACE/entservices-testframework/Tests - -I $GITHUB_WORKSPACE/Thunder/Source - -I $GITHUB_WORKSPACE/Thunder/Source/core -I $GITHUB_WORKSPACE/install/usr/include -I $GITHUB_WORKSPACE/install/usr/include/WPEFramework -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/devicesettings.h @@ -447,8 +447,6 @@ jobs: -DCMAKE_DISABLE_FIND_PACKAGE_RBus=ON -DCMAKE_BUILD_TYPE=Debug -DDS_FOUND=ON - -DHAS_FRONT_PANEL=ON - -DPLUGIN_FRONTPANEL=ON -DPLUGIN_MOTION_DETECTION=ON -DRDK_SERVICES_L1_TEST=ON -DUSE_THUNDER_R4=ON @@ -524,8 +522,6 @@ jobs: -DCMAKE_DISABLE_FIND_PACKAGE_RBus=ON -DCMAKE_BUILD_TYPE=Debug -DDS_FOUND=ON - -DHAS_FRONT_PANEL=ON - -DPLUGIN_FRONTPANEL=ON -DPLUGIN_MOTION_DETECTION=ON -DRDK_SERVICES_L1_TEST=ON -DUSE_THUNDER_R4=ON diff --git a/.github/workflows/L2-tests.yml b/.github/workflows/L2-tests.yml deleted file mode 100755 index a85b55a4..00000000 --- a/.github/workflows/L2-tests.yml +++ /dev/null @@ -1,622 +0,0 @@ -name: L2-tests - -on: - workflow_call: - inputs: - caller_source: - description: "Specifies the source type (e.g., local or test framework) for the workflow." - required: true - type: string - secrets: - RDKCM_RDKE: - required: true - -env: - BUILD_TYPE: Debug - THUNDER_REF: "R4.4.1" - INTERFACES_REF: "develop" - AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME}} - AUTOMATICS_PASSCODE: ${{ secrets. AUTOMATICS_PASSCODE}} - -jobs: - L2-tests: - name: Build and run L2 tests - runs-on: ubuntu-22.04 - strategy: - matrix: - compiler: [ gcc, clang ] - coverage: [ with-coverage, without-coverage ] - exclude: - - compiler: clang - coverage: with-coverage - - compiler: clang - coverage: without-coverage - - compiler: gcc - coverage: without-coverage - - steps: - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - run: pip install jsonref - - - name: ACK External Trigger - run: | - echo "Message: External Trigger Received for L2 Tests" - echo "Trigger Source: ${{ inputs.caller_source }}" - - - name: Set up CMake - uses: jwlawson/actions-setup-cmake@v1.13 - with: - cmake-version: '3.16.x' - - - name: Install packages - run: > - sudo apt update - && - sudo apt install -y libsqlite3-dev libcurl4-openssl-dev valgrind lcov clang libsystemd-dev libboost-all-dev libwebsocketpp-dev meson libcunit1 libcunit1-dev curl protobuf-compiler-grpc libgrpc-dev libgrpc++-dev libdbus-1-dev - - - name: Install GStreamer - run: | - sudo apt update - sudo apt install -y libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev - - - name: Build trower-base64 - run: | - if [ ! -d "trower-base64" ]; then - git clone https://github.com/xmidt-org/trower-base64.git - fi - cd trower-base64 - meson setup --warnlevel 3 --werror build - ninja -C build - sudo ninja -C build install - - - name: Checkout Thunder - uses: actions/checkout@v3 - with: - repository: rdkcentral/Thunder - path: Thunder - ref: ${{env.THUNDER_REF}} - - - name: Checkout ThunderTools - uses: actions/checkout@v3 - with: - repository: rdkcentral/ThunderTools - path: ThunderTools - ref: R4.4.3 - - - name: Checkout entservices-peripherals - if: ${{ inputs.caller_source == 'local' }} - uses: actions/checkout@v3 - with: - path: entservices-peripherals - - - name: Checkout entservices-peripherals-testframework - if: ${{ inputs.caller_source == 'testframework' }} - uses: actions/checkout@v3 - with: - repository: rdkcentral/entservices-peripherals - path: entservices-peripherals - ref: develop - - - name: Checkout entservices-testframework - uses: actions/checkout@v3 - with: - repository: rdkcentral/entservices-testframework - path: entservices-testframework - ref: develop - token: ${{ secrets.RDKCM_RDKE }} - - - name: Checkout googletest - if: steps.cache.outputs.cache-hit != 'true' - uses: actions/checkout@v3 - with: - repository: google/googletest - path: googletest - ref: v1.15.0 - - - name: Apply patches ThunderTools - run: | - cd $GITHUB_WORKSPACE/ThunderTools - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/00010-R4.4-Add-support-for-project-dir.patch - cd - - - - name: Build ThunderTools - run: > - cmake - -S "$GITHUB_WORKSPACE/ThunderTools" - -B build/ThunderTools - -DEXCEPTIONS_ENABLE=ON - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DGENERIC_CMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - && - cmake --build build/ThunderTools -j8 - && - cmake --install build/ThunderTools - - - name: Apply patches Thunder - run: | - cd $GITHUB_WORKSPACE/Thunder - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/Use_Legact_Alt_Based_On_ThunderTools_R4.4.3.patch - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/error_code_R4_4.patch - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/1004-Add-support-for-project-dir.patch - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/RDKEMW-733-Add-ENTOS-IDS.patch - cd - - - - name: Build Thunder - run: > - cmake - -S "$GITHUB_WORKSPACE/Thunder" - -B build/Thunder - -DMESSAGING=ON - -DHIDE_NON_EXTERNAL_SYMBOLS=OFF - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DBUILD_TYPE=${{env.BUILD_TYPE}} - -DBINDING=127.0.0.1 - -DPORT=9998 - -DEXCEPTIONS_ENABLE=ON - && - cmake --build build/Thunder -j8 - && - cmake --install build/Thunder - - - name: Checkout entservices-apis - uses: actions/checkout@v3 - with: - repository: rdkcentral/entservices-apis - path: entservices-apis - ref: ${{env.INTERFACES_REF}} - run: rm -rf $GITHUB_WORKSPACE/entservices-apis/jsonrpc/DTV.json - - - name: Apply patches entservices-apis - run: | - cd $GITHUB_WORKSPACE/entservices-apis - patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/RDKEMW-1007.patch - cd - - - - name: Build entservices-apis - run: > - cmake - -S "$GITHUB_WORKSPACE/entservices-apis" - -B build/entservices-apis - -DEXCEPTIONS_ENABLE=ON - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - && - cmake --build build/entservices-apis -j8 - && - cmake --install build/entservices-apis - - - name: Generate external headers - # Empty headers to mute errors - run: > - cd "$GITHUB_WORKSPACE/entservices-testframework/Tests/" - && - mkdir -p - headers - headers/audiocapturemgr - headers/rdk/ds - headers/rdk/iarmbus - headers/rdk/iarmmgrs-hal - headers/rdk/halif/ - headers/rdk/halif/deepsleep-manager - headers/ccec/drivers - headers/network - headers/proc - && - cd headers - && - touch - audiocapturemgr/audiocapturemgr_iarm.h - ccec/drivers/CecIARMBusMgr.h - rdk/ds/audioOutputPort.hpp - rdk/ds/compositeIn.hpp - rdk/ds/dsDisplay.h - rdk/ds/dsError.h - rdk/ds/dsMgr.h - rdk/ds/dsTypes.h - rdk/ds/dsUtl.h - rdk/ds/exception.hpp - rdk/ds/hdmiIn.hpp - rdk/ds/host.hpp - rdk/ds/list.hpp - rdk/ds/manager.hpp - rdk/ds/sleepMode.hpp - rdk/ds/videoDevice.hpp - rdk/ds/videoOutputPort.hpp - rdk/ds/videoOutputPortConfig.hpp - rdk/ds/videoOutputPortType.hpp - rdk/ds/videoResolution.hpp - rdk/ds/frontPanelIndicator.hpp - rdk/ds/frontPanelConfig.hpp - rdk/ds/frontPanelTextDisplay.hpp - rdk/ds/audioOutputPortType.hpp - rdk/ds/audioOutputPortConfig.hpp - rdk/ds/pixelResolution.hpp - rdk/iarmbus/libIARM.h - rdk/iarmbus/libIBus.h - rdk/iarmbus/libIBusDaemon.h - rdk/halif/deepsleep-manager/deepSleepMgr.h - rdk/iarmmgrs-hal/mfrMgr.h - rdk/iarmmgrs-hal/sysMgr.h - network/wifiSrvMgrIarmIf.h - network/netsrvmgrIarm.h - libudev.h - rfcapi.h - rbus.h - motionDetector.h - telemetry_busmessage_sender.h - maintenanceMGR.h - pkg.h - edid-parser.hpp - secure_wrapper.h - wpa_ctrl.h - proc/readproc.h - systemaudioplatform.h - gdialservice.h - gdialservicecommon.h - rdk/ds/audioOutputPort.hpp - rdk/ds/audioOutputPortType.hpp - rdk/ds/AudioStereoMode.hpp - rdk/ds/VideoDFC.hpp - && - cp -r /usr/include/gstreamer-1.0/gst /usr/include/glib-2.0/* /usr/lib/x86_64-linux-gnu/glib-2.0/include/* /usr/local/include/trower-base64/base64.h /usr/include/libdrm/drm.h /usr/include/libdrm/drm_mode.h /usr/include/xf86drm.h . - - - name: Set clang toolchain - if: ${{ matrix.compiler == 'clang' }} - run: echo "TOOLCHAIN_FILE=$GITHUB_WORKSPACE/entservices-testframework/Tests/clang.cmake" >> $GITHUB_ENV - - - name: Set gcc/with-coverage toolchain - if: ${{ matrix.compiler == 'gcc' && matrix.coverage == 'with-coverage' && !env.ACT }} - run: echo "TOOLCHAIN_FILE=$GITHUB_WORKSPACE/entservices-testframework/Tests/gcc-with-coverage.cmake" >> $GITHUB_ENV - - - name: Build googletest - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake -G Ninja - -S "$GITHUB_WORKSPACE/googletest" - -B build/googletest - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DGENERIC_CMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DBUILD_TYPE=Debug - -DBUILD_GMOCK=ON - -DBUILD_SHARED_LIBS=OFF - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - && - cmake --build build/googletest -j8 - && - cmake --install build/googletest - - - name: Build mocks - run: > - cmake - -S "$GITHUB_WORKSPACE/entservices-testframework/Tests/mocks" - -B build/mocks - -DBUILD_SHARED_LIBS=ON - -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - -DCMAKE_CXX_FLAGS=" - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers - -I $GITHUB_WORKSPACE/install/usr/include" - && - cmake --build build/mocks -j8 - && - cmake --install build/mocks - - - name: Build entservices-peripherals - run: > - cmake - -S "$GITHUB_WORKSPACE/entservices-peripherals" - -B build/entservices-peripherals - -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DHIDE_NON_EXTERNAL_SYMBOLS=OFF - -DCMAKE_CXX_FLAGS=" - -DEXCEPTIONS_ENABLE=ON - -fprofile-arcs - -ftest-coverage - -DUSE_THUNDER_R4=ON - -DTHUNDER_VERSION=4 - -DTHUNDER_VERSION_MAJOR=4 - -DTHUNDER_VERSION_MINOR=4 - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/audiocapturemgr - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmbus - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmmgrs-hal - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/ccec/drivers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/network - -I $GITHUB_WORKSPACE/entservices-testframework/Tests - -I $GITHUB_WORKSPACE/install/usr/include - -I $GITHUB_WORKSPACE/install/usr/include/WPEFramework - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/devicesettings.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Iarm.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Rfc.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/RBus.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Telemetry.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Udev.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/maintenanceMGR.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/pkg.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/secure_wrappermock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/wpa_ctrl_mock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/readprocMockInterface.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/gdialservice.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/MotionDetection.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/dsFPD.h - -Wall -Wno-unused-result -Wno-deprecated-declarations -Wno-error=format= - -DUSE_IARMBUS - -DRDK_SERVICE_L2_TEST - -DENABLE_SYSTEM_GET_STORE_DEMO_LINK - -DENABLE_DEEP_SLEEP - -DENABLE_SET_WAKEUP_SRC_CONFIG - -DENABLE_THERMAL_PROTECTION - -DUSE_DRM_SCREENCAPTURE - -DHAS_API_SYSTEM - -DHAS_API_POWERSTATE - -DHAS_RBUS - -DCLOCK_BRIGHTNESS_ENABLED - -DUSE_DS - -DENABLE_DEVICE_MANUFACTURER_INFO" - -DCOMCAST_CONFIG=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_DS=ON - -DCMAKE_DISABLE_FIND_PACKAGE_IARMBus=ON - -DCMAKE_DISABLE_FIND_PACKAGE_Udev=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RFC=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RBus=ON - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - -DDS_FOUND=ON - -DHAS_FRONT_PANEL=ON - -DPLUGIN_LEDCONTROL=ON - -DPLUGIN_FRONTPANEL=ON - -DPLUGIN_MOTION_DETECTION=ON - -DRDK_SERVICE_L2_TEST=ON - -DPLUGIN_L2Tests=ON - -DUSE_THUNDER_R4=ON - -DHIDE_NON_EXTERNAL_SYMBOLS=OFF - && - cmake --build build/entservices-peripherals -j8 - && - cmake --install build/entservices-peripherals - - - name: Build entservices-testframework - run: > - cmake - -S "$GITHUB_WORKSPACE/entservices-testframework" - -B build/entservices-testframework - -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/usr" - -DCMAKE_MODULE_PATH="$GITHUB_WORKSPACE/install/tools/cmake" - -DHIDE_NON_EXTERNAL_SYMBOLS=OFF - -DCMAKE_CXX_FLAGS=" - -DEXCEPTIONS_ENABLE=ON - -fprofile-arcs - -ftest-coverage - -DUSE_THUNDER_R4=ON - -DTHUNDER_VERSION=4 - -DTHUNDER_VERSION_MAJOR=4 - -DTHUNDER_VERSION_MINOR=4 - -DRDK_SERVICE_L2_TEST - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/audiocapturemgr - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/ds - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmbus - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/rdk/iarmmgrs-hal - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/ccec/drivers - -I $GITHUB_WORKSPACE/entservices-testframework/Tests/headers/network - -I $GITHUB_WORKSPACE/entservices-peripherals/helpers - -I $GITHUB_WORKSPACE/install/usr/include - -I $GITHUB_WORKSPACE/install/usr/include/WPEFramework - -I ./usr/include/libdrm - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/devicesettings.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Iarm.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Rfc.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/RBus.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Telemetry.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/Udev.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/maintenanceMGR.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/pkg.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/secure_wrappermock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/wpa_ctrl_mock.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/readprocMockInterface.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/gdialservice.h - -include $GITHUB_WORKSPACE/entservices-testframework/Tests/mocks/dsFPD.h - -Wall -Wno-unused-result -Wno-deprecated-declarations -Wno-error=format= - -Wl,-wrap,system -Wl,-wrap,syslog -Wl,--no-as-needed - -DENABLE_TELEMETRY_LOGGING - -DUSE_IARMBUS - -DENABLE_SYSTEM_GET_STORE_DEMO_LINK - -DENABLE_DEEP_SLEEP - -DENABLE_SET_WAKEUP_SRC_CONFIG - -DENABLE_THERMAL_PROTECTION - -DUSE_DRM_SCREENCAPTURE - -DHAS_API_SYSTEM - -DHAS_API_POWERSTATE - -DHAS_RBUS - -DCLOCK_BRIGHTNESS_ENABLED - -DUSE_DS - -DENABLE_DEVICE_MANUFACTURER_INFO" - -DCOMCAST_CONFIG=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_DS=ON - -DCMAKE_DISABLE_FIND_PACKAGE_IARMBus=ON - -DCMAKE_DISABLE_FIND_PACKAGE_Udev=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RFC=ON - -DCMAKE_DISABLE_FIND_PACKAGE_RBus=ON - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - -DDS_FOUND=ON - -DHAS_FRONT_PANEL=ON - -DPLUGIN_LEDCONTROL=ON - -DPLUGIN_FRONTPANEL=ON - -DPLUGIN_MOTION_DETECTION=ON - -DRDK_SERVICE_L2_TEST=ON - -DPLUGIN_L2Tests=ON - -DUSE_THUNDER_R4=ON - -DHIDE_NON_EXTERNAL_SYMBOLS=OFF - && - cmake --build build/entservices-testframework -j8 - && - cmake --install build/entservices-testframework - - - name: Set up files - run: > - sudo mkdir -p -m 777 - /tmp/test/testApp/etc/apps - /opt/persistent - /opt/secure - /opt/secure/reboot - /opt/secure/persistent - /opt/secure/persistent/System - /opt/logs - /lib/rdk - /run/media/sda1/logs/PreviousLogs - /run/sda1/UsbTestFWUpdate - /run/sda1/UsbProdFWUpdate - /run/sda2 - /var/run/wpa_supplicant - /tmp/bus/usb/devices/100-123 - /tmp/bus/usb/devices/101-124 - /tmp/block/sda/device - /tmp/block/sdb/device - /dev/disk/by-id - /dev - && - if [ ! -f mknod /dev/sda c 240 0 ]; then mknod /dev/sda c 240 0; fi && - if [ ! -f mknod /dev/sda1 c 240 0 ]; then mknod /dev/sda1 c 240 0; fi && - if [ ! -f mknod /dev/sda2 c 240 0 ]; then mknod /dev/sda2 c 240 0; fi && - if [ ! -f mknod /dev/sdb c 240 0 ]; then mknod /dev/sdb c 240 0; fi && - if [ ! -f mknod /dev/sdb1 c 240 0 ]; then mknod /dev/sdb1 c 240 0; fi && - if [ ! -f mknod /dev/sdb2 c 240 0 ]; then mknod /dev/sdb2 c 240 0; fi - && - sudo touch - /tmp/test/testApp/etc/apps/testApp_package.json - /opt/rdk_maintenance.conf - /opt/persistent/timeZoneDST - /opt/standbyReason.txt - /opt/tmtryoptout - /opt/fwdnldstatus.txt - /opt/dcm.properties - /etc/device.properties - /etc/dcm.properties - /etc/authService.conf - /version.txt - /run/media/sda1/logs/PreviousLogs/logFile.txt - /run/sda1/HSTP11MWR_5.11p5s1_VBN_sdy.bin - /run/sda1/UsbTestFWUpdate/HSTP11MWR_3.11p5s1_VBN_sdy.bin - /run/sda1/UsbProdFWUpdate/HSTP11MWR_4.11p5s1_VBN_sdy.bin - /lib/rdk/getMaintenanceStartTime.sh - /tmp/opkg.conf - /tmp/bus/usb/devices/100-123/serial - /tmp/bus/usb/devices/101-124/serial - /tmp/block/sda/device/vendor - /tmp/block/sda/device/model - /tmp/block/sdb/device/vendor - /tmp/block/sdb/device/model - && - sudo chmod -R 777 - /opt/rdk_maintenance.conf - /opt/persistent/timeZoneDST - /opt/standbyReason.txt - /opt/tmtryoptout - /opt/fwdnldstatus.txt - /opt/dcm.properties - /etc/device.properties - /etc/dcm.properties - /etc/authService.conf - /version.txt - /lib/rdk/getMaintenanceStartTime.sh - /tmp/opkg.conf - /tmp/bus/usb/devices/100-123/serial - /tmp/block/sda/device/vendor - /tmp/block/sda/device/model - /tmp/bus/usb/devices/101-124/serial - /tmp/block/sdb/device/vendor - /tmp/block/sdb/device/model - && - cd /dev/disk/by-id/ - && - sudo ln -s ../../sda /dev/disk/by-id/usb-Generic_Flash_Disk_B32FD507-0 - && - sudo ln -s ../../sdb /dev/disk/by-id/usb-JetFlash_Transcend_16GB_UEUIRCXT-0 - && - ls -l /dev/disk/by-id/usb-Generic_Flash_Disk_B32FD507-0 - && - ls -l /dev/disk/by-id/usb-JetFlash_Transcend_16GB_UEUIRCXT-0 - - - name: Download pact_verifier_cli - run: | - export PATH="$GITHUB_WORKSPACE/install/usr/bin:${PATH}" - $GITHUB_WORKSPACE/entservices-testframework/Tests/L2Tests/pact/install-verifier-cli.sh - - - name: Run unit tests without valgrind - run: > - PATH=$GITHUB_WORKSPACE/install/usr/bin:${PATH} - LD_LIBRARY_PATH=$GITHUB_WORKSPACE/install/usr/lib:$GITHUB_WORKSPACE/install/usr/lib/wpeframework/plugins:${LD_LIBRARY_PATH} - GTEST_OUTPUT="json:$(pwd)/rdkL2TestResults.json" - RdkServicesL2Test && - cp -rf $(pwd)/rdkL2TestResults.json $GITHUB_WORKSPACE/rdkL2TestResultsWithoutValgrind.json && - rm -rf $(pwd)/rdkL2TestResults.json - - - name: Run unit tests with valgrind - if: ${{ !env.ACT }} - run: > - PATH=$GITHUB_WORKSPACE/install/usr/bin:${PATH} - LD_LIBRARY_PATH=$GITHUB_WORKSPACE/install/usr/lib:$GITHUB_WORKSPACE/install/usr/lib/wpeframework/plugins:${LD_LIBRARY_PATH} - GTEST_OUTPUT="json:$(pwd)/rdkL2TestResults.json" - valgrind - --tool=memcheck - --log-file=valgrind_log - --leak-check=yes - --show-reachable=yes - --track-fds=yes - --fair-sched=try - RdkServicesL2Test && - cp -rf $(pwd)/rdkL2TestResults.json $GITHUB_WORKSPACE/rdkL2TestResultsWithValgrind.json && - rm -rf $(pwd)/rdkL2TestResults.json - - - name: Generate coverage - if: ${{ matrix.coverage == 'with-coverage' && !env.ACT }} - run: > - cp $GITHUB_WORKSPACE/entservices-testframework/Tests/L2Tests/.lcovrc_l2 ~/.lcovrc - && - lcov -c - -o coverage.info - -d build/entservices-peripherals - && - lcov - -r coverage.info - '/usr/include/*' - '*/build/entservices-peripherals/_deps/*' - '*/build/entservices-entservices-testframework/_deps/*' - '*/install/usr/include/*' - '*/Tests/headers/*' - '*/Tests/mocks/*' - '*/Tests/L2Tests/*' - '*/googlemock/*' - '*/googletest/*' - '*/sqlite/*' - -o filtered_coverage.info - && - genhtml - -o coverage - -t "entservices-peripherals coverage" - filtered_coverage.info - - - name: Upload artifacts - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: artifacts-L2-peripherals - path: | - coverage/ - valgrind_log - rdkL2TestResultsWithoutValgrind.json - rdkL2TestResultsWithValgrind.json - if-no-files-found: warn - diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml new file mode 100644 index 00000000..c58b1b0b --- /dev/null +++ b/.github/workflows/cla.yml @@ -0,0 +1,20 @@ +name: "CLA" + +permissions: + contents: read + pull-requests: write + actions: write + statuses: write + +on: + issue_comment: + types: [created] + pull_request_target: + types: [opened, closed, synchronize] + +jobs: + CLA-Lite: + name: "Signature" + uses: rdkcentral/cmf-actions/.github/workflows/cla.yml@v1 + secrets: + PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_ASSISTANT }} diff --git a/.github/workflows/component-release.yml b/.github/workflows/component-release.yml index 4a26990e..21a0a3ba 100644 --- a/.github/workflows/component-release.yml +++ b/.github/workflows/component-release.yml @@ -5,11 +5,24 @@ permissions: on: pull_request: - types: [closed] + types: [opened, edited, ready_for_review, closed] branches: - develop jobs: + validate-version: + if: ${{ github.event.action == 'opened' || github.event.action == 'edited' || github.event.action == 'ready_for_review' }} + runs-on: ubuntu-latest + steps: + - name: Validate PR description for version field + env: + PR_DESC: ${{ github.event.pull_request.body }} + run: | + if ! echo "$PR_DESC" | grep -qiE 'version[[:space:]]*:[[:space:]]*(major|minor|patch)'; then + echo "ERROR: PR description must include a version field in the format 'version: major|minor|patch' (case-insensitive). Example: version: minor" + exit 1 + fi + echo "Validation passed: version field found." release: if: github.event.pull_request.merged == true runs-on: ubuntu-latest @@ -21,7 +34,7 @@ jobs: - name: Set up Git run: | git config --global user.name "GitHub Actions" - git config --global user.email "actions@github.com" + git config --global user.email "187267378+rdkcm-rdke@users.noreply.github.com" - name: Install git-flow and auto-changelog run: | diff --git a/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml b/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml index 3cf44781..7b8c1cba 100644 --- a/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml +++ b/.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml @@ -1,12 +1,19 @@ name: Fossid Stateless Diff Scan -on: pull_request +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + pull-requests: read jobs: call-fossid-workflow: - uses: rdkcentral/build_tools_workflows/.github/workflows/fossid_integration_stateless_diffscan.yml@develop - secrets: + if: ${{ ! github.event.pull_request.head.repo.fork }} + uses: rdkcentral/build_tools_workflows/.github/workflows/fossid_integration_stateless_diffscan.yml@1.0.0 + secrets: FOSSID_CONTAINER_USERNAME: ${{ secrets.FOSSID_CONTAINER_USERNAME }} FOSSID_CONTAINER_PASSWORD: ${{ secrets.FOSSID_CONTAINER_PASSWORD }} FOSSID_HOST_USERNAME: ${{ secrets.FOSSID_HOST_USERNAME }} - FOSSID_HOST_TOKEN: ${{ secrets.FOSSID_HOST_TOKEN }} \ No newline at end of file + FOSSID_HOST_TOKEN: ${{ secrets.FOSSID_HOST_TOKEN }} diff --git a/.github/workflows/tests-trigger.yml b/.github/workflows/tests-trigger.yml index bb3de6af..741bdfa4 100755 --- a/.github/workflows/tests-trigger.yml +++ b/.github/workflows/tests-trigger.yml @@ -16,9 +16,4 @@ jobs: secrets: RDKCM_RDKE: ${{ secrets.RDKCM_RDKE }} - trigger-L2: - uses: ./.github/workflows/L2-tests.yml - with: - caller_source: local - secrets: - RDKCM_RDKE: ${{ secrets.RDKCM_RDKE }} + diff --git a/CHANGELOG.md b/CHANGELOG.md index 76ac79b6..5909c364 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,161 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.6.0](https://github.com/rdkcentral/entservices-peripherals/compare/1.5.1...1.6.0) + +- RDKEMW-12197: Integrate entservices-remotecontrol and entservices-voicecontrol to MW builds [`#134`](https://github.com/rdkcentral/entservices-peripherals/pull/134) +- Merge tag '1.5.1' into develop [`a0d25b4`](https://github.com/rdkcentral/entservices-peripherals/commit/a0d25b4282630164bc1e6ec6dbc99ef3521b53b4) + +#### [1.5.1](https://github.com/rdkcentral/entservices-peripherals/compare/1.5.0...1.5.1) + +> 27 February 2026 + +- RDKEMW-12639 - README update [`#139`](https://github.com/rdkcentral/entservices-peripherals/pull/139) +- 1.5.1 release changelog updates [`8c8bfd7`](https://github.com/rdkcentral/entservices-peripherals/commit/8c8bfd71cab238a1c05413463739a5f65c0db43d) +- Merge tag '1.5.0' into develop [`0c2f3fe`](https://github.com/rdkcentral/entservices-peripherals/commit/0c2f3fed35bcf2de1dbcc6937a3e60571b299f63) + +#### [1.5.0](https://github.com/rdkcentral/entservices-peripherals/compare/1.4.0...1.5.0) + +> 27 February 2026 + +- RDKEMW-14703: Disable Setup Cache in peripherals [`#138`](https://github.com/rdkcentral/entservices-peripherals/pull/138) +- 1.5.0 release changelog updates [`b2088c0`](https://github.com/rdkcentral/entservices-peripherals/commit/b2088c0d30cf20aabce096f7feca84a44adb63d8) +- Merge tag '1.4.0' into develop [`6bfe5e1`](https://github.com/rdkcentral/entservices-peripherals/commit/6bfe5e1d97d642bbb08a4079f9e7d6115b5600b4) + +#### [1.4.0](https://github.com/rdkcentral/entservices-peripherals/compare/1.3.0...1.4.0) + +> 23 February 2026 + +- RDKEMW-11931 : Fix Coverity identified issues - entservices-peripherals [`#128`](https://github.com/rdkcentral/entservices-peripherals/pull/128) +- 1.4.0 release changelog updates [`9ff97ef`](https://github.com/rdkcentral/entservices-peripherals/commit/9ff97efa2d620ca79841e26af25c488afd9be578) +- Merge tag '1.3.0' into develop [`79b6bd1`](https://github.com/rdkcentral/entservices-peripherals/commit/79b6bd111f9c263c205b4fa634c7a88f38f187d1) + +#### [1.3.0](https://github.com/rdkcentral/entservices-peripherals/compare/1.2.2...1.3.0) + +> 20 February 2026 + +- Add cache changes for successful cache upload and cache hit, Add support for COMRPC L2Tests plugin [`#127`](https://github.com/rdkcentral/entservices-peripherals/pull/127) +- 1.3.0 release changelog updates [`626bccc`](https://github.com/rdkcentral/entservices-peripherals/commit/626bccc6731a57446ed813aa8938db8eb327a223) +- Merge tag '1.2.2' into develop [`e494767`](https://github.com/rdkcentral/entservices-peripherals/commit/e49476762415e90d4aca563753308cb557f9ac35) + +#### [1.2.2](https://github.com/rdkcentral/entservices-peripherals/compare/1.2.1...1.2.2) + +> 16 February 2026 + +- RDKEMW-12801: Integrate entservices-ledcontrol [`#132`](https://github.com/rdkcentral/entservices-peripherals/pull/132) +- 1.2.2 release changelog updates [`538c77f`](https://github.com/rdkcentral/entservices-peripherals/commit/538c77f951711aa7ff2e95687b7ede957e3f4748) +- Merge tag '1.2.1' into develop [`84364a2`](https://github.com/rdkcentral/entservices-peripherals/commit/84364a2d9b0a5a55e904dbddc24cf0d584461e78) + +#### [1.2.1](https://github.com/rdkcentral/entservices-peripherals/compare/1.2.0...1.2.1) + +> 4 February 2026 + +- RDKEMW-12639: Integration of frontpanel plugin to new repo [`#131`](https://github.com/rdkcentral/entservices-peripherals/pull/131) +- 1.2.1 release changelog updates [`87aa9ea`](https://github.com/rdkcentral/entservices-peripherals/commit/87aa9ea07a2a0c46860aa209faf66add33ac4f1c) +- Merge tag '1.2.0' into develop [`d4e2764`](https://github.com/rdkcentral/entservices-peripherals/commit/d4e2764ff5946314540614213b431a84a6657597) + +#### [1.2.0](https://github.com/rdkcentral/entservices-peripherals/compare/1.1.1...1.2.0) + +> 12 January 2026 + +- RDKEMW-12159: Port firmware OTA APIs to entservices-peripherals [`#130`](https://github.com/rdkcentral/entservices-peripherals/pull/130) +- 1.2.0 release changelog updates [`eb06dc3`](https://github.com/rdkcentral/entservices-peripherals/commit/eb06dc3a9de09e9d9270ec600468591d5f79b284) +- Merge tag '1.1.1' into develop [`5196b2b`](https://github.com/rdkcentral/entservices-peripherals/commit/5196b2b806876964c98309f9dc71f6bfe279a21a) + +#### [1.1.1](https://github.com/rdkcentral/entservices-peripherals/compare/1.1.0...1.1.1) + +> 24 December 2025 + +- RDKEMW-11903: Add custom coding guidelines for entservices-repos [`#126`](https://github.com/rdkcentral/entservices-peripherals/pull/126) +- 1.1.1 release changelog updates [`80994e4`](https://github.com/rdkcentral/entservices-peripherals/commit/80994e40c973f0c6b6c96c375622b802890bbe8c) +- Merge tag '1.1.0' into develop [`39b889c`](https://github.com/rdkcentral/entservices-peripherals/commit/39b889ccac827d85e784c946f5e89eb310610ccd) + +#### [1.1.0](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.20...1.1.0) + +> 3 December 2025 + +- RDKEMW-10493 : Fix the uninitialized variables and static code analysis issues [`#121`](https://github.com/rdkcentral/entservices-peripherals/pull/121) +- 1.1.0 release changelog updates [`71eede3`](https://github.com/rdkcentral/entservices-peripherals/commit/71eede37dd79ca00caafa8fd455c13f9170ab144) +- Merge tag '1.0.20' into develop [`980c1a0`](https://github.com/rdkcentral/entservices-peripherals/commit/980c1a0306ed122df24813610f9a522dd68bffbc) + +#### [1.0.20](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.19...1.0.20) + +> 26 November 2025 + +- RDKEMW-9347 - Linking Librarly for FrontPanel [`#114`](https://github.com/rdkcentral/entservices-peripherals/pull/114) +- 1.0.20 release changelog updates [`77434ac`](https://github.com/rdkcentral/entservices-peripherals/commit/77434acdd81fd5de737e66b42ce985c664013d5a) +- Merge tag '1.0.19' into develop [`e67bc42`](https://github.com/rdkcentral/entservices-peripherals/commit/e67bc42596d570f78599550fb46fd6c55d71b51e) + +#### [1.0.19](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.18...1.0.19) + +> 19 November 2025 + +- RDKEMW-10094: Update component-release.yml [`#118`](https://github.com/rdkcentral/entservices-peripherals/pull/118) +- 1.0.19 release changelog updates [`1c85dc5`](https://github.com/rdkcentral/entservices-peripherals/commit/1c85dc58b4f16ceb543968c1c550418e6fde9506) +- Merge tag '1.0.18' into develop [`2076989`](https://github.com/rdkcentral/entservices-peripherals/commit/2076989dcac4de7fd970c39480bf4b5cc2b39380) + +#### [1.0.18](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.17...1.0.18) + +> 17 November 2025 + +- RDKEMW-10094: Update component-release.yml [`#113`](https://github.com/rdkcentral/entservices-peripherals/pull/113) +- 1.0.18 release changelog updates [`93924a6`](https://github.com/rdkcentral/entservices-peripherals/commit/93924a6ef9e5eaf30ce84cd51ac6b2a12995b47f) +- Merge tag '1.0.17' into develop [`ed0e01a`](https://github.com/rdkcentral/entservices-peripherals/commit/ed0e01aa3751ee164817473ad74f014b4ec488b6) + +#### [1.0.17](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.16...1.0.17) + +> 14 October 2025 + +- RDKEMW-7617 - Range in 'getFrontPanelLights' api [`#110`](https://github.com/rdkcentral/entservices-peripherals/pull/110) +- 1.0.17 release changelog updates [`65919de`](https://github.com/rdkcentral/entservices-peripherals/commit/65919de8f736cf6cc91b3b9e367fb212792dc219) +- Merge tag '1.0.16' into develop [`847dad9`](https://github.com/rdkcentral/entservices-peripherals/commit/847dad9c9880694b90aee886c14b1fe8e463b91f) + +#### [1.0.16](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.15...1.0.16) + +> 29 September 2025 + +- RDKEMW-7784: FrontPanel GTest [`#105`](https://github.com/rdkcentral/entservices-peripherals/pull/105) +- 1.0.16 release changelog updates [`e9150e2`](https://github.com/rdkcentral/entservices-peripherals/commit/e9150e27bbab5791b5b15f7b39bcd675051bc9a5) +- Merge tag '1.0.15' into develop [`5ac2b8d`](https://github.com/rdkcentral/entservices-peripherals/commit/5ac2b8daa85ead4f6d37d80edf8d46ff9850472e) + +#### [1.0.15](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.14...1.0.15) + +> 29 September 2025 + +- Deploy fossid_integration_stateless_diffscan_target_repo action [`#108`](https://github.com/rdkcentral/entservices-peripherals/pull/108) +- 1.0.15 release changelog updates [`5226065`](https://github.com/rdkcentral/entservices-peripherals/commit/52260657083f82fca9fd78b8ce12fad7651fe76c) +- Merge tag '1.0.14' into develop [`ddc2174`](https://github.com/rdkcentral/entservices-peripherals/commit/ddc2174a0cc19d38b991f2be56a6db230c8bf209) + +#### [1.0.14](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.13...1.0.14) + +> 26 September 2025 + +- Deploy cla action [`#57`](https://github.com/rdkcentral/entservices-peripherals/pull/57) +- 1.0.14 release changelog updates [`919d5f1`](https://github.com/rdkcentral/entservices-peripherals/commit/919d5f12841c426362e37b4a1af22f02c9d3a260) +- Merge tag '1.0.13' into develop [`4617dc1`](https://github.com/rdkcentral/entservices-peripherals/commit/4617dc1beafb0a36f032d0794cea9571b8d3af3f) + +#### [1.0.13](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.12...1.0.13) + +> 24 September 2025 + +- RDKEMW-3789: refactor LEDControl to align with proper HAL STATES and interface header changes [`#93`](https://github.com/rdkcentral/entservices-peripherals/pull/93) +- 1.0.13 release changelog updates [`99e644a`](https://github.com/rdkcentral/entservices-peripherals/commit/99e644a207c332d06ebb07f90e70a99767b3b42f) +- Merge tag '1.0.12' into develop [`85d77b1`](https://github.com/rdkcentral/entservices-peripherals/commit/85d77b1ce14a91000d12af2ec463317a9d236e47) + +#### [1.0.12](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.11...1.0.12) + +> 15 September 2025 + +- Feature/rdkemw 1013 comrpc [`#62`](https://github.com/rdkcentral/entservices-peripherals/pull/62) +- 1.0.12 release changelog updates [`9315eda`](https://github.com/rdkcentral/entservices-peripherals/commit/9315eda4371364465c4c17d3ec6863db5d93a84d) +- Merge tag '1.0.11' into develop [`e6cd4f3`](https://github.com/rdkcentral/entservices-peripherals/commit/e6cd4f3e90b962c3bb92a078c99791d7f0635f5f) + #### [1.0.11](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.10...1.0.11) +> 4 September 2025 + - Feature/rdkemw 7169 [`#96`](https://github.com/rdkcentral/entservices-peripherals/pull/96) +- 1.0.11 release changelog updates [`e292eb6`](https://github.com/rdkcentral/entservices-peripherals/commit/e292eb64bb5f1e5c382da0d15c74703734f4ae8b) - Merge tag '1.0.10' into develop [`d9e3835`](https://github.com/rdkcentral/entservices-peripherals/commit/d9e3835e2e8686223c754cdd0576f5d252c88729) #### [1.0.10](https://github.com/rdkcentral/entservices-peripherals/compare/1.0.9...1.0.10) diff --git a/CMakeLists.txt b/CMakeLists.txt index d366881f..cbc95714 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,28 +40,14 @@ if(RDK_SERVICES_L1_TEST) add_subdirectory(Tests/L1Tests) endif() -if(RDK_SERVICE_L2_TEST) - add_subdirectory(Tests/L2Tests) -endif() - -if(PLUGIN_VOICECONTROL) - add_subdirectory(VoiceControl) -endif() - -if(PLUGIN_REMOTECONTROL) - add_subdirectory(RemoteControl) -endif() - -if(PLUGIN_FRONTPANEL) - add_subdirectory(FrontPanel) -endif() if(PLUGIN_MOTION_DETECTION) add_subdirectory(MotionDetection) endif() -if(PLUGIN_LEDCONTROL) - add_subdirectory(LEDControl) +# Add a dummy install target to prevent cmake install failures when no plugins are enabled. This is needed temporarily while plugins are moved to other repos. +if(NOT RDK_SERVICES_L1_TEST AND NOT PLUGIN_MOTION_DETECTION) + install(CODE "message(STATUS \"entservices-peripherals: No install target available, ignoring...\")") endif() if(WPEFRAMEWORK_CREATE_IPKG_TARGETS) diff --git a/FrontPanel/CHANGELOG.md b/FrontPanel/CHANGELOG.md deleted file mode 100644 index 2e200c40..00000000 --- a/FrontPanel/CHANGELOG.md +++ /dev/null @@ -1,16 +0,0 @@ -# Changelog - -All notable changes to this RDK Service will be documented in this file. - -* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. - -* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - * **Added** for new features. - * **Changed** for changes in existing functionality. - * **Deprecated** for soon-to-be removed features. - * **Removed** for now removed features. - * **Fixed** for any bug fixes. - * **Security** in case of vulnerabilities. - -* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. - diff --git a/FrontPanel/CMakeLists.txt b/FrontPanel/CMakeLists.txt deleted file mode 100644 index 45b5a5f4..00000000 --- a/FrontPanel/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(PLUGIN_NAME FrontPanel) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) - -set(PLUGIN_FRONTPANEL_STARTUPORDER "" CACHE STRING "To configure startup order of FrontPanel plugin") - -find_package(${NAMESPACE}Plugins REQUIRED) - -add_library(${MODULE_NAME} SHARED - FrontPanel.cpp - Module.cpp - ../helpers/frontpanel.cpp) - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) -set_source_files_properties(FrontPanel.cpp ../helpers/frontpanel.cpp PROPERTIES COMPILE_FLAGS "-fexceptions") - -target_compile_definitions(${MODULE_NAME} PRIVATE MODULE_NAME=Plugin_${PLUGIN_NAME}) - -find_package(DS) -if (DS_FOUND) - find_package(IARMBus) - add_definitions(-DDS_FOUND) - target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS}) - target_include_directories(${MODULE_NAME} PRIVATE ${DS_INCLUDE_DIRS}) - target_include_directories(${MODULE_NAME} PRIVATE ../helpers) - target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${DS_LIBRARIES}) -# target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${DS_LIBRARIES}) -else (DS_FOUND) - target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins) -endif(DS_FOUND) - -#target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins) - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/FrontPanel/FrontPanel.conf.in b/FrontPanel/FrontPanel.conf.in deleted file mode 100644 index 99ac9de0..00000000 --- a/FrontPanel/FrontPanel.conf.in +++ /dev/null @@ -1,4 +0,0 @@ -precondition = ["Platform"] -callsign = "org.rdk.FrontPanel" -autostart = "false" -startuporder = "@PLUGIN_FRONTPANEL_STARTUPORDER@" diff --git a/FrontPanel/FrontPanel.config b/FrontPanel/FrontPanel.config deleted file mode 100644 index 37914fe3..00000000 --- a/FrontPanel/FrontPanel.config +++ /dev/null @@ -1,7 +0,0 @@ -set (autostart false) -set (preconditions Platform) -set (callsign "org.rdk.FrontPanel") - -if(PLUGIN_FRONTPANEL_STARTUPORDER) -set (startuporder ${PLUGIN_FRONTPANEL_STARTUPORDER}) -endif() diff --git a/FrontPanel/FrontPanel.cpp b/FrontPanel/FrontPanel.cpp deleted file mode 100644 index a459b36c..00000000 --- a/FrontPanel/FrontPanel.cpp +++ /dev/null @@ -1,969 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "FrontPanel.h" -#include "frontpanel.h" -#include - -#include "frontPanelIndicator.hpp" -#include "frontPanelConfig.hpp" -#include "frontPanelTextDisplay.hpp" - -#include "libIBus.h" - -#include "UtilsJsonRpc.h" -#include "UtilsIarm.h" - -#define SERVICE_NAME "FrontPanelService" -#define METHOD_FP_SET_BRIGHTNESS "setBrightness" -#define METHOD_FP_GET_BRIGHTNESS "getBrightness" -#define METHOD_FP_POWER_LED_ON "powerLedOn" -#define METHOD_FP_POWER_LED_OFF "powerLedOff" -#define METHOD_CLOCK_SET_BRIGHTNESS "setClockBrightness" -#define METHOD_CLOCK_GET_BRIGHTNESS "getClockBrightness" -#define METHOD_GET_FRONT_PANEL_LIGHTS "getFrontPanelLights" -#define METHOD_FP_GET_PREFERENCES "getPreferences" -#define METHOD_FP_SET_PREFERENCES "setPreferences" -#define METHOD_FP_SET_LED "setLED" -#define METHOD_FP_SET_BLINK "setBlink" -#define METHOD_FP_SET_24_HOUR_CLOCK "set24HourClock" -#define METHOD_FP_IS_24_HOUR_CLOCK "is24HourClock" -#define METHOD_FP_SET_CLOCKTESTPATTERN "setClockTestPattern" - -#define DATA_LED "data_led" -#define RECORD_LED "record_led" -#define POWER_LED "power_led" -#ifdef CLOCK_BRIGHTNESS_ENABLED -#define CLOCK_LED "clock_led" -#define TEXT_LED "Text" -#endif - -#ifdef USE_EXTENDED_ALL_SEGMENTS_TEXT_PATTERN -#define ALL_SEGMENTS_TEXT_PATTERN "88:88" -#else -#define ALL_SEGMENTS_TEXT_PATTERN "8888" -#endif - -#define DEFAULT_TEXT_PATTERN_UPDATE_INTERVAL 5 - -#define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 0 -#define API_VERSION_NUMBER_PATCH 6 - -using PowerState = WPEFramework::Exchange::IPowerManager::PowerState; - - -namespace -{ - - struct Mapping - { - const char *IArmBusName; - const char *SvcManagerName; - }; - - static struct Mapping name_mappings[] = { - { "Record" , "record_led"}, - { "Message" , "data_led"}, - { "Power" , "power_led"}, - { "Text" , "clock_led"}, - // TODO: add your mappings here - // { , }, - { 0, 0} - }; - - string svc2iarm(const string &name) - { - const char *s = name.c_str(); - - int i = 0; - while (name_mappings[i].SvcManagerName) - { - if (strcmp(s, name_mappings[i].SvcManagerName) == 0) - return name_mappings[i].IArmBusName; - i++; - } - return name; - } - - string iarm2svc(const string &name) - { - const char *s = name.c_str(); - - int i = 0; - while (name_mappings[i].IArmBusName) - { - if (strcmp(s, name_mappings[i].IArmBusName) == 0) - return name_mappings[i].SvcManagerName; - i++; - } - return name; - } - - JsonObject getFrontPanelIndicatorInfo(device::FrontPanelIndicator &indicator,JsonObject &indicatorInfo) - { - JsonObject returnResult; - int levels=0, min=0, max=0; - string range; - - indicator.getBrightnessLevels(levels, min, max); - range = (levels <=2)?"boolean":"int"; - indicatorInfo["range"] = range; - - indicatorInfo["min"] = JsonValue(min); - indicatorInfo["max"] = JsonValue(max); - - if (range == ("int")) - { - indicatorInfo["step"] = JsonValue((max-min)/levels); - } - JsonArray availableColors; - const device::List colorsList = indicator.getSupportedColors(); - for (uint j = 0; j < colorsList.size(); j++) - { - availableColors.Add(colorsList.at(j).getName()); - } - if (availableColors.Length() > 0) - { - indicatorInfo["colors"] = availableColors; - } - - indicatorInfo["colorMode"] = indicator.getColorMode(); - return indicatorInfo; - } -} - -namespace WPEFramework -{ - namespace { - - static Plugin::Metadata metadata( - // Version (Major, Minor, Patch) - API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, - // Preconditions - {}, - // Terminations - {}, - // Controls - {} - ); - } - - namespace Plugin - { - SERVICE_REGISTRATION(FrontPanel, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); - - FrontPanel* FrontPanel::_instance = nullptr; - - static Core::TimerType patternUpdateTimer(64 * 1024, "PatternUpdateTimer"); - int FrontPanel::m_savedClockBrightness = -1; - int FrontPanel::m_LedDisplayPatternUpdateTimerInterval = DEFAULT_TEXT_PATTERN_UPDATE_INTERVAL; - - FrontPanel::FrontPanel() - : PluginHost::JSONRPC() - , m_updateTimer(this) - , m_runUpdateTimer(false) - , _pwrMgrNotification(*this) - , _registeredEventHandlers(false) - { - FrontPanel::_instance = this; - m_runUpdateTimer = false; - - Register(METHOD_FP_SET_BRIGHTNESS, &FrontPanel::setBrightnessWrapper, this); - Register(METHOD_FP_GET_BRIGHTNESS, &FrontPanel::getBrightnessWrapper, this); - Register(METHOD_FP_POWER_LED_ON, &FrontPanel::powerLedOnWrapper, this); - Register(METHOD_FP_POWER_LED_OFF, &FrontPanel::powerLedOffWrapper, this); - Register(METHOD_CLOCK_SET_BRIGHTNESS, &FrontPanel::setClockBrightnessWrapper, this); - Register(METHOD_CLOCK_GET_BRIGHTNESS, &FrontPanel::getClockBrightnessWrapper, this); - Register(METHOD_GET_FRONT_PANEL_LIGHTS, &FrontPanel::getFrontPanelLightsWrapper, this); - Register(METHOD_FP_GET_PREFERENCES, &FrontPanel::getPreferencesWrapper, this); - Register(METHOD_FP_SET_PREFERENCES, &FrontPanel::setPreferencesWrapper, this); - Register(METHOD_FP_SET_LED, &FrontPanel::setLEDWrapper, this); - Register(METHOD_FP_SET_BLINK, &FrontPanel::setBlinkWrapper, this); - Register(METHOD_FP_SET_24_HOUR_CLOCK, &FrontPanel::set24HourClockWrapper, this); - Register(METHOD_FP_IS_24_HOUR_CLOCK, &FrontPanel::is24HourClockWrapper, this); - Register(METHOD_FP_SET_CLOCKTESTPATTERN, &FrontPanel::setClockTestPatternWrapper, this); - - } - - FrontPanel::~FrontPanel() - { - if (_powerManagerPlugin) { - _powerManagerPlugin->Unregister(_pwrMgrNotification.baseInterface()); - _powerManagerPlugin.Reset(); - } - - _registeredEventHandlers = false; - } - - const string FrontPanel::Initialize(PluginHost::IShell *service) - { - InitializePowerManager(service); - FrontPanel::_instance = this; - CFrontPanel::instance(service); - CFrontPanel::instance()->start(); - CFrontPanel::instance()->addEventObserver(this); - loadPreferences(); - - return (string()); - } - - void FrontPanel::Deinitialize(PluginHost::IShell* /* service */) - { - FrontPanel::_instance = nullptr; - - { - std::lock_guard lock(m_updateTimerMutex); - m_runUpdateTimer = false; - } - patternUpdateTimer.Revoke(m_updateTimer); - } - - void FrontPanel::InitializePowerManager(PluginHost::IShell *service) - { - _powerManagerPlugin = PowerManagerInterfaceBuilder(_T("org.rdk.PowerManager")) - .withIShell(service) - .withRetryIntervalMS(200) - .withRetryCount(25) - .createInterface(); - registerEventHandlers(); - } - - void FrontPanel::onPowerModeChanged(const PowerState currentState, const PowerState newState) - { - if(newState == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON) - { - LOGINFO("setPowerStatus true"); - CFrontPanel::instance()->setPowerStatus(true); - } - else - { - LOGINFO("setPowerStatus false"); - CFrontPanel::instance()->setPowerStatus(false); - } - return; - } - - void FrontPanel::registerEventHandlers() - { - ASSERT (_powerManagerPlugin); - - if(!_registeredEventHandlers && _powerManagerPlugin) { - _registeredEventHandlers = true; - _powerManagerPlugin->Register(_pwrMgrNotification.baseInterface()); - } - } - - void setResponseArray(JsonObject& response, const char* key, const std::vector& items) - { - JsonArray arr; - for (auto& i : items) arr.Add(JsonValue(i)); - - response[key] = arr; - - string json; - response.ToString(json); - LOGINFO("%s: result json %s\n", __FUNCTION__, json.c_str()); - } - - /** - * @brief sets the brightness of the specified LED. Brightness must be a value support by - * the LED and the value of the brightness for this led must be persisted. - * - * @param[in] brightness Brightness value. - * - * @return Returns the result which will be true when the call to set brightness succeeded. - * @ingroup SERVMGR_FRONTPANEL_API - */ - bool FrontPanel::setBrightness( int brightness ) - { - bool ok; - ok = CFrontPanel::instance()->setBrightness(brightness); - return ok; - } - - uint32_t FrontPanel::setBrightnessWrapper(const JsonObject& parameters, JsonObject& response) - { - CFrontPanel::instance()->stopBlinkTimer(); - int brightness = -1; - bool ok = false; - - if (!parameters.HasLabel("brightness")) - { - LOGERR("Parameter 'brightness' wasn't passed"); - returnResponse(ok); - } - - getNumberParameter("brightness", brightness); - - if (parameters.HasLabel("index")) - { - /* frontpanel_3 */ - if (parameters.HasLabel("index")) - { - string fp_ind; - fp_ind = svc2iarm(parameters["index"].String()); - LOGWARN("FP calling setBrightness of %s", fp_ind.c_str()); - - if (brightness >= 0) - { - LOGWARN("FP calling setBrightness of %s to %d", fp_ind.c_str(), brightness); -#ifdef CLOCK_BRIGHTNESS_ENABLED - if (TEXT_LED == fp_ind) - { - setClockBrightness(int(brightness)); - ok = true; - } - else -#endif - { - try - { - device::FrontPanelIndicator::getInstance(fp_ind.c_str()).setBrightness(int(brightness)); - ok = true; - } - catch (...) - { - ok = false; - } - } - } - } - } - else - { - - if (brightness >= 0 && brightness <= 100) - { - LOGWARN("calling setBrightness"); - ok = setBrightness(brightness); - } - else - { - LOGWARN("Invalid brightnessLevel passed to method setBrightness CallMethod"); - } - } - - returnResponse(ok); - } - - /** - * @brief Gets the brightness value of the specified LED. - * - * @return brightness Integer. - */ - int FrontPanel::getBrightness() - { - int brightness = -1; - brightness = CFrontPanel::instance()->getBrightness(); - return brightness; - } - - /** - * @brief Gets the brightness of the specified LED. - * - * @param[in] argList List of arguments (Not used). - * - * @return Returns a ServiceParams object containing brightness value and function result. - * @ingroup SERVMGR_FRONTPANEL_API - */ - uint32_t FrontPanel::getBrightnessWrapper(const JsonObject& parameters, JsonObject& response) - { - int brightness = -1; - bool ok = false; - LOGWARN("calling getBrightness"); - - if (parameters.HasLabel("index")) - { - string fp_ind; - fp_ind = svc2iarm(parameters["index"].String()); - LOGWARN("FP3 calling getBrightness of %s", fp_ind.c_str()); -#ifdef CLOCK_BRIGHTNESS_ENABLED - if (TEXT_LED == fp_ind) - { - brightness = getClockBrightness(); - } - else -#endif - try - { - brightness = device::FrontPanelIndicator::getInstance(fp_ind.c_str()).getBrightness(); - } - catch (...) - { - LOGWARN("Exception thrown from ds while calling getBrightness"); - } - } - else - brightness = getBrightness(); - - response["brightness"] = brightness; - ok = brightness >= 0 ? true : false; - - returnResponse(ok); - } - - /** - * @brief This function is used to switches ON the particular LED. The LED must be powere ON - * prior to setting its brightness. It is done by invoking the powerOnLed function of CFrontPanel. - * - * @param[in] fp_indicator Possible enum values are "0"-clock, "1"-message, "2"-power, "3"-record, - * "4"-remote etc. - * - * @return true if the LED is switches ON successfully else false. - */ - bool FrontPanel::powerLedOn(frontPanelIndicator fp_indicator) - { - return CFrontPanel::instance()->powerOnLed(fp_indicator); - } - - uint32_t FrontPanel::powerLedOnWrapper(const JsonObject& parameters, JsonObject& response ) - { - string fp_ind; - bool ok = false; - - if (parameters.HasLabel("index")) - fp_ind = parameters["index"].String(); - if (fp_ind.compare(DATA_LED) == 0) - { - LOGWARN("calling powerOnLed"); - ok = powerLedOn(FRONT_PANEL_INDICATOR_MESSAGE); - } - else if (fp_ind.compare(RECORD_LED) == 0) - { - LOGWARN("calling powerOnLed"); - ok = powerLedOn(FRONT_PANEL_INDICATOR_RECORD); - } - else if (fp_ind.compare(POWER_LED) == 0) - { - LOGWARN("calling powerOnLed"); - ok = powerLedOn(FRONT_PANEL_INDICATOR_POWER); - } - returnResponse(ok); - } - - /** - * @brief This function is used to switches OFF the particular LED. It is done by invoking - * the powerOffLed function of CFrontPanel. - * - * @param[in] fp_indicator Possible enum values are "0"-clock, "1"-message, "2"-power, "3"-record, - * "4"-remote etc. - * - * @return true if the LED is switches OFF successfully else false. - */ - bool FrontPanel::powerLedOff(frontPanelIndicator fp_indicator) - { - bool ok; - ok = CFrontPanel::instance()->powerOffLed(fp_indicator); - return ok; - } - - uint32_t FrontPanel::powerLedOffWrapper(const JsonObject& parameters, JsonObject& response) - { - string fp_ind; - bool ok = false; - - if (parameters.HasLabel("index")) - fp_ind = parameters["index"].String(); - if (fp_ind.compare(DATA_LED) == 0) - { - LOGWARN("calling powerOffLed"); - ok = powerLedOff(FRONT_PANEL_INDICATOR_MESSAGE); - } - else if (fp_ind.compare(RECORD_LED) == 0) - { - LOGWARN("calling powerOffLed"); - ok = powerLedOff(FRONT_PANEL_INDICATOR_RECORD); - } - else if (fp_ind.compare(POWER_LED) == 0) - { - LOGWARN("calling powerOffLed"); - ok = powerLedOff(FRONT_PANEL_INDICATOR_POWER); - } - returnResponse(ok); - } - - bool FrontPanel::setClockBrightness(int brightness ) - { -#ifdef CLOCK_BRIGHTNESS_ENABLED - bool ok; - ok = CFrontPanel::instance()->setClockBrightness(brightness); - return ok; -#else - return false; -#endif - } - - uint32_t FrontPanel::setClockBrightnessWrapper(const JsonObject& parameters, JsonObject& response) - { - bool ok = false; - -#ifdef CLOCK_BRIGHTNESS_ENABLED - int brightness = -1; - - if (parameters.HasLabel("brightness")) - getNumberParameter("brightness", brightness); - - if (brightness >= 0 && brightness <= 100) - { - LOGWARN("calling setClockBrightness"); - ok = setClockBrightness(brightness); - } - else - { - LOGWARN("Invalid brightnessLevel passed to method setBrightness CallMethod"); - } -#else - LOGWARN("No operation for setClockBrightness"); -#endif - - - returnResponse(ok); - } - - - /** - * @brief get the clock brightness of the specified LED. Brightness must be a value support by the - * LED and the value of the brightness for this led must be persisted. - * - * @return The brightness integer value if clock brightness enable macro is true else it will return -1. - */ - int FrontPanel::getClockBrightness() - { -#ifdef CLOCK_BRIGHTNESS_ENABLED - int brightness = -1; - brightness = CFrontPanel::instance()->getClockBrightness(); - return brightness; -#else - return -1; -#endif - } - - uint32_t FrontPanel::getClockBrightnessWrapper(const JsonObject& parameters, JsonObject& response) - { - bool ok = false; -#ifdef CLOCK_BRIGHTNESS_ENABLED - int brightness = -1; - LOGWARN("calling getClockBrightness"); - brightness = getClockBrightness(); - if (0 <= brightness) - ok = true; - response["brightness"] = brightness; -#else - LOGWARN("No operation for getClockBrightness"); -#endif - returnResponse(ok); - } - - /** - * @brief getFrontPanelLights This returns an object containing attributes of front panel - * light: success, supportedLights, and supportedLightsInfo. - * supportedLights defines the LED lights that can be controlled through the Front Panel API. - * supportedLightsInfo defines a hash of objects describing each LED light. - * success - false if the supported lights info was unable to be determined. - * - * @return Returns a list of front panel lights parameter. - * @ingroup SERVMGR_FRONTPANEL_API - */ - std::vector FrontPanel::getFrontPanelLights() - { - std::vector lights; - device::List fpIndicators = device::FrontPanelConfig::getInstance().getIndicators(); - for (uint i = 0; i < fpIndicators.size(); i++) - { - string IndicatorNameIarm = fpIndicators.at(i).getName(); - string MappedName = iarm2svc(IndicatorNameIarm); - if (MappedName != IndicatorNameIarm) lights.push_back(MappedName); - } -#ifdef CLOCK_BRIGHTNESS_ENABLED - try - { - device::List fpTextDisplays = device::FrontPanelConfig::getInstance().getTextDisplays(); - for (uint i = 0; i < fpTextDisplays.size(); i++) - { - string TextDisplayNameIarm = fpTextDisplays.at(i).getName(); - string MappedName = iarm2svc(TextDisplayNameIarm); - if (MappedName != TextDisplayNameIarm) - { - lights.push_back(MappedName); - } - } - } - catch (...) - { - LOGERR("Exception while getFrontPanelLights"); - } -#endif - return lights; - } - - /** - * @brief getFrontPanelLightsInfo This returns an object containing attributes of front - * panel light: success, supportedLights, and supportedLightsInfo. - * supportedLightsInfo defines a hash of objects describing each LED light properties such as - * -"range" Determines the types of values that can be expected in min and max value. - * -"min" The minimum value is equivalent to off i.e "0". - * -"max" The maximum value is when the LED is on i.e "1" and at its brightest. - * -"step" The step or interval between the min and max values supported by the LED. - * -"colorMode" Defines enum of "0" LED's color cannot be changed, "1" LED can be set to any color - * (using rgb-hex code),"2" LED can be set to an enumeration of colors as specified by the - * supportedColors property. - * - * @return Returns a serviceParams list of front panel lights info. - */ - JsonObject FrontPanel::getFrontPanelLightsInfo() - { - JsonObject returnResult; - JsonObject indicatorInfo; - string IndicatorNameIarm, MappedName; - - device::List fpIndicators = device::FrontPanelConfig::getInstance().getIndicators(); - for (uint i = 0; i < fpIndicators.size(); i++) - { - IndicatorNameIarm = fpIndicators.at(i).getName(); - MappedName = iarm2svc(IndicatorNameIarm); - getFrontPanelIndicatorInfo(fpIndicators.at(i),indicatorInfo); - if (MappedName != IndicatorNameIarm) - { - returnResult[MappedName.c_str()] = indicatorInfo; - } - else - { - returnResult[IndicatorNameIarm.c_str()] = indicatorInfo; - } - } - -#ifdef CLOCK_BRIGHTNESS_ENABLED - try - { - getFrontPanelIndicatorInfo(device::FrontPanelConfig::getInstance().getTextDisplay(0),indicatorInfo); - returnResult[CLOCK_LED] = indicatorInfo; - } - catch (...) - { - LOGERR("Exception while getFrontPanelLightsInfo"); - } -#endif - return returnResult; - } - - - uint32_t FrontPanel::getFrontPanelLightsWrapper(const JsonObject& parameters, JsonObject& response) - { - /*CID 17850 removing logically dead code */ - - LOGWARN("sending getFrontPanelLights"); - setResponseArray(response, "supportedLights", getFrontPanelLights()); - response["supportedLightsInfo"] = getFrontPanelLightsInfo(); - returnResponse(true); - } - - - /** - * @brief Returns the preferences object as stored in setPreferences. - * - * @return Attribute key value pair list. - */ - JsonObject FrontPanel::getPreferences() - { - return CFrontPanel::instance()->getPreferences(); - } - - /** - * @brief This method stores the preferences into persistent storage. - * It does not change the colour of any LEDs. It invoking the setPreferences - * method of cFrontPanel class to set the preference data. - * - * @param[in] preferences Key value pair of preferences data. - * - * @return Returns the success code of underlying method. - */ - void FrontPanel::setPreferences(const JsonObject& preferences) - { - CFrontPanel::instance()->setPreferences(preferences); - } - - void FrontPanel::loadPreferences() - { - CFrontPanel::instance()->loadPreferences(); - } - - uint32_t FrontPanel::getPreferencesWrapper(const JsonObject& parameters, JsonObject& response) - { - response["preferences"] = getPreferences(); - returnResponse(true); - } - - /** - * @brief This method stores the preferences into persistent storage. - * It does not change the color of any LEDs. The preferences object is not validated. - * It is up to the client of this API to ensure that preference values are valid. - * - * @param[in] argList List of preferences. - * @return Returns the success code of underlying method. - * @ingroup SERVMGR_FRONTPANEL_API - */ - uint32_t FrontPanel::setPreferencesWrapper(const JsonObject& parameters, JsonObject& response) - { - bool success = false; - - if (parameters.HasLabel("preferences")) - { - JsonObject preferences = parameters["preferences"].Object(); - setPreferences(preferences); - success = true; - } - returnResponse(success); - } - - /** - * @brief Sets the brightness and color properties of the specified LED. - * The supported properties of the info object passed in will be determined by the color - * mode of the LED. If the colorMode of an LED is 0 color values will be ignored. If the - * brightness of the LED is unspecified or value = -1, then the persisted or default - * value for the system is used. - * - * @param[in] properties Key value pair of properties data. - * - * @return Returns success value of the helper method, returns false in case of failure. - */ - bool FrontPanel::setLED(const JsonObject& properties) - { - bool success = false; - success = CFrontPanel::instance()->setLED(properties); - return success; - } - - /** - * @brief Specifies a blinking pattern for an LED. This method returns immediately, but starts - * a process of iterating through each element in the array and lighting the LED with the specified - * brightness and color (if applicable) for the given duration (in milliseconds). - * - * @param[in] blinkInfo Object containing Indicator name, blink pattern and duration. - * @ingroup SERVMGR_FRONTPANEL_API - */ - void FrontPanel::setBlink(const JsonObject& blinkInfo) - { - CFrontPanel::instance()->setBlink(blinkInfo); - } - - /** - * @brief Specifies the 24 hour clock format. - * - * @param[in] is24Hour true if 24 hour clock format. - * @ingroup SERVMGR_FRONTPANEL_API - */ - void FrontPanel::set24HourClock(bool is24Hour) - { - CFrontPanel::instance()->set24HourClock(is24Hour); - } - - /** - * @brief Get the 24 hour clock format. - * - * @return true if 24 hour clock format is used. - * @ingroup SERVMGR_FRONTPANEL_API - */ - bool FrontPanel::is24HourClock() - { - bool is24Hour = false; - is24Hour = CFrontPanel::instance()->is24HourClock(); - return is24Hour; - } - - - /** - * @brief Enable or disable showing test pattern 88:88 on stbs with clock displays. - * - * @param[in] show true to show pattern, false to restore display to default behavior, usual it's clock. - * @param[in] interval (optional) interval in seconds to check and update LED display with pattern, when it's overridden by external API. - * from 1 to 60 seconds. 0 and other outbound values mean that timer isn't used and isn't activated by this call. - * Optionally the timer is enabled for 5 seconds interval. - * @return true if method succeeded. - * @ingroup SERVMGR_FRONTPANEL_API - */ - void FrontPanel::setClockTestPattern(bool show) - { - #ifdef CLOCK_BRIGHTNESS_ENABLED - try{ - device::FrontPanelTextDisplay& display = device::FrontPanelConfig::getInstance().getTextDisplay("Text"); - - if (show) - { - if (m_LedDisplayPatternUpdateTimerInterval > 0 && m_LedDisplayPatternUpdateTimerInterval < 61) - { - { - std::lock_guard lock(m_updateTimerMutex); - m_runUpdateTimer = true; - } - patternUpdateTimer.Schedule(Core::Time::Now().Add(m_LedDisplayPatternUpdateTimerInterval * 1000), m_updateTimer); - - LOGWARN("%s: LED FP display update timer activated with interval %ds", __FUNCTION__, m_LedDisplayPatternUpdateTimerInterval); - } - else - { - LOGWARN("%s: LED FP display update timer didn't used for interval value %d. To activate it, interval should be in bound of values from 1 till 60" - , __FUNCTION__, m_LedDisplayPatternUpdateTimerInterval); - - { - std::lock_guard lock(m_updateTimerMutex); - m_runUpdateTimer = false; - } - patternUpdateTimer.Revoke(m_updateTimer); - } - - if (-1 == m_savedClockBrightness) - { - m_savedClockBrightness = getClockBrightness(); - LOGWARN("%s: brightness of LED FP display %d was saved", __FUNCTION__, m_savedClockBrightness); - } - - display.setMode(1); //Set Front Panel Display to Text Mode - display.setText(ALL_SEGMENTS_TEXT_PATTERN); - setClockBrightness(100); - LOGWARN("%s: pattern " ALL_SEGMENTS_TEXT_PATTERN " activated on LED FP display with max brightness", __FUNCTION__); - } - else - { - { - std::lock_guard lock(m_updateTimerMutex); - m_runUpdateTimer = false; - } - patternUpdateTimer.Revoke(m_updateTimer); - - display.setMode(0);//Set Front Panel Display to Default Mode - display.setText(" "); - LOGWARN("%s: pattern " ALL_SEGMENTS_TEXT_PATTERN " deactivated on LED FP display", __FUNCTION__); - - if (-1 != m_savedClockBrightness) - { - setClockBrightness(m_savedClockBrightness); - LOGWARN("%s: brightness %d of LED FP display restored", __FUNCTION__, m_savedClockBrightness); - m_savedClockBrightness = -1; - } - } - } - catch (...) - { - LOGERR("Exception while getTextDisplay"); - } - #else - LOGWARN("%s: disabled for this platform", __FUNCTION__); - #endif - } - - - - - uint32_t FrontPanel::setLEDWrapper(const JsonObject& parameters, JsonObject& response) - { - bool success = false; - - /*if (parameters.HasLabel("properties")) - { - JsonObject properties = parameters["properties"].Object(); - success = setLED(properties); - }*/ - success = setLED(parameters); - returnResponse(success); - } - - uint32_t FrontPanel::setBlinkWrapper(const JsonObject& parameters, JsonObject& response) - { - bool success = false; - - if (parameters.HasLabel("blinkInfo")) - { - JsonObject blinkInfo = parameters["blinkInfo"].Object(); - setBlink(blinkInfo); - success = true; - } - returnResponse(success); - } - - uint32_t FrontPanel::set24HourClockWrapper(const JsonObject& parameters, JsonObject& response) - { - bool success = false; - - if (parameters.HasLabel("is24Hour")) - { - bool is24Hour = false; - getBoolParameter("is24Hour", is24Hour ); - set24HourClock(is24Hour); - success = true; - } - returnResponse(success); - } - - uint32_t FrontPanel::is24HourClockWrapper(const JsonObject& parameters, JsonObject& response) - { - bool is24Hour = is24HourClock(); - response["is24Hour"] = is24Hour; - returnResponse(true); - } - - uint32_t FrontPanel::setClockTestPatternWrapper(const JsonObject& parameters, JsonObject& response) - { - if (!parameters.HasLabel("show")) - { - LOGWARN("'show' parameter wasn't passed"); - returnResponse(false); - } - - bool show = false; - getBoolParameter("show", show); - - m_LedDisplayPatternUpdateTimerInterval = DEFAULT_TEXT_PATTERN_UPDATE_INTERVAL; - if (parameters.HasLabel("timerInterval")) - getNumberParameter("timerInterval", m_LedDisplayPatternUpdateTimerInterval); - - setClockTestPattern(show); - - returnResponse(true); - } - - void FrontPanel::updateLedTextPattern() - { - LOGWARN("%s: override FP LED display with text pattern " ALL_SEGMENTS_TEXT_PATTERN, __FUNCTION__); - - if (getClockBrightness() != 100) - { - setClockBrightness(100); - } - - device::FrontPanelConfig::getInstance().getTextDisplay("Text").setText(ALL_SEGMENTS_TEXT_PATTERN); - LOGWARN("%s: LED display updated by pattern " ALL_SEGMENTS_TEXT_PATTERN, __FUNCTION__); - - { - std::lock_guard lock(m_updateTimerMutex); - if (m_runUpdateTimer) - patternUpdateTimer.Schedule(Core::Time::Now().Add(m_LedDisplayPatternUpdateTimerInterval * 1000), m_updateTimer); - } - } - - uint64_t TestPatternInfo::Timed(const uint64_t scheduledTime) - { - uint64_t result = 0; - m_frontPanel->updateLedTextPattern(); - return(result); - } - - - } // namespace Plugin -} // namespace WPEFramework diff --git a/FrontPanel/FrontPanel.h b/FrontPanel/FrontPanel.h deleted file mode 100644 index 79739fe0..00000000 --- a/FrontPanel/FrontPanel.h +++ /dev/null @@ -1,190 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once - -#include -#include "Module.h" -#include "libIARM.h" -#include "frontpanel.h" -#include -#include "PowerManagerInterface.h" - -using namespace WPEFramework; -using PowerState = WPEFramework::Exchange::IPowerManager::PowerState; -using ThermalTemperature = WPEFramework::Exchange::IPowerManager::ThermalTemperature; - -#define DATA_LED "data_led" -#define RECORD_LED "record_led" -#ifdef CLOCK_BRIGHTNESS_ENABLED -#define CLOCK_LED "clock_led" -#define TEXT_LED "Text" -#endif - -namespace WPEFramework { - - namespace Plugin { - - class TestPatternInfo - { - private: - TestPatternInfo() = delete; - TestPatternInfo& operator=(const TestPatternInfo& RHS) = delete; - - public: - TestPatternInfo(FrontPanel* fp) - : m_frontPanel(fp) - { - } - TestPatternInfo(const TestPatternInfo& copy) - : m_frontPanel(copy.m_frontPanel) - { - } - ~TestPatternInfo() {} - - inline bool operator==(const TestPatternInfo& RHS) const - { - return(m_frontPanel == RHS.m_frontPanel); - } - - public: - uint64_t Timed(const uint64_t scheduledTime); - - private: - FrontPanel* m_frontPanel; - }; - - - // This is a server for a JSONRPC communication channel. - // For a plugin to be capable to handle JSONRPC, inherit from PluginHost::JSONRPC. - // By inheriting from this class, the plugin realizes the interface PluginHost::IDispatcher. - // This realization of this interface implements, by default, the following methods on this plugin - // - exists - // - register - // - unregister - // Any other methood to be handled by this plugin can be added can be added by using the - // templated methods Register on the PluginHost::JSONRPC class. - // As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC, - // this class exposes a public method called, Notify(), using this methods, all subscribed clients - // will receive a JSONRPC message as a notification, in case this method is called. - class FrontPanel : public PluginHost::IPlugin, public PluginHost::JSONRPC { - private: - class PowerManagerNotification : public Exchange::IPowerManager::IModeChangedNotification { - private: - PowerManagerNotification(const PowerManagerNotification&) = delete; - PowerManagerNotification& operator=(const PowerManagerNotification&) = delete; - - public: - explicit PowerManagerNotification(FrontPanel& parent) - : _parent(parent) - { - } - ~PowerManagerNotification() override = default; - - public: - void OnPowerModeChanged(const PowerState currentState, const PowerState newState) override - { - _parent.onPowerModeChanged(currentState, newState); - } - - template - T* baseInterface() - { - static_assert(std::is_base_of(), "base type mismatch"); - return static_cast(this); - } - - BEGIN_INTERFACE_MAP(PowerManagerNotification) - INTERFACE_ENTRY(Exchange::IPowerManager::IModeChangedNotification) - END_INTERFACE_MAP - - private: - FrontPanel& _parent; - }; - - // We do not allow this plugin to be copied !! - FrontPanel(const FrontPanel&) = delete; - FrontPanel& operator=(const FrontPanel&) = delete; - - bool setBrightness(int brightness); - int getBrightness(); - bool powerLedOn(frontPanelIndicator fp_indicator); - bool powerLedOff(frontPanelIndicator fp_indicator); - bool setClockBrightness(int brightness); - int getClockBrightness(); - std::vector getFrontPanelLights(); - JsonObject getFrontPanelLightsInfo(); - JsonObject getPreferences(); - void setPreferences(const JsonObject& preferences); - bool setLED(const JsonObject& properties); - void setBlink(const JsonObject& blinkInfo); - void set24HourClock(bool is24Hour); - bool is24HourClock(); - void setClockTestPattern(bool show); - - void loadPreferences(); - void InitializePowerManager(PluginHost::IShell *service); - - //Begin methods - uint32_t setBrightnessWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getBrightnessWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t powerLedOnWrapper(const JsonObject& parameters, JsonObject& response ); - uint32_t powerLedOffWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setClockBrightnessWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getClockBrightnessWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getFrontPanelLightsWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getPreferencesWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setPreferencesWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setLEDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setBlinkWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t set24HourClockWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t is24HourClockWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setClockTestPatternWrapper(const JsonObject& parameters, JsonObject& response); - //End methods - - public: - FrontPanel(); - virtual ~FrontPanel(); - virtual const string Initialize(PluginHost::IShell* shell) override; - virtual void Deinitialize(PluginHost::IShell* service) override; - virtual string Information() const override { return {}; } - void onPowerModeChanged(const PowerState currentState, const PowerState newState); - void updateLedTextPattern(); - void registerEventHandlers(); - - BEGIN_INTERFACE_MAP(FrontPanel) - INTERFACE_ENTRY(PluginHost::IPlugin) - INTERFACE_ENTRY(PluginHost::IDispatcher) - END_INTERFACE_MAP - public: - static FrontPanel* _instance; - private: - static int m_savedClockBrightness; - static int m_LedDisplayPatternUpdateTimerInterval; - - TestPatternInfo m_updateTimer; - bool m_runUpdateTimer; - std::mutex m_updateTimerMutex; - PowerManagerInterfaceRef _powerManagerPlugin; - Core::Sink _pwrMgrNotification; - bool _registeredEventHandlers; - - }; - } // namespace Plugin -} // namespace WPEFramework diff --git a/FrontPanel/Module.cpp b/FrontPanel/Module.cpp deleted file mode 100644 index ce759b61..00000000 --- a/FrontPanel/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/FrontPanel/Module.h b/FrontPanel/Module.h deleted file mode 100644 index e6d64dbe..00000000 --- a/FrontPanel/Module.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once -#ifndef MODULE_NAME -#define MODULE_NAME Plugin_FrontPanel -#endif - -#include -#include - -#undef EXTERNAL -#define EXTERNAL diff --git a/LEDControl/CHANGELOG.md b/LEDControl/CHANGELOG.md deleted file mode 100644 index ace0dca9..00000000 --- a/LEDControl/CHANGELOG.md +++ /dev/null @@ -1,15 +0,0 @@ -All notable changes to this RDK Service will be documented in this file. - - Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. - - Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - Added for new features. - Changed for changes in existing functionality. - Deprecated for soon-to-be removed features. - Removed for now removed features. - Fixed for any bug fixes. - Security in case of vulnerabilities. - - Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. - - For more details, refer to versioning section under Main README. diff --git a/LEDControl/CMakeLists.txt b/LEDControl/CMakeLists.txt deleted file mode 100644 index 7de2b928..00000000 --- a/LEDControl/CMakeLists.txt +++ /dev/null @@ -1,88 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(PLUGIN_NAME LEDControl) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) -set(PLUGIN_IMPLEMENTATION ${MODULE_NAME}Implementation) - -set(PLUGIN_LEDCONTROL_STARTUPORDER "" CACHE STRING "To configure startup order of LEDControl plugin") - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - -find_package(${NAMESPACE}Plugins REQUIRED) -find_package(${NAMESPACE}Definitions REQUIRED) -find_package(CompileSettingsDebug CONFIG REQUIRED) - -add_library(${MODULE_NAME} SHARED - LEDControl.cpp - Module.cpp) - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -target_include_directories(${MODULE_NAME} PRIVATE ../helpers) - -target_link_libraries(${MODULE_NAME} - PRIVATE - CompileSettingsDebug::CompileSettingsDebug - ${NAMESPACE}Plugins::${NAMESPACE}Plugins - ${NAMESPACE}Definitions::${NAMESPACE}Definitions) - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -add_library(${PLUGIN_IMPLEMENTATION} SHARED - LEDControlImplementation.cpp - Module.cpp -) - -set_target_properties(${PLUGIN_IMPLEMENTATION} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -if (RDK_SERVICE_L2_TEST) - find_library(TESTMOCKLIB_LIBRARIES NAMES TestMocklib) - if (TESTMOCKLIB_LIBRARIES) - message ("linking mock libraries ${TESTMOCKLIB_LIBRARIES} library") - target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE ${TESTMOCKLIB_LIBRARIES}) - else (TESTMOCKLIB_LIBRARIES) - message ("Require ${TESTMOCKLIB_LIBRARIES} library") - endif (TESTMOCKLIB_LIBRARIES) -endif (RDK_SERVICES_L2_TEST) - -target_compile_definitions(${PLUGIN_IMPLEMENTATION} PRIVATE MODULE_NAME=Plugin_${PLUGIN_NAME}) - -find_package(DS) -if (DS_FOUND) - find_package(IARMBus) - add_definitions(-DDS_FOUND) - target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${IARMBUS_INCLUDE_DIRS}) - target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${DS_INCLUDE_DIRS}) - target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ../helpers) - target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${OEMHAL_LIBRARIES} -lpthread -lglib-2.0 -ldbus-1 ${IARMBUS_LIBRARIES}) -# target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${DS_LIBRARIES}) -else (DS_FOUND) - target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins) -endif(DS_FOUND) - -#target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins) - -install(TARGETS ${PLUGIN_IMPLEMENTATION} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/LEDControl/LEDControl.conf.in b/LEDControl/LEDControl.conf.in deleted file mode 100644 index 10dcd73e..00000000 --- a/LEDControl/LEDControl.conf.in +++ /dev/null @@ -1,12 +0,0 @@ -precondition = ["Platform"] -callsign = "org.rdk.LEDControl" -autostart = "false" -startuporder = "@PLUGIN_LEDCONTROL_STARTUPORDER@" - -configuration = JSON() -rootobject = JSON() - -rootobject.add("mode", "@PLUGIN_LEDCONTROL_MODE@") -rootobject.add("locator", "lib@PLUGIN_IMPLEMENTATION@.so") - -configuration.add("root", rootobject) diff --git a/LEDControl/LEDControl.config b/LEDControl/LEDControl.config deleted file mode 100644 index 06f50da2..00000000 --- a/LEDControl/LEDControl.config +++ /dev/null @@ -1,16 +0,0 @@ -set (autostart false) -set (preconditions Platform) -set (callsign "org.rdk.LEDControl") - -if(PLUGIN_LEDCONTROL_STARTUPORDER) -set (startuporder ${PLUGIN_LEDCONTROL_STARTUPORDER}) -endif() - -map() - key(root) - map() - kv(mode ${PLUGIN_LEDCONTROL_MODE}) - kv(locator lib${PLUGIN_IMPLEMENTATION}.so) - end() -end() -ans(configuration) diff --git a/LEDControl/LEDControl.cpp b/LEDControl/LEDControl.cpp deleted file mode 100644 index 7767f88e..00000000 --- a/LEDControl/LEDControl.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2025 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "LEDControl.h" - -#define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 0 -#define API_VERSION_NUMBER_PATCH 1 - - -namespace WPEFramework -{ - namespace { - static Plugin::Metadata metadata( - // Version (Major, Minor, Patch) - API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, - // Preconditions - {}, - // Terminations - {}, - // Controls - {} - ); - } - - namespace Plugin - { - /* - *Register Ledcontrol module as wpeframework plugin - **/ - SERVICE_REGISTRATION(LEDControl, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); - - LEDControl::LEDControl() : _service(nullptr), _connectionId(0), _ledcontrol(nullptr) - { - SYSLOG(Logging::Startup, (_T("LEDControl Constructor"))); - } - - LEDControl::~LEDControl() - { - SYSLOG(Logging::Shutdown, (string(_T("LEDControl Destructor")))); - } - - const string LEDControl::Initialize(PluginHost::IShell* service) - { - string message=""; - - ASSERT(nullptr != service); - ASSERT(nullptr == _service); - ASSERT(nullptr == _ledcontrol); - ASSERT(0 == _connectionId); - - SYSLOG(Logging::Startup, (_T("LEDControl::Initialize: PID=%u"), getpid())); - - _service = service; - _service->AddRef(); - _ledcontrol = _service->Root(_connectionId, 5000, _T("LEDControlImplementation")); - - if(nullptr != _ledcontrol) - { - // Invoking Plugin API register to wpeframework - Exchange::JLEDControl::Register(*this, _ledcontrol); - } - else - { - SYSLOG(Logging::Startup, (_T("Ledcontrol::Initialize: Failed to initialise LEDControl plugin"))); - message = _T("LEDControl plugin could not be initialised"); - } - - return message; - } - - void LEDControl::Deinitialize(PluginHost::IShell* service) - { - ASSERT(_service == service); - - SYSLOG(Logging::Shutdown, (string(_T("LEDControl::Deinitialize")))); - - if (nullptr != _ledcontrol) - { - - Exchange::JLEDControl::Unregister(*this); - - // Stop processing: - RPC::IRemoteConnection* connection = service->RemoteConnection(_connectionId); - VARIABLE_IS_NOT_USED uint32_t result = _ledcontrol->Release(); - - _ledcontrol = nullptr; - - // It should have been the last reference we are releasing, - // so it should endup in a DESTRUCTION_SUCCEEDED, if not we - // are leaking... - ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED); - - // If this was running in a (container) process... - if (nullptr != connection) - { - // Lets trigger the cleanup sequence for - // out-of-process code. Which will guard - // that unwilling processes, get shot if - // not stopped friendly :-) - try - { - connection->Terminate(); - // Log success if needed - LOGWARN("Connection terminated successfully."); - } - catch (const std::exception& e) - { - std::string errorMessage = "Failed to terminate connection: "; - errorMessage += e.what(); - LOGWARN("%s",errorMessage.c_str()); - } - - connection->Release(); - } - } - - _connectionId = 0; - _service->Release(); - _service = nullptr; - SYSLOG(Logging::Shutdown, (string(_T("LEDControl de-initialised")))); - } - - string LEDControl::Information() const - { - return string(); - } - - void LEDControl::Deactivated(RPC::IRemoteConnection* connection) - { - if (connection->Id() == _connectionId) { - ASSERT(nullptr != _service); - Core::IWorkerPool::Instance().Submit(PluginHost::IShell::Job::Create(_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::FAILURE)); - } - } - } // namespace Plugin -} // namespace WPEFramework diff --git a/LEDControl/LEDControl.h b/LEDControl/LEDControl.h deleted file mode 100644 index 55b28a8d..00000000 --- a/LEDControl/LEDControl.h +++ /dev/null @@ -1,63 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2025 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once - -#include "Module.h" -#include -#include -#include -#include "UtilsLogging.h" -#include "tracing/Logging.h" - -namespace WPEFramework -{ - namespace Plugin - { - class LEDControl : public PluginHost::IPlugin, public PluginHost::JSONRPC - { - public: - LEDControl(const LEDControl&) = delete; - LEDControl& operator=(const LEDControl&) = delete; - - LEDControl(); - virtual ~LEDControl(); - - BEGIN_INTERFACE_MAP(LEDControl) - INTERFACE_ENTRY(PluginHost::IPlugin) - INTERFACE_ENTRY(PluginHost::IDispatcher) - INTERFACE_AGGREGATE(Exchange::ILEDControl, _ledcontrol) - END_INTERFACE_MAP - - // IPlugin methods - // ------------------------------------------------------------------------------------------------------- - const string Initialize(PluginHost::IShell* service) override; - void Deinitialize(PluginHost::IShell* service) override; - string Information() const override; - - private: - void Deactivated(RPC::IRemoteConnection* connection); - - private: - PluginHost::IShell* _service{}; - uint32_t _connectionId{}; - Exchange::ILEDControl* _ledcontrol{}; - }; - } // namespace Plugin -} // namespace WPEFramework diff --git a/LEDControl/LEDControlImplementation.cpp b/LEDControl/LEDControlImplementation.cpp deleted file mode 100644 index 4a937540..00000000 --- a/LEDControl/LEDControlImplementation.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2025 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "LEDControlImplementation.h" - -#include - -#include "UtilsJsonRpc.h" -#include "UtilsIarm.h" -#include "dsFPD.h" - -#define FPD_LED_DEVICE_NONE "NONE" -#define FPD_LED_DEVICE_ACTIVE "ACTIVE" -#define FPD_LED_DEVICE_STANDBY "STANDBY" -#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" - -namespace WPEFramework -{ - namespace Plugin - { - SERVICE_REGISTRATION(LEDControlImplementation, 1, 0); - - LEDControlImplementation::LEDControlImplementation(): m_isPlatInitialized (false) - { - LOGINFO("LEDControlImplementation Constructor called"); - if (!m_isPlatInitialized){ - LOGINFO("Doing plat init"); - if (dsERR_NONE != dsFPInit()){ - LOGERR("dsFPInit failed"); - } - m_isPlatInitialized = true; - } - } - - LEDControlImplementation::~LEDControlImplementation() - { - LOGINFO("LEDControlImplementation Destructor called"); - if (m_isPlatInitialized){ - LOGINFO("Doing plat uninit"); - dsFPTerm(); - m_isPlatInitialized = false; - } - } - - Core::hresult LEDControlImplementation::GetSupportedLEDStates(IStringIterator*& supportedLEDStates, bool& success) - { - LOGINFO(""); - - std::list supportedLEDStatesInfo; - - try { - unsigned int states = dsFPD_LED_DEVICE_NONE; - dsError_t err = dsFPGetSupportedLEDStates (&states); - if (!err) { - if(!states)supportedLEDStatesInfo.emplace_back(FPD_LED_DEVICE_NONE); - if(states & (1<::Create(supportedLEDStatesInfo)); - success = true; - return Core::ERROR_NONE; - } - - Core::hresult LEDControlImplementation::GetLEDState(LEDControlState& state) - { - LOGINFO(""); - - try - { - dsFPDLedState_t Ledstate; - dsError_t err = dsFPGetLEDState (&Ledstate); - if (!err) { - switch (Ledstate) { - case dsFPD_LED_DEVICE_NONE: - state.state = FPD_LED_DEVICE_NONE; - break; - case dsFPD_LED_DEVICE_ACTIVE: - state.state = FPD_LED_DEVICE_ACTIVE; - break; - case dsFPD_LED_DEVICE_STANDBY: - state.state = FPD_LED_DEVICE_STANDBY; - break; - case dsFPD_LED_DEVICE_WPS_CONNECTING: - state.state = FPD_LED_DEVICE_WPS_CONNECTING; - break; - case dsFPD_LED_DEVICE_WPS_CONNECTED: - state.state = FPD_LED_DEVICE_WPS_CONNECTED; - break; - case dsFPD_LED_DEVICE_WPS_ERROR: - state.state = FPD_LED_DEVICE_WPS_ERROR; - break; - case dsFPD_LED_DEVICE_FACTORY_RESET: - state.state = FPD_LED_DEVICE_FACTORY_RESET; - break; - case dsFPD_LED_DEVICE_USB_UPGRADE: - state.state = FPD_LED_DEVICE_USB_UPGRADE; - break; - case dsFPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR: - state.state = FPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR; - break; - - default : - LOGERR("Unsupported LEDState %d", Ledstate); - return WPEFramework::Core::ERROR_BAD_REQUEST; - } - } else { - LOGERR("dsFPGetLEDState returned error %d", err); - return Core::ERROR_GENERAL; - } - } - catch(...) - { - LOGERR("Exception in dsFPGetLEDState"); - return Core::ERROR_GENERAL; - } - - return Core::ERROR_NONE; - } - - Core::hresult LEDControlImplementation::SetLEDState(const string& state, bool& success) - { - LOGINFO(""); - - if (state.empty()) - { - LOGERR("state is empty"); - success = false; - return WPEFramework::Core::ERROR_BAD_REQUEST; - } - - try - { - dsFPDLedState_t LEDstate = dsFPD_LED_DEVICE_NONE; - if (0==strncmp(state.c_str(), FPD_LED_DEVICE_ACTIVE, strlen(FPD_LED_DEVICE_ACTIVE)) && - (strlen(state.c_str()) == strlen(FPD_LED_DEVICE_ACTIVE)) ){ - LEDstate = dsFPD_LED_DEVICE_ACTIVE; - } else if (0==strncmp(state.c_str(), FPD_LED_DEVICE_STANDBY, strlen(FPD_LED_DEVICE_STANDBY)) && - (strlen(state.c_str()) == strlen(FPD_LED_DEVICE_STANDBY)) ){ - LEDstate = dsFPD_LED_DEVICE_STANDBY; - } else if (0==strncmp(state.c_str(), FPD_LED_DEVICE_WPS_CONNECTING, strlen(FPD_LED_DEVICE_WPS_CONNECTING)) && - (strlen(state.c_str()) == strlen(FPD_LED_DEVICE_WPS_CONNECTING))){ - LEDstate = dsFPD_LED_DEVICE_WPS_CONNECTING; - } else if (0==strncmp(state.c_str(), FPD_LED_DEVICE_WPS_CONNECTED, strlen(FPD_LED_DEVICE_WPS_CONNECTED)) && - (strlen(state.c_str()) == strlen(FPD_LED_DEVICE_WPS_CONNECTED)) ){ - LEDstate = dsFPD_LED_DEVICE_WPS_CONNECTED; - } else if (0==strncmp(state.c_str(), FPD_LED_DEVICE_WPS_ERROR, strlen(FPD_LED_DEVICE_WPS_ERROR)) && - (strlen(state.c_str()) == strlen(FPD_LED_DEVICE_WPS_ERROR)) ){ - LEDstate = dsFPD_LED_DEVICE_WPS_ERROR; - } else if (0==strncmp(state.c_str(), FPD_LED_DEVICE_FACTORY_RESET, strlen(FPD_LED_DEVICE_FACTORY_RESET)) && - (strlen(state.c_str()) == strlen(FPD_LED_DEVICE_FACTORY_RESET)) ){ - LEDstate = dsFPD_LED_DEVICE_FACTORY_RESET; - } else if (0==strncmp(state.c_str(), FPD_LED_DEVICE_USB_UPGRADE, strlen(FPD_LED_DEVICE_USB_UPGRADE)) && - (strlen(state.c_str()) == strlen(FPD_LED_DEVICE_USB_UPGRADE)) ){ - LEDstate = dsFPD_LED_DEVICE_USB_UPGRADE; - } else if (0==strncmp(state.c_str(), FPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR, strlen(FPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR)) && - (strlen(state.c_str()) == strlen(FPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR)) ){ - LEDstate = dsFPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR; - } else { - //Invalid parameter - LOGERR("UNKNOWN state : %s", state.c_str()); - success = false; - return WPEFramework::Core::ERROR_BAD_REQUEST; - } - if (dsFPD_LED_DEVICE_NONE!=LEDstate) { - LOGINFO("dsFPSetLEDState state:%s state:%d", state.c_str(), LEDstate); - dsError_t err = dsFPSetLEDState (LEDstate); - if (err) { - LOGERR("dsFPSetLEDState returned error %d", err); - success = false; - return Core::ERROR_GENERAL; - } - } - } - catch (...) - { - LOGERR("Exception in dsFPSetLEDState"); - success = false; - return Core::ERROR_GENERAL; - } - - success = true; - return Core::ERROR_NONE; - } - - } // namespace Plugin -} // namespace WPEFramework diff --git a/LEDControl/LEDControlImplementation.h b/LEDControl/LEDControlImplementation.h deleted file mode 100644 index 7257a71f..00000000 --- a/LEDControl/LEDControlImplementation.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2025 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#pragma once - -#include "Module.h" -#include -#include - -#include -#include "libIARM.h" - -#include -#include - -namespace WPEFramework -{ - namespace Plugin - { - class LEDControlImplementation : public Exchange::ILEDControl - { - public: - // We do not allow this plugin to be copied !! - LEDControlImplementation(); - ~LEDControlImplementation() override; - - // We do not allow this plugin to be copied !! - LEDControlImplementation(const LEDControlImplementation&) = delete; - LEDControlImplementation& operator=(const LEDControlImplementation&) = delete; - - BEGIN_INTERFACE_MAP(LEDControlImplementation) - INTERFACE_ENTRY(Exchange::ILEDControl) - END_INTERFACE_MAP - - private: - bool m_isPlatInitialized; - - public: - Core::hresult GetSupportedLEDStates(IStringIterator*& supportedLEDStates, bool& success) override; - Core::hresult GetLEDState(LEDControlState& ledState) override; - Core::hresult SetLEDState(const string& state, bool& success) override; - - }; - } // namespace Plugin -} // namespace WPEFramework diff --git a/LEDControl/Module.cpp b/LEDControl/Module.cpp deleted file mode 100644 index 69ecca05..00000000 --- a/LEDControl/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2020 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/LEDControl/Module.h b/LEDControl/Module.h deleted file mode 100644 index f750aa9d..00000000 --- a/LEDControl/Module.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2020 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once -#ifndef MODULE_NAME -#define MODULE_NAME Plugin_LEDControl -#endif - -#include -#include - -#undef EXTERNAL -#define EXTERNAL diff --git a/MotionDetection/MotionDetection.cpp b/MotionDetection/MotionDetection.cpp index eb4612b5..ac79028d 100644 --- a/MotionDetection/MotionDetection.cpp +++ b/MotionDetection/MotionDetection.cpp @@ -319,16 +319,15 @@ namespace WPEFramework { returnResponse(false); } - string rSensitivity(sensitivity); - - if (currentMode == 1) { - response["value"] = rSensitivity; - } - else if (currentMode == 2) { - response["name"] = rSensitivity; - } - if (sensitivity) { + string rSensitivity(sensitivity); + + if (currentMode == 1) { + response["value"] = rSensitivity; + } + else if (currentMode == 2) { + response["name"] = rSensitivity; + } free(sensitivity); } returnResponse(true); @@ -368,12 +367,19 @@ namespace WPEFramework { timeSet.m_nowTime = nowTime; timeSet.m_timeRangeArray = (MOTION_DETECTION_Time_t *)malloc(rangeList.Length() * sizeof(MOTION_DETECTION_Time_t)); timeSet.m_rangeCount = rangeList.Length(); + + // Check malloc success + if (timeSet.m_timeRangeArray == nullptr) { + LOGERR("Failed to allocate memory for time range array"); + returnResponse(false); + } + for (int range = 0; range < rangeList.Length(); range++) { JsonObject rangeObj = rangeList[range].Object(); if (rangeObj.HasLabel("startTime") && rangeObj.HasLabel("endTime")) { - unsigned int startTime, endTime = 0; + unsigned int startTime = 0, endTime = 0; getNumberParameterObject(rangeObj, "startTime", startTime); getNumberParameterObject(rangeObj, "endTime", endTime); timeSet.m_timeRangeArray[range].m_startTime = startTime; @@ -392,11 +398,13 @@ namespace WPEFramework { if (rc != MOTION_DETECTION_RESULT_SUCCESS) { LOGERR("Failed to set Active Time..!"); + free(timeSet.m_timeRangeArray); returnResponse(false); } } else { + free(timeSet.m_timeRangeArray); returnResponse(false); } free(timeSet.m_timeRangeArray); diff --git a/README.md b/README.md index 492a6c01..7742d700 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ -# template -Template repository with common workflows for future clone +# entservices-peripherals + +Following plugins are moved to dedicated repositories as per below table: + +| Plugin | Repository | +| --- | --- | +| frontpanel | https://github.com/rdkcentral/entservices-frontpanel | +| ledcontrol | https://github.com/rdkcentral/entservices-ledcontrol | +| motiondetection | https://github.com/rdkcentral/entservices-motiondetection | +| remotecontrol | https://github.com/rdkcentral/entservices-remotecontrol | +| voicecontrol | https://github.com/rdkcentral/entservices-voicecontrol | + +Any further code changes need to come from the above repositories on the `develop` branch. +Ongoing release changes for `8.0`, `8.1`, `8.2`, `8.3`, and `8.4` branches should still use this repository. diff --git a/RemoteControl/CHANGELOG.md b/RemoteControl/CHANGELOG.md deleted file mode 100644 index ed830fd6..00000000 --- a/RemoteControl/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -# Changelog -All notable changes to this RDK Service will be documented in this file. -* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. -* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - * **Added** for new features. - * **Changed** for changes in existing functionality. - * **Deprecated** for soon-to-be removed features. - * **Removed** for now removed features. - * **Fixed** for any bug fixes. - * **Security** in case of vulnerabilities. -* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. - diff --git a/RemoteControl/CMakeLists.txt b/RemoteControl/CMakeLists.txt deleted file mode 100644 index 143a11d9..00000000 --- a/RemoteControl/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2023 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -### - -set(PLUGIN_NAME RemoteControl) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) - -find_package(${NAMESPACE}Plugins REQUIRED) - -add_subdirectory(test) - -add_library(${MODULE_NAME} SHARED - RemoteControl.cpp - Module.cpp) - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -target_include_directories(${MODULE_NAME} PRIVATE ../helpers) - -find_package(CTRLM) -if (CTRLM_FOUND) - find_package(IARMBus) - add_definitions(-DCTRLM_FOUND) - target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS}) - target_include_directories(${MODULE_NAME} PRIVATE ${CTRLM_INCLUDE_DIRS}) - target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES}) -else (CTRLM_FOUND) - target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins) -endif(CTRLM_FOUND) - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/RemoteControl/Module.cpp b/RemoteControl/Module.cpp deleted file mode 100644 index ab461e81..00000000 --- a/RemoteControl/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2023 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/RemoteControl/Module.h b/RemoteControl/Module.h deleted file mode 100644 index 5a85aa78..00000000 --- a/RemoteControl/Module.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2023 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once -#ifndef MODULE_NAME -#define MODULE_NAME RemoteControl -#endif - -#include -#include - -#undef EXTERNAL -#define EXTERNAL diff --git a/RemoteControl/README.md b/RemoteControl/README.md deleted file mode 100644 index 61d9b4d1..00000000 --- a/RemoteControl/README.md +++ /dev/null @@ -1,18 +0,0 @@ ------------------ -Build: - -bitbake thunder-plugins - ------------------ -Test: - - -Methods common to typical plugins - getQuirks() and getApiVersionNumber() (not documented in official RemoteControl service API) - -curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "org.rdk.RemoteControl.1.getQuirks"}' http://127.0.0.1:9998/jsonrpc - -curl -d '{"jsonrpc":"2.0","id":"4","method":"org.rdk.RemoteControl.1.getApiVersionNumber"}' http://127.0.0.1:9998/jsonrpc - - - - diff --git a/RemoteControl/RemoteControl.conf.in b/RemoteControl/RemoteControl.conf.in deleted file mode 100644 index b765c1e7..00000000 --- a/RemoteControl/RemoteControl.conf.in +++ /dev/null @@ -1,3 +0,0 @@ -precondition = ["Platform"] -callsign = "org.rdk.RemoteControl" -autostart = "false" diff --git a/RemoteControl/RemoteControl.config b/RemoteControl/RemoteControl.config deleted file mode 100644 index 5a1edbd4..00000000 --- a/RemoteControl/RemoteControl.config +++ /dev/null @@ -1,22 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2023 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -### - -set (autostart false) -set (preconditions Platform) -set (callsign "org.rdk.RemoteControl") diff --git a/RemoteControl/RemoteControl.cpp b/RemoteControl/RemoteControl.cpp deleted file mode 100644 index 2e2d93e8..00000000 --- a/RemoteControl/RemoteControl.cpp +++ /dev/null @@ -1,902 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2023 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "RemoteControl.h" -#include "libIBusDaemon.h" -#include "UtilsUnused.h" -#include "UtilsCStr.h" -#include "UtilsJsonRpc.h" -#include "UtilsIarm.h" -#include "UtilsString.h" - -#include - -#define IARM_FACTORY_RESET_TIMEOUT (15 * 1000) // 15 seconds, in milliseconds -#define IARM_IRDB_CALLS_TIMEOUT (10 * 1000) // 10 seconds, in milliseconds - -using namespace std; - -#define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 5 -#define API_VERSION_NUMBER_PATCH 0 - -namespace WPEFramework { - - namespace { - static Plugin::Metadata metadata( - // Version (Major, Minor, Patch) - API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, - // Preconditions - {}, - // Terminations - {}, - // Controls - {} - ); - } - - namespace Plugin { - - SERVICE_REGISTRATION(RemoteControl, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); - - RemoteControl* RemoteControl::_instance = nullptr; - - RemoteControl::RemoteControl() - : PluginHost::JSONRPC() - , m_apiVersionNumber((uint32_t)-1) /* default max uint32_t so everything gets enabled */ //TODO(MROLLINS) Can't we access this from jsonrpc interface? - { - LOGINFO("ctor"); - RemoteControl::_instance = this; - - Register("getApiVersionNumber", &RemoteControl::getApiVersionNumber, this); - Register("startPairing", &RemoteControl::startPairing, this); - Register("stopPairing", &RemoteControl::stopPairing, this); - Register("getNetStatus", &RemoteControl::getNetStatus, this); - Register("getIRDBManufacturers", &RemoteControl::getIRDBManufacturers, this); - Register("getIRDBModels", &RemoteControl::getIRDBModels, this); - Register("getIRCodesByAutoLookup", &RemoteControl::getIRCodesByAutoLookup,this); - Register("getIRCodesByNames", &RemoteControl::getIRCodesByNames, this); - Register("setIRCode", &RemoteControl::setIRCode, this); - Register("clearIRCodes", &RemoteControl::clearIRCodes, this); - Register("getLastKeypressSource", &RemoteControl::getLastKeypressSource, this); - Register("configureWakeupKeys", &RemoteControl::configureWakeupKeys, this); - Register("initializeIRDB", &RemoteControl::initializeIRDB, this); - Register("findMyRemote", &RemoteControl::findMyRemote, this); - Register("factoryReset", &RemoteControl::factoryReset, this); - - m_hasOwnProcess = false; - setApiVersionNumber(1); - } - - RemoteControl::~RemoteControl() - { - //LOGINFO("dtor"); - } - - const string RemoteControl::Initialize(PluginHost::IShell* /* service */) - { - InitializeIARM(); - // On success return empty, to indicate there is no error text. - return (string()); - } - - void RemoteControl::Deinitialize(PluginHost::IShell* /* service */) - { - DeinitializeIARM(); - RemoteControl::_instance = nullptr; - } - - void RemoteControl::InitializeIARM() - { - if (Utils::IARM::init()) - { - m_hasOwnProcess = true; - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_RCU_STATUS, remoteEventHandler) ); - // Register for ControlMgr pairing-related events - IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_VALIDATION_STATUS, remoteEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_CONFIGURATION_COMPLETE, remoteEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_RF4CE_PAIRING_WINDOW_TIMEOUT, remoteEventHandler) ); - } - else - m_hasOwnProcess = false; - } - - //TODO(MROLLINS) - we need to install crash handler to ensure DeinitializeIARM gets called - void RemoteControl::DeinitializeIARM() - { - if (m_hasOwnProcess) - { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_RCU_STATUS, remoteEventHandler) ); - // Remove handlers for ControlMgr pairing-related events - IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_VALIDATION_STATUS, remoteEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_CONFIGURATION_COMPLETE, remoteEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_RCU_IARM_EVENT_RF4CE_PAIRING_WINDOW_TIMEOUT, remoteEventHandler) ); - - IARM_CHECK( IARM_Bus_Disconnect() ); - IARM_CHECK( IARM_Bus_Term() ); - m_hasOwnProcess = false; - } - } - - void RemoteControl::remoteEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if (RemoteControl::_instance) - RemoteControl::_instance->iarmEventHandler(owner, eventId, data, len); - else - LOGWARN("WARNING - cannot handle btremote IARM events without a RemoteControl plugin instance!"); - } - - //bt handlers - void RemoteControl::iarmEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if (strcmp(owner, CTRLM_MAIN_IARM_BUS_NAME)) - { - LOGERR("ERROR - unexpected event: owner %s, eventId: %d, data: %p, size: %d.", - owner, (int)eventId, data, len); - return; - } - - if ((data == NULL) || (len == 0)) - { - LOGERR("ERROR - event with NO DATA: eventId: %d, data: %p, size: %d.", (int)eventId, data, len); - return; - } - ctrlm_main_iarm_event_json_t *eventData = static_cast(data); - - switch(eventId) { - case CTRLM_RCU_IARM_EVENT_RCU_STATUS: - case CTRLM_RCU_IARM_EVENT_CONFIGURATION_COMPLETE: - case CTRLM_RCU_IARM_EVENT_RF4CE_PAIRING_WINDOW_TIMEOUT: - LOGWARN("Got CTRLM_RCU_IARM_EVENT event."); - onStatus(eventData); - break; - case CTRLM_RCU_IARM_EVENT_VALIDATION_STATUS: - LOGWARN("Got CTRLM_RCU_IARM_EVENT_VALIDATION_STATUS event."); - onValidation(eventData); - break; - default: - LOGERR("ERROR - unexpected ctrlm event: eventId: %d, data: %p, size: %d.", - (int)eventId, data, len); - break; - } - } // End iarmEventHandler() - - //Begin methods - uint32_t RemoteControl::getApiVersionNumber(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - response["version"] = m_apiVersionNumber; - returnResponse(true); - } - - uint32_t RemoteControl::startPairing(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_START_PAIRING, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_START_PAIRING Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("START PAIRING call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_START_PAIRING returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::stopPairing(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_STOP_PAIRING, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_STOP_PAIRING Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("STOP PAIRING call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_STOP_PAIRING returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::getNetStatus(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_GET_RCU_STATUS, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_GET_RCU_STATUS Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("GET RCU STATUS call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_GET_RCU_STATUS returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::getIRDBManufacturers(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - // The default timeout for IARM calls is 5 seconds, but this call could take longer since the results could come from a cloud IRDB. - // So increase the timeout to IARM_IRDB_CALLS_TIMEOUT - res = IARM_Bus_Call_with_IPCTimeout(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_IR_MANUFACTURERS, (void *)call, totalsize, IARM_IRDB_CALLS_TIMEOUT); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_MANUFACTURERS Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("IRDB MANUFACTURERS call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_MANUFACTURERS returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::getIRDBModels(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - // The default timeout for IARM calls is 5 seconds, but this call could take longer since the results could come from a cloud IRDB. - // So increase the timeout to IARM_IRDB_CALLS_TIMEOUT - res = IARM_Bus_Call_with_IPCTimeout(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_IR_MODELS, (void *)call, totalsize, IARM_IRDB_CALLS_TIMEOUT); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_MODELS Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("IRDB MODELS call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_MODELS returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::getIRCodesByAutoLookup(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - // The default timeout for IARM calls is 5 seconds, but this call could take longer since the results could come from a cloud IRDB. - // So increase the timeout to IARM_IRDB_CALLS_TIMEOUT - res = IARM_Bus_Call_with_IPCTimeout(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_IR_AUTO_LOOKUP, (void *)call, totalsize, IARM_IRDB_CALLS_TIMEOUT); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_AUTO_LOOKUP Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("IRDB AUTO LOOKUP call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_AUTO_LOOKUP returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::getIRCodesByNames(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - // The default timeout for IARM calls is 5 seconds, but this call could take longer since the results could come from a cloud IRDB. - // So increase the timeout to IARM_IRDB_CALLS_TIMEOUT - res = IARM_Bus_Call_with_IPCTimeout(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_IR_CODES, (void *)call, totalsize, IARM_IRDB_CALLS_TIMEOUT); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_CODES Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("GET IR CODES call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_CODES returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::setIRCode(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_IR_SET_CODE, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_SET_CODE Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("SET IR CODES call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_SET_CODE returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::clearIRCodes(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_IR_CLEAR_CODE, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_CLEAR_CODE Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("CLEAR IR CODES call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_CLEAR_CODE returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::getLastKeypressSource(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_LAST_KEYPRESS_GET, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_LAST_KEYPRESS_GET Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("GET LAST KEYPRESS call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_LAST_KEYPRESS_GET returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::configureWakeupKeys(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_WRITE_RCU_WAKEUP_CONFIG, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_WRITE_RCU_WAKEUP_CONFIG Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("WRITE RCU WAKEUP CONFIG call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_WRITE_RCU_WAKEUP_CONFIG returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::initializeIRDB(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - res = IARM_Bus_Call_with_IPCTimeout(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_IR_INITIALIZE, (void *)call, totalsize, IARM_IRDB_CALLS_TIMEOUT); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_INITIALIZE Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("INITIALIZE IRDB call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_IR_INITIALIZE returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::findMyRemote(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_FIND_MY_REMOTE, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_FIND_MY_REMOTE Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("FIND MY REMOTE call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_FIND_MY_REMOTE returned FAILURE!"); - - returnResponse(bSuccess); - } - - uint32_t RemoteControl::factoryReset(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_main_iarm_call_json_t *call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = false; - size_t totalsize = 0; - - parameters.ToString(jsonParams); - totalsize = sizeof(ctrlm_main_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_main_iarm_call_json_t*)calloc(1, totalsize); - - if (call == NULL) - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - returnResponse(bSuccess); - } - - call->api_revision = CTRLM_MAIN_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - - // The default timeout for IARM calls is 5 seconds, but this call could take longer and we need to ensure the remotes receive - // the message before the larger system factory reset operation continues. Therefore, make this timeout longer. - res = IARM_Bus_Call_with_IPCTimeout(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_MAIN_IARM_CALL_FACTORY_RESET, (void *)call, totalsize, IARM_FACTORY_RESET_TIMEOUT); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_FACTORY_RESET Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - free(call); - returnResponse(bSuccess); - } - - JsonObject result; - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - free(call); - - if (bSuccess) - LOGINFO("FACTORY RESET call SUCCESS!"); - else - LOGERR("ERROR - CTRLM_MAIN_IARM_CALL_FACTORY_RESET returned FAILURE!"); - - returnResponse(bSuccess); - } - //End methods - - //Begin events - void RemoteControl::onStatus(ctrlm_main_iarm_event_json_t* eventData) - { - JsonObject params; - - params.FromString(eventData->payload); - - sendNotify("onStatus", params); - } - - void RemoteControl::onValidation(ctrlm_main_iarm_event_json_t* eventData) - { - JsonObject params; - - params.FromString(eventData->payload); - - sendNotify("onValidation", params); - } - //End events - - //Begin local private utility methods - void RemoteControl::setApiVersionNumber(unsigned int apiVersionNumber) - { - LOGINFO("setting version: %d", (int)apiVersionNumber); - m_apiVersionNumber = apiVersionNumber; - } - //End local private utility methods - } // namespace Plugin -} // namespace WPEFramework - diff --git a/RemoteControl/RemoteControl.h b/RemoteControl/RemoteControl.h deleted file mode 100644 index 0e42a853..00000000 --- a/RemoteControl/RemoteControl.h +++ /dev/null @@ -1,116 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2023 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once - -#include "Module.h" -#include "libIBus.h" - -#include "ctrlm_ipc.h" -#include "ctrlm_ipc_rcu.h" -#include "ctrlm_ipc_ble.h" - -#define IARM_REMOTECONTROL_PLUGIN_NAME "Remote_Control" - - -namespace WPEFramework { - - namespace Plugin { - - class RemoteControl; // Forward declaration - - // This is a server for a JSONRPC communication channel. - // For a plugin to be capable to handle JSONRPC, inherit from PluginHost::JSONRPC. - // By inheriting from this class, the plugin realizes the interface PluginHost::IDispatcher. - // This realization of this interface implements, by default, the following methods on this plugin - // - exists - // - register - // - unregister - // Any other method to be handled by this plugin can be added can be added by using the - // templated methods Register on the PluginHost::JSONRPC class. - // As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC, - // this class exposes a public method called, Notify(), using this methods, all subscribed clients - // will receive a JSONRPC message as a notification, in case this method is called. - // Note that most of the above is now inherited from the AbstractPlugin class. - class RemoteControl : public PluginHost::IPlugin, public PluginHost::JSONRPC { - private: - typedef Core::JSON::String JString; - typedef Core::JSON::ArrayType JStringArray; - typedef Core::JSON::ArrayType JObjectArray; - typedef Core::JSON::Boolean JBool; - - // We do not allow this plugin to be copied !! - RemoteControl(const RemoteControl&) = delete; - RemoteControl& operator=(const RemoteControl&) = delete; - - //Begin methods - uint32_t getApiVersionNumber(const JsonObject& parameters, JsonObject& response); - uint32_t startPairing(const JsonObject& parameters, JsonObject& response); - uint32_t stopPairing(const JsonObject& parameters, JsonObject& response); - uint32_t getNetStatus(const JsonObject& parameters, JsonObject& response); - uint32_t getIRDBManufacturers(const JsonObject& parameters, JsonObject& response); - uint32_t getIRDBModels(const JsonObject& parameters, JsonObject& response); - uint32_t getIRCodesByAutoLookup(const JsonObject& parameters, JsonObject& response); - uint32_t getIRCodesByNames(const JsonObject& parameters, JsonObject& response); - uint32_t setIRCode(const JsonObject& parameters, JsonObject& response); - uint32_t clearIRCodes(const JsonObject& parameters, JsonObject& response); - uint32_t getLastKeypressSource(const JsonObject& parameters, JsonObject& response); - uint32_t configureWakeupKeys(const JsonObject& parameters, JsonObject& response); - uint32_t initializeIRDB(const JsonObject& parameters, JsonObject& response); - uint32_t findMyRemote(const JsonObject& parameters, JsonObject& response); - uint32_t factoryReset(const JsonObject& parameters, JsonObject& response); - //End methods - - //Begin events - void onStatus(ctrlm_main_iarm_event_json_t* eventData); - void onValidation(ctrlm_main_iarm_event_json_t* eventData); - //End events - - public: - RemoteControl(); - virtual ~RemoteControl(); - //IPlugin methods - virtual const string Initialize(PluginHost::IShell* service) override; - virtual void Deinitialize(PluginHost::IShell* service) override; - virtual string Information() const override { return {}; } - - BEGIN_INTERFACE_MAP(RemoteControl) - INTERFACE_ENTRY(PluginHost::IPlugin) - INTERFACE_ENTRY(PluginHost::IDispatcher) - END_INTERFACE_MAP - - private: - void InitializeIARM(); - void DeinitializeIARM(); - // Handlers for ControlMgr BT Remote events - static void remoteEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - void iarmEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - // Local utility methods - void setApiVersionNumber(uint32_t apiVersionNumber); - - public: - static RemoteControl* _instance; - private: - // Generic members - uint32_t m_apiVersionNumber; - bool m_hasOwnProcess; - }; - } // namespace Plugin -} // namespace WPEFramework diff --git a/RemoteControl/test/CMakeLists.txt b/RemoteControl/test/CMakeLists.txt deleted file mode 100644 index 12d256c2..00000000 --- a/RemoteControl/test/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -### - -set(PLUGIN_NAME remoteControlTestClient) -find_package(${NAMESPACE}Core REQUIRED) - -if (USE_THUNDER_R4) - find_package(${NAMESPACE}COM REQUIRED) -else () - find_package(${NAMESPACE}Protocols REQUIRED) -endif (USE_THUNDER_R4) - -add_executable(${PLUGIN_NAME} remoteControlTestClient.cpp) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES - ) - -target_link_libraries(${PLUGIN_NAME} PRIVATE ${NAMESPACE}Core::${NAMESPACE}Core) - -if (USE_THUNDER_R4) -target_link_libraries(${PLUGIN_NAME} PRIVATE ${NAMESPACE}COM::${NAMESPACE}COM ${NAMESPACE}WebSocket::${NAMESPACE}WebSocket) -else () -target_link_libraries(${PLUGIN_NAME} PRIVATE ${NAMESPACE}Protocols::${NAMESPACE}Protocols) -endif (USE_THUNDER_R4) - - -install(TARGETS ${PLUGIN_NAME} DESTINATION bin) diff --git a/RemoteControl/test/Module.h b/RemoteControl/test/Module.h deleted file mode 100644 index 9b92fd23..00000000 --- a/RemoteControl/test/Module.h +++ /dev/null @@ -1,27 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2023 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once - -#ifndef MODULE_NAME -#define MODULE_NAME remoteControlTestClient -#endif - -#include -#include diff --git a/RemoteControl/test/remoteControlTestClient.cpp b/RemoteControl/test/remoteControlTestClient.cpp deleted file mode 100644 index 14740756..00000000 --- a/RemoteControl/test/remoteControlTestClient.cpp +++ /dev/null @@ -1,860 +0,0 @@ -/* - * If not stated otherwise in this file or this component's license file - * the following copyright and licenses apply: - * - * Copyright 2018 RDK Management - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file remoteControlTestClient.cpp - * @brief Thunder Plugin based Implementation of CPP Test Client for RemoteControl service API's. - * @reference RDK-28622. - */ - -#include -#include -#include -#include - -#include "Module.h" - -#define SYSSRV_CALLSIGN "org.rdk.RemoteControl.1" -#define SERVER_DETAILS "127.0.0.1:9998" -#define INVOKE_TIMEOUT (5000) - -using namespace std; -using namespace WPEFramework; -// Global data used to for arguments to pass to the plugin methods -int deviceID = 1; - -string currentTVCode = ""; -string currentAMPCode = ""; -string currentModel = ""; -string avDevType = "TV"; -int infoFrameIndex = 0; -int netType = 1; -int timeout = 0; -int remoteId = 1; -string manufacturer; - -const std::vector beepLevels = {"off","mid","high"}; -size_t beepLevelIdx = 0; -string beepLevel = beepLevels[0]; - -/* Declare module name */ -MODULE_NAME_DECLARATION(BUILD_REFERENCE) - -/* This section can be used for API validation logic. */ -void showMenu() -{ - std::cout<< std::endl; - std::cout<< std::endl; - std::cout<<"RemoteControl API Methods: Current Parameter Settings:\n"; - std::cout<<"0.getQuirks a.Toggle 'netType' [0 for RF4CE | 1 for BLE]: " << netType << "\n"; - std::cout<<"1.getApiVersionNumber b.Enter the 'remoteId' values [1 thru 9]: " << remoteId << "\n"; - std::cout<<"2.startPairing c.Toggle 'avDevType' [TV | AMP]: " << avDevType << "\n"; - std::cout<<"3.getNetStatus d.Enter the 'timeout' value: [0 - use default | Greater than 0 - use value]: " << timeout << "\n"; - std::cout<<"4.getIRDBManufacturers e.Enter the 'tvCode' value: " << currentTVCode << "\n"; - std::cout<<"5.getIRDBModels f.Enter the 'avrCode' value: " << currentAMPCode << "\n"; - std::cout<<"6.getIRCodesByNames g.Enter the 'model' value (for getIRCodesByNames only): " << currentModel << "\n"; - std::cout<<"7.setIRCode h.Cycle thru 'level' values (for findMyRemote only): " << beepLevel << "\n"; - std::cout<<"8.clearIRCodes\n"; - std::cout<<"9.getIRCodesByAutoLookup\n"; - std::cout<<"10.getLastKeypressSource\n"; - std::cout<<"11.initializeIRDB\n"; - std::cout<<"12.findMyRemote\n"; - - std::cout<<"\nEnter your choice: "; -} - -void formatForDisplay(std::string& str) -{ - const int indent = 4; - int level = 0; - - for (size_t i = 0; i < str.size(); i++) - { - if (str[i] == ',') - { - str.insert((i+1), 1, '\n'); // insert after - if (level > 0) - { - str.insert((i+2), (level * indent), ' '); - } - } - else if (str[i] == '}') - { - level--; - if (level < 0) level = 0; - str.insert((i), 1, '\n'); // insert before - if (level > 0) - { - // after the newline, but before the curly brace - str.insert((i+1), (level * indent), ' '); - } - i += (level * indent) + 1; // put i back on the curly brace - } - else if (str[i] == '{') - { - level++; - str.insert((i+1), 1, '\n'); // insert after - if (level > 0) - { - str.insert((i+2), (level * indent), ' '); - } - } - } -} - -#define MAX_FORMATTED_COLUMNS 4 -// Takes output from above (formatForDisplay) as input. -// Intended to format "remoteData" info to display in less vertical space. -void formatColumns(std::string& str) -{ - const int colsize = 52; - int width, numcols; - std::size_t inidx = 0; - std::size_t idxRemoteData = std::string::npos; - - std::string outstr; - std::string colstr[MAX_FORMATTED_COLUMNS]; - int collines[MAX_FORMATTED_COLUMNS]; - - // Auto-sense how many columns we can display - struct winsize console; - ioctl(STDOUT_FILENO, TIOCGWINSZ, &console); - width = console.ws_col; - numcols = width / colsize; - if (numcols > MAX_FORMATTED_COLUMNS) numcols = MAX_FORMATTED_COLUMNS; - - //std::cout<<"width: "<< width <<"\n"; - - if (numcols < 2) - { - // If we can't have more than one column, there is nothing to do here. - return; - } - // Find index where "remoteData": is located - idxRemoteData = str.find("remoteData"); - if (idxRemoteData == std::string::npos) - { - // Failure - no remoteData in the input string. Just bail now. - return; - } - - for (inidx = 0; inidx < str.size(); inidx++) // outermost string transcribe character loop - { - outstr.push_back(str[inidx]); - - if (inidx > idxRemoteData) - { - if (str[inidx] == '{') - { - std::size_t idx; - std::size_t pad; - std::string outline; - int outlines = 0; - int totallines = 0; - int baselines = 0; - int xtra = 0; - - // We have encountered a remoteData block. - // Transcribe to include the curly brace newline... - do - { - inidx++; - outstr.push_back(str[inidx]); - } - while(str[inidx] != '\n'); - // ...then update the input index to the first character after the newline. - inidx++; - // Count the number of lines between here and the next closing curly brace. - for (std::size_t i = inidx; i < str.size(); i++) - { - if (str[i] == '\n') - totallines++; - else if (str[i] == '}') - break; - } - // Allocate the lines to the number of columns we have. - baselines = totallines / numcols; - xtra = totallines % numcols; - outlines = baselines + ((xtra > 0) ? 1 : 0); // We'll use this later... - for (int i = 0; i < numcols; i++) - { - collines[i] = baselines + ((xtra > 0) ? 1 : 0); - if (xtra > 0) xtra--; - } - // Load the column strings from the input. - // This will also advance the input index past the entire block. - for (int i = 0; i < numcols; i++) - { - colstr[i].clear(); - for (; inidx < str.size(); inidx++) - { - if (collines[i] > 0) - { - colstr[i].push_back(str[inidx]); - if (str[inidx] == '\n') - { - collines[i]--; - } - } - else - { - break; - } - } - } - // At this point, the input index is set to the character AFTER the final newline - // in the input block. But we want to leave the input index AT the final newline, - // to get the correct continuation of the outer transcription loop. So we must - // move it back by one, here. - inidx--; - - // Build line strings encompassing all the columns, - // and add them to the output string. - for (int i = 0; i < outlines; i++) - { - for (int j = 0; j < numcols; j++) - { - if (!colstr[j].empty() && (totallines > 0)) - { - idx = colstr[j].find('\n'); - if (idx != std::string::npos) - { - outline.append(colstr[j], 0, idx+1); - // Remove the line we just appended, from the start of the colstr. - colstr[j].erase(0, idx+1); - // Count the line as being handled - done with. - totallines--; - // Except for the last column, clobber the newline, - // and pad the line out to the column width, using spaces. - // We leave things as they are for the last column. - // We also leave the last line out of the total number - // of lines alone (newline intact), because even if it isn't - // in the rightmost column, there won't be any more lines! - if ((j < (numcols - 1)) && (totallines > 0)) - { - // Get rid of the newline - outline.pop_back(); // We all agree to use C++11, right? - // Determine how many spaces we need. - pad = ((std::size_t)colsize) - idx; - // Append spaces to the outline. - outline.append(pad, ' '); - } - } - } - } - // Add this cross-column line to the overall output, - outstr.append(outline); - outline.clear(); - } - } - } - } - - // Return the output in the original reference input string - str.clear(); - str.append(outstr); -} - -// Event parameters sent to JSONRPC::Client event handlers, have somehow -// acquired overall quotation marks, with internal quotes backslash-escaped. -// They weren't presented that way in the past, but now somehow they are. -// This function tries to detect and correct that, for console output. -// Should have no effect if the in/out string isn't inside double-quotes. -void removeJsonQuotes(std::string& str) -{ - if ((str.front() == '"') && (str.back() == '"')) - { - str.erase(0, 1); - str.pop_back(); - - for (size_t i = 0; i < str.size(); i++) - { - if ((i < (str.size() - 1)) && (str[i] == 0x5c) && (str[i+1] == '"')) - { - str.erase(i, 1); - } - } - } -} - -// Make changes in parameters -void handleParams(string& cmd) -{ - switch(cmd[0]) - { - case 'a': - { - // netType - if (netType == 1) - { - netType = 0; - } - else - { - netType = 1; - } - } - break; - - case 'b': - { - // Enter rf4ce remoteId - std::cout << "Enter the remoteId (in decimal): "; - std::cin >> remoteId; - if (std::cin.peek() == '\n') - { - string temp; - std::getline(std::cin, temp); - } - } - break; - - case 'c': - { - // avDevType - if (avDevType == "AMP") - { - avDevType = "TV"; - } - else - { - avDevType = "AMP"; - } - } - break; - - case 'd': - { - // Enter timeout - std::cout << "Enter the timeout (0 for default): "; - std::cin >> timeout; - if (std::cin.peek() == '\n') - { - string temp; - std::getline(std::cin, temp); - } - } - break; - - case 'e': - { - // Enter TV code - string digits; - while (digits.empty()) - { - std::cout << "Enter the TV code: "; - std::getline(std::cin, digits); - } - currentTVCode = digits; - } - break; - - case 'f': - { - // Enter AVR code - string digits; - while (digits.empty()) - { - std::cout << "Enter the AVR code: "; - std::getline(std::cin, digits); - } - currentAMPCode = digits; - } - break; - - case 'g': - { - // Enter model - string model = ""; - std::cout << "Enter the model (return for empty string): "; - std::getline(std::cin, model); - - if(!model.empty()) - { - currentModel = model; - } - else - { - currentModel = ""; - } - } - break; - - case 'h': - { - // Cycle through level values - beepLevelIdx++; - if (beepLevelIdx >= beepLevels.size()) - { - beepLevelIdx = 0; - } - beepLevel = beepLevels[beepLevelIdx]; - } - break; - } -} - -/* This section is related to the event handler implementation for RemoteControl Plugin Events. */ - -namespace Handlers { - /* Event Handlers */ - static void onStatus(const Core::JSON::String& parameters) { - std::string message; - parameters.ToString(message); - removeJsonQuotes(message); - std::cout << "\n[RemoteControlEvt] " << __FUNCTION__ << ": " << message << std::endl; - } -} - -int main(int argc, char** argv) -{ - int retStatus = -1; - JSONRPC::LinkType * remoteObject = NULL; - - int choice; - string cmd; - uint32_t ret; - string lastCmd; - - Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T(SERVER_DETAILS))); - - // Security Token - std::cout << "Retrieving security token" << std::endl; - std::string sToken; - - FILE *pSecurity = popen("/usr/bin/WPEFrameworkSecurityUtility", "r"); - if(pSecurity) { - JsonObject pSecurityJson; - std::string pSecurityOutput; - int pSecurityOutputTrimIndex; - std::array pSecurityBuffer; - - while(fgets(pSecurityBuffer.data(), 256, pSecurity) != NULL) { - pSecurityOutput += pSecurityBuffer.data(); - } - pclose(pSecurity); - - pSecurityOutputTrimIndex = (int)pSecurityOutput.find('{'); - if(pSecurityOutputTrimIndex == (int)std::string::npos) { - std::cout << "Security Utility returned unexpected output" << std::endl; - } else { - if(pSecurityOutputTrimIndex > 0) { - std::cout << "Trimming output from Security Utility" << std::endl; - pSecurityOutput = pSecurityOutput.substr(pSecurityOutputTrimIndex); - } - pSecurityJson.FromString(pSecurityOutput); - if(pSecurityJson["success"].Boolean() == true) { - std::cout << "Security Token retrieved successfully!" << std::endl; - sToken = "token=" + pSecurityJson["token"].String(); - } else { - std::cout << "Security Token retrieval failed!" << std::endl; - } - } - } else { - std::cout << "Failed to open security utility" << std::endl; - } - // End Security Token - - std::cout << "Using callsign: " << SYSSRV_CALLSIGN << std::endl; - - if (NULL == remoteObject) { - remoteObject = new JSONRPC::LinkType(_T(SYSSRV_CALLSIGN), _T(""), false, sToken); - if (NULL == remoteObject) { - std::cout << "JSONRPC::Client initialization failed" << std::endl; - - } else { - - { - // Create a controller client - static auto& controllerClient = *new WPEFramework::JSONRPC::LinkType("", "", false, sToken); - // In case the plugin isn't activated already, try to start it, BEFORE registering for the events! - string strres; - JsonObject params; - params["callsign"] = SYSSRV_CALLSIGN; - JsonObject result; - ret = controllerClient.Invoke(2000, "activate", params, result); - result.ToString(strres); - std::cout<<"\nstartup result : "<< strres <<"\n"; - } - - /* Register handlers for Event reception. */ - std::cout << "\nSubscribing to event handlers\n" << std::endl; - if (remoteObject->Subscribe(1000, _T("onStatus"), - &Handlers::onStatus) == Core::ERROR_NONE) { - std::cout << "Subscribed to : onStatus" << std::endl; - } else { - std::cout << "Failed to Subscribe notification handler : onStatus" << std::endl; - } - - /* API Validation Logic. */ - while (true) { - while (cmd.empty()) - { - showMenu(); - std::getline(std::cin, cmd); - lastCmd = cmd; - } - if ((cmd[0] >= '0') && (cmd[0] <= '9')) - { - choice = stoi(cmd); - } - else if ((cmd[0] >= 'a') && (cmd[0] <= 'h')) - { - handleParams(cmd); - cmd.clear(); - continue; - } - else return 0; - - { - JsonObject result; // The Clear method can leave crud. A new instance off the stack works better. - - switch (choice) { - case 0: - { - JsonObject params; - string res; - ret = remoteObject->Invoke(INVOKE_TIMEOUT, - _T("getQuirks"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl getQuirks call - Success!\n"; - } else { - std::cout<<"RemoteControl getQuirks call - failed!\n"; - } - std::cout<<"result : "<Invoke(INVOKE_TIMEOUT, - _T("getApiVersionNumber"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl getApiVersionNumber call - Success!\n"; - } else { - std::cout<<"RemoteControl getApiVersionNumber call - failed!\n"; - } - std::cout<<"result : "< 0) { - params["timeout"] = timeout; - } - - ret = remoteObject->Invoke(INVOKE_TIMEOUT, - _T("startPairing"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - if (result["success"].Boolean()) { - std::cout<<"\nRemoteControl startPairing call success\n"; - } else { - std::cout<<"\nRemoteControl startPairing call failure\n"; - } - std::cout<<"result : "<Invoke(INVOKE_TIMEOUT, - _T("getNetStatus"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - formatForDisplay(res); - formatColumns(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl getNetStatus call - Success!\n"; - } else { - std::cout<<"RemoteControl getNetStatus call - failed!\n"; - } - std::cout<<"result : "<> manufacturer; - params["manufacturer"] = manufacturer; - - - ret = remoteObject->Invoke(INVOKE_TIMEOUT, - _T("getIRDBManufacturers"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl getIRDBManufacturers call - Success!\n"; - } else { - std::cout<<"RemoteControl getIRDBManufacturers call - failed!\n"; - } - std::cout<<"result : "<< res <<"\n"; - } - break; - - case 5: - { - JsonObject params; - string model; - string res; - - params["netType"] = netType; - params["avDevType"] = avDevType; - - std::cout<<"\nEnter the full manufacturer name : "; - std::cin>> manufacturer; - params["manufacturer"] = manufacturer; - - std::cout<<"\nEnter at least part of a model name : "; - std::cin>> model; - params["model"] = model; - - - ret = remoteObject->Invoke(INVOKE_TIMEOUT, - _T("getIRDBModels"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl getIRDBModels call - Success!\n"; - } else { - std::cout<<"RemoteControl getIRDBModels call - failed!\n"; - } - std::cout<<"result : "<< res <<"\n"; - } - break; - - case 6: - { - JsonObject params; - string model; - string res; - - params["netType"] = netType; - params["avDevType"] = avDevType; - - std::cout<<"\nEnter the full manufacturer name : "; - std::cin>> manufacturer; - params["manufacturer"] = manufacturer; - - if(!currentModel.empty()) - { - params["model"] = currentModel; - } - - - ret = remoteObject->Invoke(INVOKE_TIMEOUT, - _T("getIRCodesByNames"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl getIRCodesByNames call - Success!\n"; - } else { - std::cout<<"RemoteControl getIRCodesByNames call - failed!\n"; - } - std::cout<<"result : "<< res <<"\n"; - } - break; - - case 7: - { - JsonObject params; - string res; - params["netType"] = netType; - params["remoteId"] = remoteId; - params["avDevType"] = avDevType; - - if(avDevType=="TV") - { - params["code"] = currentTVCode; - } - else - { - params["code"] = currentAMPCode; - } - - ret = remoteObject->Invoke(INVOKE_TIMEOUT, - _T("setIRCode"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - formatForDisplay(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl setIRCode call - Success!\n"; - } else { - std::cout<<"RemoteControl setIRCode call - failed!\n"; - } - std::cout<<"result : "<Invoke(INVOKE_TIMEOUT, - _T("clearIRCodes"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - formatForDisplay(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl clearIRCodes call - Success!\n"; - } else { - std::cout<<"RemoteControl clearIRCodes call - failed!\n"; - } - std::cout<<"result : "<Invoke(INVOKE_TIMEOUT, - _T("getIRCodesByAutoLookup"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl getIRCodesByAutoLookup call - Success!\n"; - } else { - std::cout<<"RemoteControl getIRCodesByAutoLookup call - failed!\n"; - } - std::cout<<"result : "<< res <<"\n"; - } - break; - - case 10: - { - JsonObject params; - string res; - params["netType"] = netType; - ret = remoteObject->Invoke(1000, - _T("getLastKeypressSource"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - formatForDisplay(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl getLastKeypressSource call - Success!\n"; - } else { - std::cout<<"RemoteControl getLastKeypressSource call - failed!\n"; - } - std::cout<<"result : "<Invoke(INVOKE_TIMEOUT, - _T("initializeIRDB"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - formatForDisplay(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl initializeIRDB call - Success!\n"; - } else { - std::cout<<"RemoteControl initializeIRDB call - failed!\n"; - } - std::cout<<"result : "<Invoke(INVOKE_TIMEOUT, - _T("findMyRemote"), params, result); - std::cout<<"RemoteControl Invoke ret : "<< ret <<"\n"; - result.ToString(res); - if (result["success"].Boolean()) { - std::cout<<"RemoteControl findMyRemote call - Success!\n"; - } else { - std::cout<<"RemoteControl findMyRemote call - failed!\n"; - } - std::cout<<"result : "< "; - cmd.clear(); - - std::getline(std::cin, cmd); - if (cmd.empty()) - { - cmd.clear(); - lastCmd.clear(); - } - else if ((cmd[0] == 'r') || (cmd[0] == 'R')) - cmd = lastCmd; - else if ((cmd[0] >= '0') && (cmd[0] <= '9')) - { - choice = stoi(cmd); - lastCmd = cmd; - } - else if ((cmd[0] >= 'a') && (cmd[0] <= 'h')) - { - } - else - break; - - } - } - } - - return retStatus; -} diff --git a/Tests/L1Tests/CMakeLists.txt b/Tests/L1Tests/CMakeLists.txt index 5c74de03..1963b33a 100755 --- a/Tests/L1Tests/CMakeLists.txt +++ b/Tests/L1Tests/CMakeLists.txt @@ -105,15 +105,11 @@ endmacro() set (MOTION_DETECTION_INC ${CMAKE_SOURCE_DIR}/../entservices-peripherals/MotionDetection ${CMAKE_SOURCE_DIR}/../entservices-peripherals/helpers) add_plugin_test_ex(PLUGIN_MOTION_DETECTION tests/test_MotionDetection.cpp "${MOTION_DETECTION_INC}" "${NAMESPACE}MotionDetection") -# PLUGIN_FRONTPANEL -set (FRONTPANEL_INC ${CMAKE_SOURCE_DIR}/../entservices-peripherals/FrontPanel ${CMAKE_SOURCE_DIR}/../entservices-peripherals/helpers) -add_plugin_test_ex(PLUGIN_FRONTPANEL tests/test_FrontPanel.cpp "${FRONTPANEL_INC}" "${NAMESPACE}FrontPanel") + add_library(${MODULE_NAME} SHARED ${TEST_SRC}) -set_source_files_properties( - tests/test_FrontPanel.cpp - PROPERTIES COMPILE_FLAGS "-fexceptions") + include_directories(${TEST_INC}) diff --git a/Tests/L1Tests/tests/test_FrontPanel.cpp b/Tests/L1Tests/tests/test_FrontPanel.cpp deleted file mode 100755 index 0dff0594..00000000 --- a/Tests/L1Tests/tests/test_FrontPanel.cpp +++ /dev/null @@ -1,722 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include - -#include "FrontPanel.h" -#include "frontpanel.h" - -#include "FactoriesImplementation.h" - -#include "FrontPanelIndicatorMock.h" -#include "FrontPanelTextDisplayMock.h" -#include "FrontPanelConfigMock.h" -#include "IarmBusMock.h" -#include "ServiceMock.h" -#include "ColorMock.h" -#include "PowerManagerMock.h" -#include "ThunderPortability.h" - -using namespace WPEFramework; -using IPowerManager = Exchange::IPowerManager; - -using testing::Eq; - -class FrontPanelTest : public ::testing::Test { -protected: - Core::ProxyType plugin; - Core::JSONRPC::Handler& handler; - DECL_CORE_JSONRPC_CONX connection; - string response; - - FrontPanelTest() - : plugin(Core::ProxyType::Create()) - , handler(*(plugin)) - , INIT_CONX(1, 0) - { - } - virtual ~FrontPanelTest() = default; -}; - -class FrontPanelDsTest : public FrontPanelTest { -protected: - testing::NiceMock frontPanelIndicatorMock; - testing::NiceMock frontPanelTextDisplayIndicatorMock; - FrontPanelConfigMock *p_frontPanelConfigImplMock = nullptr; - FrontPanelTextDisplayMock *p_frontPanelTextDisplayMock = nullptr; - FrontPanelDsTest() - : FrontPanelTest() - { - device::FrontPanelIndicator::getInstance().impl = &frontPanelIndicatorMock; - p_frontPanelConfigImplMock = new testing::NiceMock ; - device::FrontPanelConfig::setImpl(p_frontPanelConfigImplMock); - p_frontPanelTextDisplayMock = new testing::NiceMock ; - device::FrontPanelTextDisplay::setImpl(p_frontPanelTextDisplayMock); - device::FrontPanelTextDisplay::getInstance().FrontPanelIndicator::impl = &frontPanelTextDisplayIndicatorMock; - - } - virtual ~FrontPanelDsTest() override - { - device::FrontPanelIndicator::getInstance().impl = nullptr; - device::FrontPanelTextDisplay::getInstance().FrontPanelIndicator::impl = nullptr; - if (p_frontPanelTextDisplayMock != nullptr) - { - delete p_frontPanelTextDisplayMock; - p_frontPanelTextDisplayMock = nullptr; - } - if (p_frontPanelConfigImplMock != nullptr) - { - delete p_frontPanelConfigImplMock; - p_frontPanelConfigImplMock = nullptr; - } - - } -}; - -class FrontPanelInitializedTest : public FrontPanelTest { -protected: - IarmBusImplMock *p_iarmBusImplMock = nullptr ; - FrontPanelConfigMock *p_frontPanelConfigImplMock = nullptr; - FrontPanelTextDisplayMock *p_frontPanelTextDisplayMock = nullptr; - IPowerManager::IModeChangedNotification* _notification = nullptr; - - IARM_EventHandler_t dsPanelEventHandler; - testing::NiceMock frontPanelIndicatorMock; - testing::NiceMock frontPanelTextDisplayIndicatorMock; - - - FrontPanelInitializedTest() - : FrontPanelTest() - { - - p_iarmBusImplMock = new testing::NiceMock ; - IarmBus::setImpl(p_iarmBusImplMock); - p_frontPanelConfigImplMock = new testing::NiceMock ; - device::FrontPanelConfig::setImpl(p_frontPanelConfigImplMock); - - device::FrontPanelIndicator::getInstance().impl = &frontPanelIndicatorMock; - device::FrontPanelTextDisplay::getInstance().FrontPanelIndicator::impl = &frontPanelTextDisplayIndicatorMock; - - p_frontPanelTextDisplayMock = new testing::NiceMock ; - device::FrontPanelTextDisplay::setImpl(p_frontPanelTextDisplayMock); - - //Needs to be set at initiative time, as the function gets called when FrontPanel is intialized. - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Power", name); - return device::FrontPanelIndicator::getInstance(); - })); - - ON_CALL(*p_frontPanelConfigImplMock, getIndicators()) - .WillByDefault(::testing::Return(device::List({ device::FrontPanelIndicator::getInstance() }))); - - EXPECT_CALL(PowerManagerMock::Mock(), Register(::testing::Matcher(::testing::_))) - .WillOnce( - [this](IPowerManager::IModeChangedNotification* notification) -> uint32_t { - _notification = notification; - return Core::ERROR_NONE; - }); - - // This CFrontPanel::instance() is never destroyed - // ::testing::Mock::AllowLeak(PowerManagerMock::Get()); - - EXPECT_EQ(string(""), plugin->Initialize(nullptr)); - } - virtual ~FrontPanelInitializedTest() override - { - device::FrontPanelIndicator::getInstance().impl = nullptr; - device::FrontPanelTextDisplay::getInstance().FrontPanelIndicator::impl = nullptr; - - plugin->Deinitialize(nullptr); - - _notification = nullptr; - PowerManagerMock::Delete(); - - //Clearing out out of scope variables, and setting initDone to 0. - Plugin::CFrontPanel::initDone = 0; - IarmBus::setImpl(nullptr); - if (p_iarmBusImplMock != nullptr) - { - delete p_iarmBusImplMock; - p_iarmBusImplMock = nullptr; - } - device::FrontPanelTextDisplay::setImpl(nullptr); - if (p_frontPanelTextDisplayMock != nullptr) - { - delete p_frontPanelTextDisplayMock; - p_frontPanelTextDisplayMock = nullptr; - } - device::FrontPanelConfig::setImpl(nullptr); - if (p_frontPanelConfigImplMock != nullptr) - { - delete p_frontPanelConfigImplMock; - p_frontPanelConfigImplMock = nullptr; - } - } -}; - -class FrontPanelInitializedEventTest : public FrontPanelInitializedTest { -protected: - testing::NiceMock service; - FactoriesImplementation factoriesImplementation; - PLUGINHOST_DISPATCHER* dispatcher; - Core::JSONRPC::Message message; - - FrontPanelInitializedEventTest() - : FrontPanelInitializedTest() - { - PluginHost::IFactories::Assign(&factoriesImplementation); - - dispatcher = static_cast( - plugin->QueryInterface(PLUGINHOST_DISPATCHER_ID)); - - dispatcher->Activate(&service); - } - - virtual ~FrontPanelInitializedEventTest() override - { - dispatcher->Deactivate(); - dispatcher->Release(); - - PluginHost::IFactories::Assign(nullptr); - } -}; - -class FrontPanelInitializedEventDsTest : public FrontPanelInitializedEventTest { -protected: - - ColorMock *p_colorImplMock = nullptr ; - - FrontPanelInitializedEventDsTest() - : FrontPanelInitializedEventTest() - { - p_colorImplMock = new testing::NiceMock ; - device::FrontPanelIndicator::Color::setImpl(p_colorImplMock); - - EXPECT_NE(_notification, nullptr); - _notification->OnPowerModeChanged(IPowerManager::POWER_STATE_STANDBY, IPowerManager::POWER_STATE_ON); - } - - virtual ~FrontPanelInitializedEventDsTest() override - { - device::FrontPanelIndicator::Color::setImpl(nullptr); - if (p_colorImplMock != nullptr) - { - delete p_colorImplMock; - p_colorImplMock = nullptr; - } - } -}; - -TEST_F(FrontPanelTest, RegisteredMethods) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setBrightness"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getBrightness"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("powerLedOn"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("powerLedOff"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setClockBrightness"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getClockBrightness"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getFrontPanelLights"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getPreferences"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setPreferences"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setLED"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setBlink"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("set24HourClock"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("is24HourClock"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setClockTestPattern"))); -} - -TEST_F(FrontPanelInitializedEventDsTest, setBrightnessWIndex) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Power", name); - return device::FrontPanelIndicator::getInstance(); - })); - - ON_CALL(frontPanelIndicatorMock, getName()) - .WillByDefault(::testing::Return("Power")); - - - EXPECT_CALL(frontPanelIndicatorMock, setBrightness(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](int brightness, bool toPersist) { - EXPECT_EQ(brightness, 1); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setBrightness"), _T("{\"brightness\": 1,\"index\": \"power_led\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(FrontPanelInitializedEventDsTest, setBrightnessClock) -{ - ON_CALL(*p_frontPanelTextDisplayMock, getInstanceByName) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelTextDisplay& { - EXPECT_EQ("Text", name); - return device::FrontPanelTextDisplay::getInstance(); - })); - - ON_CALL(*p_frontPanelConfigImplMock, getIndicators()) - .WillByDefault(::testing::Return(device::List({device::FrontPanelIndicator::getInstance()}))); - ON_CALL(frontPanelIndicatorMock, getName()) - .WillByDefault(::testing::Return("red")); - - EXPECT_CALL(*p_frontPanelTextDisplayMock, setTextBrightness(::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](int brightness) { - EXPECT_EQ(brightness, 1); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setBrightness"), _T("{\"brightness\": 1,\"index\": \"clock_led\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(FrontPanelInitializedEventDsTest, setBrightness) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Power", name); - return device::FrontPanelIndicator::getInstance(); - })); - - ON_CALL(*p_frontPanelConfigImplMock, getIndicators()) - .WillByDefault(::testing::Return(device::List({device::FrontPanelIndicator::getInstance()}))); - - ON_CALL(frontPanelIndicatorMock, getName()) - .WillByDefault(::testing::Return("Power")); - - EXPECT_CALL(frontPanelIndicatorMock, setBrightness(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](int brightness, bool toPersist) { - EXPECT_EQ(brightness, 1); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setBrightness"), _T("{\"brightness\": 1}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(FrontPanelInitializedEventDsTest, getBrightnessWIndex) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Power", name); - return device::FrontPanelIndicator::getInstance(); - })); - ON_CALL(frontPanelIndicatorMock, getBrightness(::testing::_)) - .WillByDefault(::testing::Return(50)); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getBrightness"), _T("{\"index\": \"power_led\"}"), response)); - EXPECT_EQ(response, string("{\"brightness\":50,\"success\":true}")); -} - -TEST_F(FrontPanelInitializedEventDsTest, getBrightnessOtherName) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("other", name); - return device::FrontPanelIndicator::getInstance(); - })); - ON_CALL(frontPanelIndicatorMock, getBrightness(::testing::_)) - .WillByDefault(::testing::Return(50)); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getBrightness"), _T("{\"index\": \"other\"}"), response)); - EXPECT_EQ(response, string("{\"brightness\":50,\"success\":true}")); -} - -TEST_F(FrontPanelInitializedEventDsTest, getBrightnessWIndexClock) -{ - - ON_CALL(*p_frontPanelTextDisplayMock, getInstanceByName) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelTextDisplay& { - EXPECT_EQ("Text", name); - return device::FrontPanelTextDisplay::getInstance(); - })); - - - ON_CALL(*p_frontPanelTextDisplayMock, getTextBrightness()) - .WillByDefault(::testing::Return(50)); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getBrightness"), _T("{\"index\": \"clock_led\"}"), response)); - EXPECT_EQ(response, string("{\"brightness\":50,\"success\":true}")); -} - - -TEST_F(FrontPanelInitializedEventDsTest, getBrightness) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Power", name); - return device::FrontPanelIndicator::getInstance(); - })); - ON_CALL(frontPanelIndicatorMock, getBrightness(::testing::_)) - .WillByDefault(::testing::Return(50)); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getBrightness"), _T(""), response)); - EXPECT_EQ(response, string("{\"brightness\":50,\"success\":true}")); -} -TEST_F(FrontPanelInitializedEventDsTest, getClockBrightness) -{ - - ON_CALL(*p_frontPanelTextDisplayMock, getInstanceByName) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelTextDisplay& { - EXPECT_EQ("Text", name); - return device::FrontPanelTextDisplay::getInstance(); - })); - - ON_CALL(*p_frontPanelTextDisplayMock, getTextBrightness()) - .WillByDefault(::testing::Return(50)); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getClockBrightness"), _T(""), response)); - EXPECT_EQ(response, string("{\"brightness\":50,\"success\":true}")); -} - -TEST_F(FrontPanelInitializedEventDsTest, setClockBrightness) -{ - - ON_CALL(*p_frontPanelTextDisplayMock, getInstanceByName) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelTextDisplay& { - EXPECT_EQ("Text", name); - return device::FrontPanelTextDisplay::getInstance(); - })); - - ON_CALL(*p_frontPanelConfigImplMock, getIndicators()) - .WillByDefault(::testing::Return(device::List({device::FrontPanelIndicator::getInstance()}))); - ON_CALL(frontPanelIndicatorMock, getName()) - .WillByDefault(::testing::Return("red")); - - EXPECT_CALL(*p_frontPanelTextDisplayMock, setTextBrightness(::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](int brightness) { - EXPECT_EQ(brightness, 1); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setClockBrightness"), _T("{\"brightness\": 1}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - - -TEST_F(FrontPanelInitializedEventDsTest, getFrontPanelLights) -{ - ON_CALL(*p_frontPanelConfigImplMock, getIndicators()) - .WillByDefault(::testing::Return(device::List({ device::FrontPanelIndicator::getInstance() }))); - - ON_CALL(frontPanelIndicatorMock, getBrightnessLevels(::testing::_,::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int &levels,int &min,int &max) { - levels=1; - min=0; - max=2; - })); - ON_CALL(frontPanelTextDisplayIndicatorMock, getBrightnessLevels(::testing::_, ::testing::_, ::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int& levels, int& min, int& max) { - levels = 1; - min = 0; - max = 2; - })); - - ON_CALL(*p_frontPanelConfigImplMock, getTextDisplays()) - .WillByDefault(::testing::Return(device::List({ device::FrontPanelTextDisplay::getInstance() }))); - ON_CALL(frontPanelTextDisplayIndicatorMock, getName()) - .WillByDefault(::testing::Return("Text")); - ON_CALL(*p_colorImplMock, getName()) - .WillByDefault(::testing::Return("white")); - - int test = 0; - - ON_CALL(*p_frontPanelConfigImplMock, getTextDisplay(test)) - .WillByDefault(::testing::ReturnRef(device::FrontPanelTextDisplay::getInstance())); - - ON_CALL(frontPanelIndicatorMock, getName()) - .WillByDefault(::testing::Return("Power")); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getFrontPanelLights"), _T(""), response)); - EXPECT_EQ(response, string("{\"supportedLights\":[\"power_led\",\"clock_led\"],\"supportedLightsInfo\":{\"power_led\":{\"range\":\"boolean\",\"min\":0,\"max\":2,\"colorMode\":0},\"clock_led\":{\"range\":\"boolean\",\"min\":0,\"max\":2,\"colorMode\":0}},\"success\":true}")); -} - - -TEST_F(FrontPanelInitializedEventDsTest, getPreferences) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setPreferences"), _T("{\"preferences\":{\"test\": true}}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getPreferences"), _T(""), response)); - EXPECT_EQ(response, string("{\"preferences\":{\"test\":true},\"success\":true}")); -} - -TEST_F(FrontPanelInitializedEventDsTest, is24HourClock) -{ - - std::string test = "Text"; - ON_CALL(*p_frontPanelConfigImplMock, getTextDisplay(test)) - .WillByDefault(::testing::ReturnRef(device::FrontPanelTextDisplay::getInstance())); - ON_CALL(*p_frontPanelTextDisplayMock, getCurrentTimeFormat()) - .WillByDefault(::testing::Return(dsFPD_TIME_12_HOUR)); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("is24HourClock"), _T(""), response)); - EXPECT_EQ(response, string("{\"is24Hour\":false,\"success\":true}")); - - ON_CALL(*p_frontPanelTextDisplayMock, getCurrentTimeFormat()) - .WillByDefault(::testing::Return(dsFPD_TIME_24_HOUR)); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("is24HourClock"), _T(""), response)); - EXPECT_EQ(response, string("{\"is24Hour\":true,\"success\":true}")); - -} - -TEST_F(FrontPanelInitializedEventDsTest, powerLedOffPower) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Power", name); - return device::FrontPanelIndicator::getInstance(); - })); - - - EXPECT_CALL(frontPanelIndicatorMock, setState(::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](bool state) { - EXPECT_EQ(state, false); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("powerLedOff"), _T("{\"index\": \"power_led\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(FrontPanelInitializedEventDsTest, powerLedOffData) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Message", name); - return device::FrontPanelIndicator::getInstance(); - })); - - - EXPECT_CALL(frontPanelIndicatorMock, setState(::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](bool state) { - EXPECT_EQ(state, false); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("powerLedOff"), _T("{\"index\": \"data_led\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(FrontPanelInitializedEventDsTest, powerLedOffRecord) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Record", name); - return device::FrontPanelIndicator::getInstance(); - })); - - - EXPECT_CALL(frontPanelIndicatorMock, setState(::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](bool state) { - EXPECT_EQ(state, false); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("powerLedOff"), _T("{\"index\": \"record_led\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(FrontPanelInitializedEventDsTest, powerLedOnPower) -{ - - ON_CALL(*p_frontPanelConfigImplMock, getIndicators()) - .WillByDefault(::testing::Return(device::List({device::FrontPanelIndicator::getInstance()}))); - ON_CALL(frontPanelIndicatorMock, getName()) - .WillByDefault(::testing::Return("red")); - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Power", name); - return device::FrontPanelIndicator::getInstance(); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("powerLedOn"), _T("{\"index\": \"power_led\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Record", name); - return device::FrontPanelIndicator::getInstance(); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("powerLedOn"), _T("{\"index\": \"record_led\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Message", name); - return device::FrontPanelIndicator::getInstance(); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("powerLedOn"), _T("{\"index\": \"data_led\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - - -} - -TEST_F(FrontPanelInitializedEventDsTest, set24HourClock) -{ - std::string test = "Text"; - - ON_CALL(*p_frontPanelConfigImplMock, getTextDisplay(test)) - .WillByDefault(::testing::ReturnRef(device::FrontPanelTextDisplay::getInstance())); - ON_CALL(*p_frontPanelTextDisplayMock, getCurrentTimeFormat()) - .WillByDefault(::testing::Return(dsFPD_TIME_24_HOUR)); - EXPECT_CALL(*p_frontPanelTextDisplayMock, setTimeFormat(::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const int iTimeFormat) { - EXPECT_EQ(iTimeFormat, dsFPD_TIME_24_HOUR); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("set24HourClock"), _T("{\"is24Hour\": true}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} - -TEST_F(FrontPanelInitializedEventDsTest, setBlink) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Power", name); - return device::FrontPanelIndicator::getInstance(); - })); - - ON_CALL(frontPanelIndicatorMock, getBrightness(::testing::_)) - .WillByDefault(::testing::Return(50)); - ON_CALL(*p_frontPanelTextDisplayMock, getTextBrightness()) - .WillByDefault(::testing::Return(50)); - - ON_CALL(frontPanelIndicatorMock, getName()) - .WillByDefault(::testing::Return("Power")); - - EXPECT_CALL(frontPanelIndicatorMock, setColorInt(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](uint32_t color, bool persist) { - EXPECT_EQ(color, 131586); - })); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setBlink"), _T("{\"blinkInfo\": {\"ledIndicator\": \"power_led\", \"iterations\": 10, \"pattern\": [{\"brightness\": 50, \"duration\": 100, \"red\": 2, \"green\":2, \"blue\":2}]}}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(FrontPanelInitializedEventDsTest, setClockTestPattern) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Power", name); - return device::FrontPanelIndicator::getInstance(); - })); - - ON_CALL(*p_colorImplMock, getInstanceByName) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator::Color& { - EXPECT_EQ("red", name); - return device::FrontPanelIndicator::Color::getInstance(); - })); - - std::string test = "Text"; - - ON_CALL(*p_frontPanelConfigImplMock, getTextDisplay(test)) - .WillByDefault(::testing::ReturnRef(device::FrontPanelTextDisplay::getInstance())); - ON_CALL(*p_frontPanelTextDisplayMock, getTextBrightness()) - .WillByDefault(::testing::Return(100)); - - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setClockTestPattern"), _T("{\"show\": true, \"timeInterval\": 4}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setClockTestPattern"), _T("{\"show\": false, \"timeInterval\": 4}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - -} - -TEST_F(FrontPanelInitializedEventDsTest, setLEDMode1) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Power", name); - return device::FrontPanelIndicator::getInstance(); - })); - - ON_CALL(frontPanelIndicatorMock, getName()) - .WillByDefault(::testing::Return("Power")); - - EXPECT_CALL(frontPanelIndicatorMock, setColorInt(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](uint32_t color, bool toPersist) { - EXPECT_EQ(color, 0); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setLED"), _T("{\"ledIndicator\": \"power_led\", \"brightness\": 50, \"red\": 0, \"green\": 0, \"blue\":0}"), response)); - - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(FrontPanelInitializedEventDsTest, setLEDMode2) -{ - - ON_CALL(frontPanelIndicatorMock, getInstanceString) - .WillByDefault(::testing::Invoke( - [&](const std::string& name) -> device::FrontPanelIndicator& { - EXPECT_EQ("Power", name); - return device::FrontPanelIndicator::getInstance(); - })); - - EXPECT_CALL(frontPanelIndicatorMock, setColorInt(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](uint32_t color, bool toPersist) { - EXPECT_EQ(color, 66051); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setLED"), _T("{\"ledIndicator\": \"power_led\", \"brightness\": 50, \"red\": 1, \"green\": 2, \"blue\":3}"), response)); - - EXPECT_EQ(response, string("{\"success\":true}")); -} - diff --git a/Tests/L2Tests/CMakeLists.txt b/Tests/L2Tests/CMakeLists.txt deleted file mode 100755 index 4c0c4cb4..00000000 --- a/Tests/L2Tests/CMakeLists.txt +++ /dev/null @@ -1,71 +0,0 @@ -# If not stated otherwise in this file or this component's LICENSE file the -# following copyright and licenses apply: -# -# Copyright 2023 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -set(PLUGIN_NAME L2TestsPE) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) -set(THUNDER_PORT 9998) -find_package(${NAMESPACE}Plugins REQUIRED) - -if(PLUGIN_LEDCONTROL) - set(SRC_FILES ${SRC_FILES} tests/LedControl_L2Test.cpp) -endif() - -add_library(${MODULE_NAME} SHARED ${SRC_FILES}) - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 14 - CXX_STANDARD_REQUIRED YES) - -target_compile_definitions(${MODULE_NAME} - PRIVATE - MODULE_NAME=Plugin_${PLUGIN_NAME} - THUNDER_PORT="${THUNDER_PORT}") - -target_compile_options(${MODULE_NAME} PRIVATE -Wno-error) -target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins) - -if (NOT L2_TEST_OOP_RPC) - find_library(TESTMOCKLIB_LIBRARIES NAMES TestMocklib) - if (TESTMOCKLIB_LIBRARIES) - message ("Found mock library - ${TESTMOCKLIB_LIBRARIES}") - target_link_libraries(${MODULE_NAME} PRIVATE ${TESTMOCKLIB_LIBRARIES}) - else (TESTMOCKLIB_LIBRARIES) - message ("Require ${TESTMOCKLIB_LIBRARIES} library") - endif (TESTMOCKLIB_LIBRARIES) -endif (NOT L2_TEST_OOP_RPC) - -find_library(MOCKACCESSOR_LIBRARIES NAMES MockAccessor) -if (MOCKACCESSOR_LIBRARIES) - message ("Found MockAccessor library - ${MOCKACCESSOR_LIBRARIES}") - target_link_libraries(${MODULE_NAME} PRIVATE ${MOCKACCESSOR_LIBRARIES}) -else (MOCKACCESSOR_LIBRARIES) - message ("Require ${MOCKACCESSOR_LIBRARIES} library") -endif (MOCKACCESSOR_LIBRARIES) - -target_include_directories( - ${MODULE_NAME} PRIVATE ./ - ../../helpers - ../../../entservices-testframework/Tests/mocks - ../../../entservices-testframework/Tests/mocks/thunder - ../../../entservices-testframework/Tests/mocks/devicesettings - ../../../entservices-testframework/Tests/mocks/MockPlugin - ../../../entservices-testframework/Tests/L2Tests/L2TestsPlugin - ${CMAKE_INSTALL_PREFIX}/include - ) - -install(TARGETS ${MODULE_NAME} DESTINATION lib) diff --git a/Tests/L2Tests/tests/LedControl_L2Test.cpp b/Tests/L2Tests/tests/LedControl_L2Test.cpp deleted file mode 100755 index 8f811746..00000000 --- a/Tests/L2Tests/tests/LedControl_L2Test.cpp +++ /dev/null @@ -1,929 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2025 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "L2Tests.h" -#include "L2TestsMock.h" -#include -#include -#include -#include -#include -#include - -#define TEST_LOG(x, ...) \ - fprintf(stderr, "\033[1;32m[%s:%d](%s)" x "\n\033[0m", __FILE__, __LINE__, __FUNCTION__, getpid(), gettid(), ##__VA_ARGS__); \ - fflush(stderr); - -#define LED_CALLSIGN _T("org.rdk.LEDControl.1") -#define LEDL2TEST_CALLSIGN _T("L2tests.1") - -using ::testing::NiceMock; -using namespace WPEFramework; -using testing::StrictMock; -using ::WPEFramework::Exchange::ILEDControl; - -class LEDControl_L2test : public L2TestMocks { -protected: - virtual ~LEDControl_L2test() override; - -public: - LEDControl_L2test(); - uint32_t CreateDeviceLEDControlInterfaceObject(); - -protected: - /** @brief Pointer to the IShell interface */ - PluginHost::IShell* m_controller_LED; - - /** @brief Pointer to the ILEDControl interface */ - Exchange::ILEDControl* m_LEDplugin; -}; - -LEDControl_L2test::LEDControl_L2test() - : L2TestMocks() -{ - uint32_t status = Core::ERROR_GENERAL; - - ON_CALL(*p_dsFPDMock, dsFPInit()) - .WillByDefault(testing::Return(dsERR_NONE)); - - /* Activate plugin in constructor */ - status = ActivateService("org.rdk.LEDControl"); - EXPECT_EQ(Core::ERROR_NONE, status); - - if (CreateDeviceLEDControlInterfaceObject() != Core::ERROR_NONE) { - TEST_LOG("Invalid LEDControl_Client"); - } else { - EXPECT_TRUE(m_controller_LED != nullptr); - if (m_controller_LED) { - EXPECT_TRUE(m_LEDplugin != nullptr); - if (m_LEDplugin) { - m_LEDplugin->AddRef(); - } else { - TEST_LOG("m_LEDplugin is NULL"); - } - } else { - TEST_LOG("m_controller_LED is NULL"); - } - } -} - -LEDControl_L2test::~LEDControl_L2test() -{ - TEST_LOG("Inside LEDControl_L2test destructor"); - - ON_CALL(*p_dsFPDMock, dsFPTerm()) - .WillByDefault(testing::Return(dsERR_NONE)); - - if (m_LEDplugin) { - m_LEDplugin->Release(); - m_LEDplugin = nullptr; - } - if (m_controller_LED) { - m_controller_LED->Release(); - m_controller_LED = nullptr; - } - - uint32_t status = Core::ERROR_GENERAL; - - /* Deactivate plugin in destructor */ - status = DeactivateService("org.rdk.LEDControl"); - EXPECT_EQ(Core::ERROR_NONE, status); -} - -uint32_t LEDControl_L2test::CreateDeviceLEDControlInterfaceObject() -{ - uint32_t return_value = Core::ERROR_GENERAL; - Core::ProxyType> LEDControl_Engine; - Core::ProxyType LEDControl_Client; - - TEST_LOG("Creating LEDControl_Engine"); - LEDControl_Engine = Core::ProxyType>::Create(); - LEDControl_Client = Core::ProxyType::Create(Core::NodeId("/tmp/communicator"), Core::ProxyType(LEDControl_Engine)); - - TEST_LOG("Creating LEDControl_Engine Announcements"); -#if ((THUNDER_VERSION == 2) || ((THUNDER_VERSION == 4) && (THUNDER_VERSION_MINOR == 2))) - LEDControl_Engine->Announcements(mLEDControl_Client->Announcement()); -#endif - if (!LEDControl_Client.IsValid()) { - TEST_LOG("Invalid LEDControl_Client"); - } else { - m_controller_LED = LEDControl_Client->Open(_T("org.rdk.LEDControl"), ~0, 3000); - if (m_controller_LED) { - m_LEDplugin = m_controller_LED->QueryInterface(); - return_value = Core::ERROR_NONE; - } - } - return return_value; -} - -/************Test case Details ************************** -** 1.getSupportedLEDStates with states set as "ACTIVE,STANDBY" using jsonrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, JSONRPC_GetSupportedLEDStates_ACTIVE) -{ - JSONRPC::LinkType jsonrpc(LED_CALLSIGN, LEDL2TEST_CALLSIGN); - uint32_t status = Core::ERROR_GENERAL; - JsonObject param, result; - - //mock dsFPGetSupportedLEDStates to respond with ACTIVE and STANDBY states - EXPECT_CALL(*p_dsFPDMock, dsFPGetSupportedLEDStates(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(1 << dsFPD_LED_DEVICE_ACTIVE | 1 << dsFPD_LED_DEVICE_STANDBY), - ::testing::Return(dsERR_NONE))); - - status = InvokeServiceMethod("org.rdk.LEDControl.1", "getSupportedLEDStates", param, result); - EXPECT_EQ(Core::ERROR_NONE, status); - EXPECT_TRUE(result["success"].Boolean()); -} - -/************Test case Details ************************** -** 1.setLEDState with states set as "ACTIVE" using jsonrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, JSONRPC_Set_LEDState_ACTIVE) -{ - JSONRPC::LinkType jsonrpc(LED_CALLSIGN, LEDL2TEST_CALLSIGN); - uint32_t status = Core::ERROR_GENERAL; - JsonObject param, response; - - EXPECT_CALL(*p_dsFPDMock, dsFPSetLEDState(::testing::_)) - .WillOnce(::testing::Return(dsERR_NONE)); - - param["state"] = "ACTIVE"; - status = InvokeServiceMethod("org.rdk.LEDControl.1", "setLEDState", param, response); - EXPECT_EQ(status, Core::ERROR_NONE); -} - -/************Test case Details ************************** -** 1.getLEDState with states set as "ACTIVE" using jsonrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, JSONRPC_Get_LEDState_ACTIVE) -{ - JSONRPC::LinkType jsonrpc(LED_CALLSIGN, LEDL2TEST_CALLSIGN); - uint32_t status = Core::ERROR_GENERAL; - JsonObject param, result; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(dsFPD_LED_DEVICE_ACTIVE), - ::testing::Return(dsERR_NONE))); - - status = InvokeServiceMethod("org.rdk.LEDControl.1", "getLEDState", param, result); - EXPECT_EQ(status, Core::ERROR_NONE); -} - -/************Test case Details ************************** -** 1.GetSupportedLEDStates with states set as "ACTIVE" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, GetSupportedLEDStates_ACTIVE) -{ - uint32_t status = Core::ERROR_NONE; - bool success = false; - WPEFramework::RPC::IStringIterator* supportedLEDStates; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetSupportedLEDStates(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(1 << dsFPD_LED_DEVICE_ACTIVE), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetSupportedLEDStates(supportedLEDStates, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); - - if (supportedLEDStates != nullptr) { - string value; - while (supportedLEDStates->Next(value) == true) { - TEST_LOG("supportedLEDState: %s", value.c_str()); - } - } else { - TEST_LOG("supportedLEDStates is empty!"); - } -} - -/************Test case Details ************************** -** 1.GetSupportedLEDStates with states set as "STANDBY" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, GetSupportedLEDStates_STANDBY) -{ - uint32_t status = Core::ERROR_NONE; - bool success = false; - WPEFramework::RPC::IStringIterator* supportedLEDStates; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetSupportedLEDStates(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(1 << dsFPD_LED_DEVICE_STANDBY), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetSupportedLEDStates(supportedLEDStates, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); - - if (supportedLEDStates != nullptr) { - string value; - while (supportedLEDStates->Next(value) == true) { - TEST_LOG("supportedLEDState: %s", value.c_str()); - } - } else { - TEST_LOG("supportedLEDStates is empty!"); - } -} - -/************Test case Details ************************** -** 1.GetSupportedLEDStates with states set as "WPSCONNECTING" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, GetSupportedLEDStates_WPSCONNECTING) -{ - uint32_t status = Core::ERROR_NONE; - bool success = false; - WPEFramework::RPC::IStringIterator* supportedLEDStates; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetSupportedLEDStates(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(1 << dsFPD_LED_DEVICE_WPS_CONNECTING), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetSupportedLEDStates(supportedLEDStates, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); - - if (supportedLEDStates != nullptr) { - string value; - while (supportedLEDStates->Next(value) == true) { - TEST_LOG("supportedLEDState: %s", value.c_str()); - } - } else { - TEST_LOG("supportedLEDStates is empty!"); - } -} - -/************Test case Details ************************** -** 1.GetSupportedLEDStates with states set as "WPSCONNECTED" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, GetSupportedLEDStates_WPSCONNECTED) -{ - uint32_t status = Core::ERROR_NONE; - bool success = false; - WPEFramework::RPC::IStringIterator* supportedLEDStates; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetSupportedLEDStates(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(1 << dsFPD_LED_DEVICE_WPS_CONNECTED), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetSupportedLEDStates(supportedLEDStates, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); - - if (supportedLEDStates != nullptr) { - string value; - while (supportedLEDStates->Next(value) == true) { - TEST_LOG("supportedLEDState: %s", value.c_str()); - } - } else { - TEST_LOG("supportedLEDStates is empty!"); - } -} - -/************Test case Details ************************** -** 1.GetSupportedLEDStates with states set as "WPSERROR" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, GetSupportedLEDStates_WPSERROR) -{ - uint32_t status = Core::ERROR_NONE; - bool success = false; - WPEFramework::RPC::IStringIterator* supportedLEDStates; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetSupportedLEDStates(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(1 << dsFPD_LED_DEVICE_WPS_ERROR), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetSupportedLEDStates(supportedLEDStates, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); - - if (supportedLEDStates != nullptr) { - string value; - while (supportedLEDStates->Next(value) == true) { - TEST_LOG("supportedLEDState: %s", value.c_str()); - } - } else { - TEST_LOG("supportedLEDStates is empty!"); - } -} - -/************Test case Details ************************** -** 1.GetSupportedLEDStates with states set as "FACTORY_RESET" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, GetSupportedLEDStates_RESET) -{ - uint32_t status = Core::ERROR_NONE; - bool success = false; - WPEFramework::RPC::IStringIterator* supportedLEDStates; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetSupportedLEDStates(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(1 << dsFPD_LED_DEVICE_FACTORY_RESET), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetSupportedLEDStates(supportedLEDStates, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); - - if (supportedLEDStates != nullptr) { - string value; - while (supportedLEDStates->Next(value) == true) { - TEST_LOG("supportedLEDState: %s", value.c_str()); - } - } else { - TEST_LOG("supportedLEDStates is empty!"); - } -} - -/************Test case Details ************************** -** 1.GetSupportedLEDStates with states set as "USB_UPGRADE" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, GetSupportedLEDStates_USBUPGRADE) -{ - uint32_t status = Core::ERROR_NONE; - bool success = false; - WPEFramework::RPC::IStringIterator* supportedLEDStates; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetSupportedLEDStates(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(1 << dsFPD_LED_DEVICE_USB_UPGRADE), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetSupportedLEDStates(supportedLEDStates, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); - - if (supportedLEDStates != nullptr) { - string value; - while (supportedLEDStates->Next(value) == true) { - TEST_LOG("supportedLEDState: %s", value.c_str()); - } - } else { - TEST_LOG("supportedLEDStates is empty!"); - } -} - -/************Test case Details ************************** -** 1.GetSupportedLEDStates with states set as "SOFTWARE_DOWNLOAD_ERROR" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, GetSupportedLEDStates_DOWNLOADERROR) -{ - uint32_t status = Core::ERROR_NONE; - bool success = false; - WPEFramework::RPC::IStringIterator* supportedLEDStates; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetSupportedLEDStates(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(1 << dsFPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetSupportedLEDStates(supportedLEDStates, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); - - if (supportedLEDStates != nullptr) { - string value; - while (supportedLEDStates->Next(value) == true) { - TEST_LOG("supportedLEDState: %s", value.c_str()); - } - } else { - TEST_LOG("supportedLEDStates is empty!"); - } -} - -/************Test case Details ************************** -** 1.GetSupportedLEDStates with mock returning error using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, GetSupportedLEDStates_ErrorCase) -{ - uint32_t status = Core::ERROR_NONE; - bool success = false; - WPEFramework::RPC::IStringIterator* supportedLEDStates; - - //return dsERR_GENERAL for failure case - EXPECT_CALL(*p_dsFPDMock, dsFPGetSupportedLEDStates(::testing::_)) - .WillOnce(::testing::Return(dsERR_GENERAL)); - - status = m_LEDplugin->GetSupportedLEDStates(supportedLEDStates, success); - EXPECT_EQ(status, Core::ERROR_GENERAL); - EXPECT_FALSE(success); -} - -/************Test case Details ************************** -** 1.SetLEDState with state set to be "ACTIVE" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_ACTIVE) -{ - uint32_t status = Core::ERROR_NONE; - string State = "ACTIVE"; - bool success = false; - - EXPECT_CALL(*p_dsFPDMock, dsFPSetLEDState(::testing::_)) - .WillOnce(::testing::Return(dsERR_NONE)); - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); -} - -/************Test case Details ************************** -** 1.GetLEDState with state set to be "ACTIVE" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Get_LEDState_ACTIVE) -{ - Exchange::ILEDControl::LEDControlState LEDState; - uint32_t status = Core::ERROR_NONE; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(dsFPD_LED_DEVICE_ACTIVE), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_NONE); - - TEST_LOG("GetLEDState returned: %s", LEDState.state.c_str()); -} - -/************Test case Details ************************** -** 1.SetLEDState with state set to be "STANDBY" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_STANDBY) -{ - uint32_t status = Core::ERROR_NONE; - string State = "STANDBY"; - bool success = false; - - EXPECT_CALL(*p_dsFPDMock, dsFPSetLEDState(::testing::_)) - .WillOnce(::testing::Return(dsERR_NONE)); - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); -} - -/************Test case Details ************************** -** 1.GetLEDState with state set to be "STANDBY" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Get_LEDState_STANDBY) -{ - Exchange::ILEDControl::LEDControlState LEDState; - uint32_t status = Core::ERROR_NONE; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(dsFPD_LED_DEVICE_STANDBY), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_NONE); - - TEST_LOG("GetLEDState returned: %s", LEDState.state.c_str()); -} - -/************Test case Details ************************** -** 1.SetLEDState with state set to be "WPS_CONNECTING" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_WPSCONNECTING) -{ - uint32_t status = Core::ERROR_NONE; - string State = "WPS_CONNECTING"; - bool success = false; - - EXPECT_CALL(*p_dsFPDMock, dsFPSetLEDState(::testing::_)) - .WillOnce(::testing::Return(dsERR_NONE)); - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); -} - -/************Test case Details ************************** -** 1.GetLEDState with state set to be "WPS_CONNECTING" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Get_LEDState_WPSCONNECTING) -{ - Exchange::ILEDControl::LEDControlState LEDState; - uint32_t status = Core::ERROR_NONE; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(dsFPD_LED_DEVICE_WPS_CONNECTING), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_NONE); - - TEST_LOG("GetLEDState returned: %s", LEDState.state.c_str()); -} - -/************Test case Details ************************** -** 1.SetLEDState with state set to be "WPS_CONNECTED" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_CONNECTED) -{ - uint32_t status = Core::ERROR_NONE; - string State = "WPS_CONNECTED"; - bool success = false; - - EXPECT_CALL(*p_dsFPDMock, dsFPSetLEDState(::testing::_)) - .WillOnce(::testing::Return(dsERR_NONE)); - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); -} - -/************Test case Details ************************** -** 1.GetLEDState with state returned as "WPS_CONNECTED" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Get_LEDState_WPSCONNECTED) -{ - Exchange::ILEDControl::LEDControlState LEDState; - uint32_t status = Core::ERROR_NONE; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(dsFPD_LED_DEVICE_WPS_CONNECTED), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_NONE); - - TEST_LOG("GetLEDState returned: %s", LEDState.state.c_str()); -} - -/************Test case Details ************************** -** 1.SetLEDState with state set to be "WPS_ERROR" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_ERROR) -{ - uint32_t status = Core::ERROR_NONE; - string State = "WPS_ERROR"; - bool success = false; - - EXPECT_CALL(*p_dsFPDMock, dsFPSetLEDState(::testing::_)) - .WillOnce(::testing::Return(dsERR_NONE)); - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); -} - -/************Test case Details ************************** -** 1.GetLEDState with state returned as "WPS_ERROR" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Get_LEDState_ERROR) -{ - Exchange::ILEDControl::LEDControlState LEDState; - uint32_t status = Core::ERROR_NONE; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(dsFPD_LED_DEVICE_WPS_ERROR), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_NONE); - - TEST_LOG("GetLEDState returned: %s", LEDState.state.c_str()); -} - -/************Test case Details ************************** -** 1.SetLEDState with state set to be "FACTORY_RESET" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_FACTORYRESET) -{ - uint32_t status = Core::ERROR_NONE; - string State = "FACTORY_RESET"; - bool success = false; - - EXPECT_CALL(*p_dsFPDMock, dsFPSetLEDState(::testing::_)) - .WillOnce(::testing::Return(dsERR_NONE)); - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); -} - -/************Test case Details ************************** -** 1.GetLEDState with state returned as "DEVICE_FACTORY_RESET" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Get_LEDState_FACTORYRESET) -{ - Exchange::ILEDControl::LEDControlState LEDState; - uint32_t status = Core::ERROR_NONE; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(dsFPD_LED_DEVICE_FACTORY_RESET), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_NONE); - - TEST_LOG("GetLEDState returned: %s", LEDState.state.c_str()); -} - -/************Test case Details ************************** -** 1.SetLEDState with state set to be "USB_UPGRADE" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_USBUPGRADE) -{ - uint32_t status = Core::ERROR_NONE; - string State = "USB_UPGRADE"; - bool success = false; - - EXPECT_CALL(*p_dsFPDMock, dsFPSetLEDState(::testing::_)) - .WillOnce(::testing::Return(dsERR_NONE)); - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); -} - -/************Test case Details ************************** -** 1.GetLEDState with state returned as "DEVICE_USB_UPGRADE" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Get_LEDState_USBUPGRADE) -{ - Exchange::ILEDControl::LEDControlState LEDState; - uint32_t status = Core::ERROR_NONE; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(dsFPD_LED_DEVICE_USB_UPGRADE), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_NONE); - - TEST_LOG("GetLEDState returned: %s", LEDState.state.c_str()); -} - -/************Test case Details ************************** -** 1.SetLEDState with state set to be "DOWNLOAD_ERROR" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_DOWNLOADERROR) -{ - uint32_t status = Core::ERROR_NONE; - string State = "DOWNLOAD_ERROR"; - bool success = false; - - EXPECT_CALL(*p_dsFPDMock, dsFPSetLEDState(::testing::_)) - .WillOnce(::testing::Return(dsERR_NONE)); - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_NONE); - EXPECT_TRUE(success); -} - -/************Test case Details ************************** -** 1.GetLEDState with state returned as "SOFTWARE_DOWNLOAD_ERROR" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Get_LEDState_DOWNLOADERROR) -{ - Exchange::ILEDControl::LEDControlState LEDState; - uint32_t status = Core::ERROR_NONE; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(dsFPD_LED_DEVICE_SOFTWARE_DOWNLOAD_ERROR), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_NONE); - - TEST_LOG("GetLEDState returned: %s", LEDState.state.c_str()); -} - -/************Test case Details ************************** -** 1.GetLEDState with state returned as "NONE" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Get_LEDState_FPD_LED_DEVICE_NONE) -{ - Exchange::ILEDControl::LEDControlState LEDState; - uint32_t status = Core::ERROR_NONE; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(dsFPD_LED_DEVICE_NONE), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_NONE); - - TEST_LOG("GetLEDState returned: %s", LEDState.state.c_str()); -} - -/************Test case Details ************************** -** 1.SetLEDState with state set to be "NONE" using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_NONE) -{ - uint32_t status = Core::ERROR_NONE; - string State = "NONE"; - bool success = true; - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_BAD_REQUEST); - EXPECT_FALSE(success); -} - -/************Test case Details ************************** -** 1.GetLEDState with dsFPGetLEDState mock returning dsFPD_LED_DEVICE_MAX for Unsupported LED state using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Get_LEDState_defaultCase) -{ - Exchange::ILEDControl::LEDControlState LEDState; - uint32_t status = Core::ERROR_NONE; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::DoAll( - ::testing::SetArgPointee<0>(dsFPD_LED_DEVICE_MAX), - ::testing::Return(dsERR_NONE))); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_BAD_REQUEST); - - TEST_LOG("GetLEDState returned: %s", LEDState.state.c_str()); -} - -/************Test case Details ************************** -** 1.GetLEDState with dsFPGetLEDState mock returning error using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Get_LEDState_Errorcase) -{ - Exchange::ILEDControl::LEDControlState LEDState; - uint32_t status = Core::ERROR_NONE; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::Return(dsERR_GENERAL)); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_GENERAL); - - TEST_LOG("GetLEDState returned: %s", LEDState.state.c_str()); -} - -/************Test case Details ************************** -** 1.SetLEDState with invalid parameter using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_InvalidParameter) -{ - uint32_t status = Core::ERROR_NONE; - string State = "INVALID"; - bool success = true; - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_BAD_REQUEST); - EXPECT_FALSE(success); -} - -/************Test case Details ************************** -** 1.SetLEDState with empty parameter using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_emptyParameter) -{ - uint32_t status = Core::ERROR_NONE; - string State; - bool success = true; - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_BAD_REQUEST); - EXPECT_FALSE(success); -} - -/************Test case Details ************************** -** 1.SetLEDState with dsFPSetLEDState mock returning error using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, Set_LEDState_dsFPSetLEDState_Error) -{ - uint32_t status = Core::ERROR_NONE; - string State = "DOWNLOAD_ERROR"; - bool success = true; - - EXPECT_CALL(*p_dsFPDMock, dsFPSetLEDState(::testing::_)) - .WillOnce(::testing::Return(dsERR_GENERAL)); - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_GENERAL); - EXPECT_FALSE(success); -} - -/************Test case Details ************************** -** 1.GetSupportedLEDStates with dsFPGetSupportedLEDStates mock raising exception using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, dsFPGetSupportedLEDStates_RaiseException) -{ - uint32_t status = Core::ERROR_NONE; - bool success = false; - WPEFramework::RPC::IStringIterator* supportedLEDStates; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetSupportedLEDStates(::testing::_)) - .WillOnce(::testing::Invoke([](unsigned int* states) { - throw std::runtime_error("Simulated Exception"); - return dsERR_NONE; - })); - - status = m_LEDplugin->GetSupportedLEDStates(supportedLEDStates, success); - EXPECT_EQ(status, Core::ERROR_GENERAL); - EXPECT_FALSE(success); -} - -/************Test case Details ************************** -** 1.GetLEDState with dsFPGetLEDState mock raising exception using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, dsFPGetLEDState_RaiseException) -{ - uint32_t status = Core::ERROR_NONE; - Exchange::ILEDControl::LEDControlState LEDState; - ; - - EXPECT_CALL(*p_dsFPDMock, dsFPGetLEDState(::testing::_)) - .WillOnce(::testing::Invoke([](dsFPDLedState_t* states) { - throw std::runtime_error("Simulated Exception"); - return dsERR_NONE; - })); - - status = m_LEDplugin->GetLEDState(LEDState); - EXPECT_EQ(status, Core::ERROR_GENERAL); -} - -/************Test case Details ************************** -** 1.SetLEDState with dsFPSetLEDState mock raising exception using comrpc -*******************************************************/ - -TEST_F(LEDControl_L2test, dsFPSetLEDState_RaiseException) -{ - uint32_t status = Core::ERROR_NONE; - string State = "DOWNLOAD_ERROR"; - bool success = true; - - EXPECT_CALL(*p_dsFPDMock, dsFPSetLEDState(::testing::_)) - .WillOnce(::testing::Invoke([](dsFPDLedState_t states) { - throw std::runtime_error("Simulated Exception"); - return dsERR_NONE; - })); - - status = m_LEDplugin->SetLEDState(State, success); - EXPECT_EQ(status, Core::ERROR_GENERAL); - EXPECT_FALSE(success); -} diff --git a/VoiceControl/CHANGELOG.md b/VoiceControl/CHANGELOG.md deleted file mode 100644 index 2e200c40..00000000 --- a/VoiceControl/CHANGELOG.md +++ /dev/null @@ -1,16 +0,0 @@ -# Changelog - -All notable changes to this RDK Service will be documented in this file. - -* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. - -* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - * **Added** for new features. - * **Changed** for changes in existing functionality. - * **Deprecated** for soon-to-be removed features. - * **Removed** for now removed features. - * **Fixed** for any bug fixes. - * **Security** in case of vulnerabilities. - -* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. - diff --git a/VoiceControl/CMakeLists.txt b/VoiceControl/CMakeLists.txt deleted file mode 100644 index 5f0d9e72..00000000 --- a/VoiceControl/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -### -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2024 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -### - -set(PLUGIN_NAME VoiceControl) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) - -set(PLUGIN_VOICECONTROL_STARTUPORDER "" CACHE STRING "To configure startup order of VoiceControl plugin") - -find_package(${NAMESPACE}Plugins REQUIRED) - -add_library(${MODULE_NAME} SHARED - VoiceControl.cpp - Module.cpp) - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -target_include_directories(${MODULE_NAME} PRIVATE ../helpers) - -find_package(CTRLM) -if (CTRLM_FOUND) - find_package(IARMBus) - add_definitions(-DCTRLM_FOUND) - target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS}) - target_include_directories(${MODULE_NAME} PRIVATE ${CTRLM_INCLUDE_DIRS}) - target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES}) -else (CTRLM_FOUND) - target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Plugins::${NAMESPACE}Plugins) -endif(CTRLM_FOUND) - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/VoiceControl/Module.cpp b/VoiceControl/Module.cpp deleted file mode 100644 index cd6d4d14..00000000 --- a/VoiceControl/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/VoiceControl/Module.h b/VoiceControl/Module.h deleted file mode 100644 index d85f7dce..00000000 --- a/VoiceControl/Module.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once -#ifndef MODULE_NAME -#define MODULE_NAME VoiceControl -#endif - -#include -#include - -#undef EXTERNAL -#define EXTERNAL diff --git a/VoiceControl/README.md b/VoiceControl/README.md deleted file mode 100644 index b3e73027..00000000 --- a/VoiceControl/README.md +++ /dev/null @@ -1,18 +0,0 @@ ------------------ -Build: - -bitbake thunder-plugins - ------------------ -Test: - - -Methods common to typical plugins - getQuirks() and getApiVersionNumber() (not specific to the VoiceControl API) - -curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "org.rdk.VoiceControl.1.getQuirks"}' http://127.0.0.1:9998/jsonrpc - -curl -d '{"jsonrpc":"2.0","id":"4","method":"org.rdk.VoiceControl.1.getApiVersionNumber"}' http://127.0.0.1:9998/jsonrpc - - - - diff --git a/VoiceControl/VoiceControl.conf.in b/VoiceControl/VoiceControl.conf.in deleted file mode 100644 index dcfbc06d..00000000 --- a/VoiceControl/VoiceControl.conf.in +++ /dev/null @@ -1,4 +0,0 @@ -precondition = ["Platform"] -callsign = "org.rdk.VoiceControl" -autostart = "false" -startuporder = "@PLUGIN_VOICECONTROL_STARTUPORDER@" diff --git a/VoiceControl/VoiceControl.config b/VoiceControl/VoiceControl.config deleted file mode 100644 index fefc47a7..00000000 --- a/VoiceControl/VoiceControl.config +++ /dev/null @@ -1,7 +0,0 @@ -set (autostart false) -set (preconditions Platform) -set (callsign "org.rdk.VoiceControl") - -if(PLUGIN_VOICECONTROL_STARTUPORDER) -set (startuporder ${PLUGIN_VOICECONTROL_STARTUPORDER}) -endif() diff --git a/VoiceControl/VoiceControl.cpp b/VoiceControl/VoiceControl.cpp deleted file mode 100644 index 6b55826f..00000000 --- a/VoiceControl/VoiceControl.cpp +++ /dev/null @@ -1,828 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "VoiceControl.h" -#include "libIBusDaemon.h" -#include -#include "UtilsJsonRpc.h" -#include "UtilsIarm.h" - -#define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 4 -#define API_VERSION_NUMBER_PATCH 0 - -using namespace std; - -namespace WPEFramework { - - namespace { - - static Plugin::Metadata metadata( - // Version (Major, Minor, Patch) - API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, - // Preconditions - {}, - // Terminations - {}, - // Controls - {} - ); - } - - namespace Plugin { - - SERVICE_REGISTRATION(VoiceControl, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); - - VoiceControl* VoiceControl::_instance = nullptr; - - VoiceControl::VoiceControl() - : PluginHost::JSONRPC() - , m_apiVersionNumber((uint32_t)-1) /* default max uint32_t so everything gets enabled */ - { - LOGINFO("ctor"); - VoiceControl::_instance = this; - - Register("getApiVersionNumber", &VoiceControl::getApiVersionNumber, this); - - Register("voiceStatus", &VoiceControl::voiceStatus, this); - Register("configureVoice", &VoiceControl::configureVoice, this); - Register("setVoiceInit", &VoiceControl::setVoiceInit, this); - Register("sendVoiceMessage", &VoiceControl::sendVoiceMessage, this); - Register("voiceSessionByText", &VoiceControl::voiceSessionByText, this); - Register("voiceSessionTypes", &VoiceControl::voiceSessionTypes, this); - Register("voiceSessionRequest", &VoiceControl::voiceSessionRequest, this); - Register("voiceSessionTerminate", &VoiceControl::voiceSessionTerminate, this); - Register("voiceSessionAudioStreamStart", &VoiceControl::voiceSessionAudioStreamStart, this); - - setApiVersionNumber(1); - m_hasOwnProcess = false; - m_maskPii = false; - } - - VoiceControl::~VoiceControl() - { - //LOGINFO("dtor"); - } - - const string VoiceControl::Initialize(PluginHost::IShell* /* service */) - { - InitializeIARM(); - getMaskPii_(); - // On success return empty, to indicate there is no error text. - return (string()); - } - - void VoiceControl::Deinitialize(PluginHost::IShell* /* service */) - { - LOGINFO("Deinitialize"); - DeinitializeIARM(); - VoiceControl::_instance = nullptr; - } - - void VoiceControl::InitializeIARM() - { - if (Utils::IARM::init()) - { - // We have our own Linux process, so we need to connect and disconnect from the IARM Bus - m_hasOwnProcess = true; - - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_SESSION_BEGIN, voiceEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_STREAM_BEGIN, voiceEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_KEYWORD_VERIFICATION, voiceEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_SERVER_MESSAGE, voiceEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_STREAM_END, voiceEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_SESSION_END, voiceEventHandler) ); - } - else - m_hasOwnProcess = false; - } - - //TODO(MROLLINS) - we need to install crash handler to ensure DeinitializeIARM gets called - void VoiceControl::DeinitializeIARM() - { - if (m_hasOwnProcess) - { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_SESSION_END, voiceEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_STREAM_END, voiceEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_KEYWORD_VERIFICATION, voiceEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_SERVER_MESSAGE, voiceEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_STREAM_BEGIN, voiceEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_EVENT_JSON_SESSION_BEGIN, voiceEventHandler) ); - - m_hasOwnProcess = false; - } - } - - void VoiceControl::voiceEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if (VoiceControl::_instance) - VoiceControl::_instance->iarmEventHandler(owner, eventId, data, len); - else - LOGWARN("WARNING - cannot handle IARM events without a VoiceControl plugin instance!"); - } - - void VoiceControl::iarmEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - LOGINFO("Event ID %u received, data: %p, len: %u.", (unsigned)eventId, data, (unsigned)len); - if (!strcmp(owner, CTRLM_MAIN_IARM_BUS_NAME)) - { - ctrlm_voice_iarm_event_json_t* eventData = (ctrlm_voice_iarm_event_json_t*)data; - - if ((data == NULL) || (len <= sizeof(ctrlm_voice_iarm_event_json_t))) - { - LOGERR("ERROR - got eventId(%u) with INVALID DATA: data: %p, len: %zu.", (unsigned)eventId, data, len); - return; - } - - // Ensure there is a null character at the end of the data area. - char* str = (char*)data; - str[len - 1] = '\0'; - - if (CTRLM_VOICE_IARM_BUS_API_REVISION != eventData->api_revision) - { - LOGERR("ERROR - got eventId(%u) with wrong VOICE IARM API revision - should be %d, event has %d.", - (unsigned)eventId, CTRLM_VOICE_IARM_BUS_API_REVISION, (int)eventData->api_revision); - return; - } - - switch(eventId) { - case CTRLM_VOICE_IARM_EVENT_JSON_SESSION_BEGIN: - LOGWARN("Got CTRLM_VOICE_IARM_EVENT_JSON_SESSION_BEGIN event."); - - onSessionBegin(eventData); - break; - - case CTRLM_VOICE_IARM_EVENT_JSON_STREAM_BEGIN: - LOGWARN("Got CTRLM_VOICE_IARM_EVENT_JSON_STREAM_BEGIN event."); - - onStreamBegin(eventData); - break; - - case CTRLM_VOICE_IARM_EVENT_JSON_KEYWORD_VERIFICATION: - LOGWARN("Got CTRLM_VOICE_IARM_EVENT_JSON_KEYWORD_VERIFICATION event."); - - onKeywordVerification(eventData); - break; - - case CTRLM_VOICE_IARM_EVENT_JSON_SERVER_MESSAGE: - LOGWARN("Got CTRLM_VOICE_IARM_EVENT_JSON_SERVER_MESSAGE event."); - - onServerMessage(eventData); - break; - - case CTRLM_VOICE_IARM_EVENT_JSON_STREAM_END: - LOGWARN("Got CTRLM_VOICE_IARM_EVENT_JSON_STREAM_END event."); - - onStreamEnd(eventData); - break; - - case CTRLM_VOICE_IARM_EVENT_JSON_SESSION_END: - LOGWARN("Got CTRLM_VOICE_IARM_EVENT_JSON_SESSION_END event."); - - onSessionEnd(eventData); - break; - - default: - LOGERR("ERROR - unexpected ControlMgr event: eventId: %u, data: %p, size: %zu.", - (unsigned)eventId, data, len); - break; - } - } - else - { - LOGERR("ERROR - unexpected event: owner %s, eventId: %u, data: %p, size: %zu.", - owner, (unsigned)eventId, data, len); - } - } // End iarmEventHandler() - - //Begin methods - uint32_t VoiceControl::getApiVersionNumber(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - response["version"] = m_apiVersionNumber; - returnResponse(true); - } - - void VoiceControl::getMaskPii_() - { - JsonObject params; - JsonObject result; - voiceStatus(params, result); - m_maskPii = result["maskPii"].Boolean(); - LOGINFO("Mask pii set to %s.", (m_maskPii ? "True" : "False")); - } - - uint32_t VoiceControl::voiceStatus(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_voice_iarm_call_json_t* call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = true; - - // Just pass through the input parameters, without understanding or checking them. - parameters.ToString(jsonParams); - - // We must allocate the memory for the call structure. Determine what we will need. - size_t totalsize = sizeof(ctrlm_voice_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_voice_iarm_call_json_t*)calloc(1, totalsize); - - if (call != NULL) - { - // Set the call structure members appropriately. - call->api_revision = CTRLM_VOICE_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - } - else - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - } - - if (bSuccess) - { - // Make the IARM call to controlMgr to configure the voice settings - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_CALL_STATUS, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_STATUS Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - } - else - { - JsonObject result; - - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - if(bSuccess) { - LOGINFO("CTRLM_VOICE_IARM_CALL_STATUS call SUCCESS!"); - } else { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_STATUS returned FAILURE!"); - } - } - } - - if (call != NULL) - { - free(call); - } - - returnResponse(bSuccess); - } - - uint32_t VoiceControl::configureVoice(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_voice_iarm_call_json_t* call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = true; - - // Just pass through the input parameters, without understanding or checking them. - parameters.ToString(jsonParams); - - // We must allocate the memory for the call structure. Determine what we will need. - size_t totalsize = sizeof(ctrlm_voice_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_voice_iarm_call_json_t*)calloc(1, totalsize); - - if (call != NULL) - { - // Set the call structure members appropriately. - call->api_revision = CTRLM_VOICE_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - } - else - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - } - - if (bSuccess) - { - // Make the IARM call to controlMgr to configure the voice settings - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_CALL_CONFIGURE_VOICE, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_CONFIGURE_VOICE Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - } - else - { - JsonObject result; - - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - if(bSuccess) { - LOGINFO("CONFIGURE_VOICE call SUCCESS!"); - } else { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_CONFIGURE_VOICE returned FAILURE!"); - } - } - } - - if (call != NULL) - { - free(call); - } - - returnResponse(bSuccess); - } - - uint32_t VoiceControl::setVoiceInit(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_voice_iarm_call_json_t* call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = true; - - // Just pass through the input parameters, without understanding or checking them. - parameters.ToString(jsonParams); - - // We must allocate the memory for the call structure. Determine what we will need. - size_t totalsize = sizeof(ctrlm_voice_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_voice_iarm_call_json_t*)calloc(1, totalsize); - - if (call != NULL) - { - // Set the call structure members appropriately. - call->api_revision = CTRLM_VOICE_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - } - else - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - } - - if (bSuccess) - { - // Make the IARM call to controlMgr to configure the voice settings - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_CALL_SET_VOICE_INIT, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SET_VOICE_INIT Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - } - else - { - JsonObject result; - - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - if(bSuccess) { - LOGINFO("SET_VOICE_INIT call SUCCESS!"); - } else { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SET_VOICE_INIT returned FAILURE!"); - } - } - } - - if (call != NULL) - { - free(call); - } - - returnResponse(bSuccess); - } - - - uint32_t VoiceControl::sendVoiceMessage(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_voice_iarm_call_json_t* call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = true; - - // Just pass through the input parameters, without understanding or checking them. - parameters.ToString(jsonParams); - - // We must allocate the memory for the call structure. Determine what we will need. - size_t totalsize = sizeof(ctrlm_voice_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_voice_iarm_call_json_t*)calloc(1, totalsize); - - if (call != NULL) - { - // Set the call structure members appropriately. - call->api_revision = CTRLM_VOICE_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - } - else - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - } - - if (bSuccess) - { - // Make the IARM call to controlMgr to configure the voice settings - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_CALL_SEND_VOICE_MESSAGE, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SEND_VOICE_MESSAGE Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - } - else - { - JsonObject result; - - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - if(bSuccess) { - LOGINFO("SEND_VOICE_MESSAGE call SUCCESS!"); - } else { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SEND_VOICE_MESSAGE returned FAILURE!"); - } - } - } - - if (call != NULL) - { - free(call); - } - - returnResponse(bSuccess); - } - - uint32_t VoiceControl::voiceSessionByText(const JsonObject& parameters, JsonObject& response) // DEPRECATED - { - // Translate the input parameters then call voiceSessionRequest - JsonObject parameters_translated; - - if(!parameters.HasLabel("type")) { - parameters_translated["type"] = "ptt_transcription"; - } else { - std::string str_type = parameters["type"].String(); - transform(str_type.begin(), str_type.end(), str_type.begin(), ::tolower); - if(str_type == "ptt") { - parameters_translated["type"] = "ptt_transcription"; - } else if(str_type == "ff") { - parameters_translated["type"] = "ff_transcription"; - } else if(str_type == "mic") { - parameters_translated["type"] = "mic_transcription"; - } else { - parameters_translated["type"] = ""; - } - } - if(parameters.HasLabel("transcription")) { - parameters_translated["transcription"] = parameters["transcription"]; - } // else voiceSessionRequest will return an error if transcription field is not present - - return(voiceSessionRequest(parameters_translated, response)); - } - - uint32_t VoiceControl::voiceSessionTypes(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_voice_iarm_call_json_t* call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = true; - - // Just pass through the input parameters, without understanding or checking them. - parameters.ToString(jsonParams); - - // We must allocate the memory for the call structure. Determine what we will need. - size_t totalsize = sizeof(ctrlm_voice_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_voice_iarm_call_json_t*)calloc(1, totalsize); - - if (call != NULL) - { - // Set the call structure members appropriately. - call->api_revision = CTRLM_VOICE_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - } - else - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - } - - if (bSuccess) - { - // Make the IARM call to controlMgr to configure the voice settings - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_CALL_SESSION_TYPES, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SESSION_TYPES Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - } - else - { - JsonObject result; - - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - if(bSuccess) { - LOGINFO("SESSION_TYPES call SUCCESS!"); - } else { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SESSION_TYPES returned FAILURE!"); - } - } - } - - if (call != NULL) - { - free(call); - } - - returnResponse(bSuccess); - } - - uint32_t VoiceControl::voiceSessionRequest(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_voice_iarm_call_json_t* call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = true; - - // Just pass through the input parameters, without understanding or checking them. - parameters.ToString(jsonParams); - - // We must allocate the memory for the call structure. Determine what we will need. - size_t totalsize = sizeof(ctrlm_voice_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_voice_iarm_call_json_t*)calloc(1, totalsize); - - if (call != NULL) - { - // Set the call structure members appropriately. - call->api_revision = CTRLM_VOICE_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - } - else - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - } - - if (bSuccess) - { - // Make the IARM call to controlMgr to configure the voice settings - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_CALL_SESSION_REQUEST, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SESSION_REQUEST Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - } - else - { - JsonObject result; - - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - if(bSuccess) { - LOGINFO("SESSION_REQUEST call SUCCESS!"); - } else { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SESSION_REQUEST returned FAILURE!"); - } - } - } - - if (call != NULL) - { - free(call); - } - - returnResponse(bSuccess); - } - - uint32_t VoiceControl::voiceSessionTerminate(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_voice_iarm_call_json_t* call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = true; - - // Just pass through the input parameters, without understanding or checking them. - parameters.ToString(jsonParams); - - // We must allocate the memory for the call structure. Determine what we will need. - size_t totalsize = sizeof(ctrlm_voice_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_voice_iarm_call_json_t*)calloc(1, totalsize); - - if (call != NULL) - { - // Set the call structure members appropriately. - call->api_revision = CTRLM_VOICE_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - } - else - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - } - - if (bSuccess) - { - // Make the IARM call to controlMgr to configure the voice settings - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_CALL_SESSION_TERMINATE, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SESSION_TERMINATE Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - } - else - { - JsonObject result; - - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - if(bSuccess) { - LOGINFO("SESSION_TERMINATE call SUCCESS!"); - } else { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SESSION_TERMINATE returned FAILURE!"); - } - } - } - - if (call != NULL) - { - free(call); - } - - returnResponse(bSuccess); - } - - uint32_t VoiceControl::voiceSessionAudioStreamStart(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - ctrlm_voice_iarm_call_json_t* call = NULL; - IARM_Result_t res; - string jsonParams; - bool bSuccess = true; - - // Just pass through the input parameters, without understanding or checking them. - parameters.ToString(jsonParams); - - // We must allocate the memory for the call structure. Determine what we will need. - size_t totalsize = sizeof(ctrlm_voice_iarm_call_json_t) + jsonParams.size() + 1; - call = (ctrlm_voice_iarm_call_json_t*)calloc(1, totalsize); - - if (call != NULL) - { - // Set the call structure members appropriately. - call->api_revision = CTRLM_VOICE_IARM_BUS_API_REVISION; - size_t len = jsonParams.copy(call->payload, jsonParams.size()); - call->payload[len] = '\0'; - } - else - { - LOGERR("ERROR - Cannot allocate IARM structure - size: %u.", (unsigned)totalsize); - bSuccess = false; - } - - if (bSuccess) - { - // Make the IARM call to controlMgr to start the audio stream - res = IARM_Bus_Call(CTRLM_MAIN_IARM_BUS_NAME, CTRLM_VOICE_IARM_CALL_SESSION_AUDIO_STREAM_START, (void *)call, totalsize); - if (res != IARM_RESULT_SUCCESS) - { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SESSION_AUDIO_STREAM_START Bus Call FAILED, res: %d.", (int)res); - bSuccess = false; - } - else - { - JsonObject result; - - result.FromString(call->result); - bSuccess = result["success"].Boolean(); - response = result; - if(bSuccess) { - LOGINFO("SESSION_AUDIO_STREAM_START call SUCCESS!"); - } else { - LOGERR("ERROR - CTRLM_VOICE_IARM_CALL_SESSION_AUDIO_STREAM_START returned FAILURE!"); - } - } - } - - if (call != NULL) - { - free(call); - } - - returnResponse(bSuccess); - } - //End methods - - //Begin events - void VoiceControl::onSessionBegin(ctrlm_voice_iarm_event_json_t* eventData) - { - JsonObject params; - - params.FromString(eventData->payload); - - sendNotify("onSessionBegin", params); - } - - void VoiceControl::onStreamBegin(ctrlm_voice_iarm_event_json_t* eventData) - { - JsonObject params; - - params.FromString(eventData->payload); - - sendNotify("onStreamBegin", params); - } - - void VoiceControl::onKeywordVerification(ctrlm_voice_iarm_event_json_t* eventData) - { - JsonObject params; - - params.FromString(eventData->payload); - - sendNotify("onKeywordVerification", params); - } - - void VoiceControl::onServerMessage(ctrlm_voice_iarm_event_json_t* eventData) - { - JsonObject params; - - params.FromString(eventData->payload); - - sendNotify_("onServerMessage", params); - } - - void VoiceControl::onStreamEnd(ctrlm_voice_iarm_event_json_t* eventData) - { - JsonObject params; - - params.FromString(eventData->payload); - - sendNotify("onStreamEnd", params); - } - - void VoiceControl::onSessionEnd(ctrlm_voice_iarm_event_json_t* eventData) - { - JsonObject params; - - params.FromString(eventData->payload); - - sendNotify_("onSessionEnd", params); - } - //End events - - //Begin local private utility methods - void VoiceControl::setApiVersionNumber(unsigned int apiVersionNumber) - { - LOGINFO("setting version: %d", (int)apiVersionNumber); - m_apiVersionNumber = apiVersionNumber; - } - - void VoiceControl::sendNotify_(const char* eventName, JsonObject& parameters) - { - if(m_maskPii) - { - sendNotifyMaskParameters(eventName, parameters); - } - else - { - sendNotify(eventName, parameters); - } - } - //End local private utility methods - - } // namespace Plugin -} // namespace WPEFramework - diff --git a/VoiceControl/VoiceControl.h b/VoiceControl/VoiceControl.h deleted file mode 100644 index 074123b0..00000000 --- a/VoiceControl/VoiceControl.h +++ /dev/null @@ -1,95 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once - -#include "Module.h" -#include "libIBus.h" - -#include "ctrlm_ipc.h" -#include "ctrlm_ipc_voice.h" - -#define IARM_VOICECONTROL_PLUGIN_NAME "Voice_Control" - -namespace WPEFramework { - - namespace Plugin { - - class VoiceControl : public PluginHost::IPlugin, public PluginHost::JSONRPC { - private: - // We do not allow this plugin to be copied !! - VoiceControl(const VoiceControl&) = delete; - VoiceControl& operator=(const VoiceControl&) = delete; - - //Begin methods - uint32_t getApiVersionNumber(const JsonObject& parameters, JsonObject& response); - void sendNotify_(const char* eventName, JsonObject& parameters); - - uint32_t voiceStatus(const JsonObject& parameters, JsonObject& response); - uint32_t configureVoice(const JsonObject& parameters, JsonObject& response); - uint32_t setVoiceInit(const JsonObject& parameters, JsonObject& response); - uint32_t sendVoiceMessage(const JsonObject& parameters, JsonObject& response); - uint32_t voiceSessionByText(const JsonObject& parameters, JsonObject& response); // DEPRECATED - uint32_t voiceSessionTypes(const JsonObject& parameters, JsonObject& response); - uint32_t voiceSessionRequest(const JsonObject& parameters, JsonObject& response); - uint32_t voiceSessionTerminate(const JsonObject& parameters, JsonObject& response); - uint32_t voiceSessionAudioStreamStart(const JsonObject& parameters, JsonObject& response); - //End methods - - //Begin events - void onSessionBegin(ctrlm_voice_iarm_event_json_t* eventData); - void onStreamBegin(ctrlm_voice_iarm_event_json_t* eventData); - void onKeywordVerification(ctrlm_voice_iarm_event_json_t* eventData); - void onServerMessage(ctrlm_voice_iarm_event_json_t* eventData); - void onStreamEnd(ctrlm_voice_iarm_event_json_t* eventData); - void onSessionEnd(ctrlm_voice_iarm_event_json_t* eventData); - //End events - - public: - VoiceControl(); - virtual ~VoiceControl(); - //IPlugin methods - virtual const string Initialize(PluginHost::IShell* service) override; - virtual void Deinitialize(PluginHost::IShell* service) override; - virtual string Information() const override { return {}; } - - BEGIN_INTERFACE_MAP(VoiceControl) - INTERFACE_ENTRY(PluginHost::IPlugin) - INTERFACE_ENTRY(PluginHost::IDispatcher) - END_INTERFACE_MAP - - private: - void InitializeIARM(); - void DeinitializeIARM(); - // Handlers for ControlMgr BT Remote events - static void voiceEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - void iarmEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - // Local utility methods - void setApiVersionNumber(uint32_t apiVersionNumber); - void getMaskPii_(); - public: - static VoiceControl* _instance; - private: - uint32_t m_apiVersionNumber; - bool m_hasOwnProcess; - bool m_maskPii; - }; - } // namespace Plugin -} // namespace WPEFramework diff --git a/helpers/PluginInterfaceBuilder.h b/helpers/PluginInterfaceBuilder.h index fdfc5edb..82c5455f 100755 --- a/helpers/PluginInterfaceBuilder.h +++ b/helpers/PluginInterfaceBuilder.h @@ -39,11 +39,13 @@ namespace Plugin { public: PluginInterfaceRef() : _interface(nullptr) + , _service(nullptr) { } PluginInterfaceRef(INTERFACE* interface, PluginHost::IShell* controller) : _interface(interface) + , _service(controller) { } @@ -59,6 +61,7 @@ namespace Plugin { // use move PluginInterfaceRef(PluginInterfaceRef&& other) : _interface(other._interface) + , _service(other._service) { other._interface = nullptr; } @@ -199,12 +202,12 @@ namespace Plugin { return std::move(PluginInterfaceRef(interface, _service)); } - const uint32_t retryInterval() const + uint32_t retryInterval() const { return _retry_interval; } - const int retryCount() const + int retryCount() const { return _retry_count; } diff --git a/helpers/frontpanel.cpp b/helpers/frontpanel.cpp index f1a7e6ed..30ffce17 100644 --- a/helpers/frontpanel.cpp +++ b/helpers/frontpanel.cpp @@ -69,15 +69,11 @@ namespace WPEFramework { CFrontPanel* CFrontPanel::s_instance = NULL; static int globalLedBrightness = 100; -#ifdef CLOCK_BRIGHTNESS_ENABLED - static int clockBrightness = 100; -#endif + int CFrontPanel::initDone = 0; static bool isMessageLedOn = false; static bool isRecordLedOn = false; -#ifdef CLOCK_BRIGHTNESS_ENABLED - static bool isClockOn; -#endif + static bool powerStatus = false; //Check how this works on xi3 and rng's static bool started = false; static int m_numberOfBlinks = 0; @@ -155,7 +151,7 @@ namespace WPEFramework auto it = std::find(m_lights.begin(), m_lights.end(), IndicatorNameIarm); if (m_lights.end() == it) { - m_lights.push_back(IndicatorNameIarm); + m_lights.push_back(std::move(IndicatorNameIarm)); } } @@ -176,10 +172,7 @@ namespace WPEFramework } } #endif -#ifdef CLOCK_BRIGHTNESS_ENABLED - clockBrightness = device::FrontPanelTextDisplay::getInstance("Text").getTextBrightness(); - device::FrontPanelTextDisplay::getInstance("Text").setTextBrightness(clockBrightness); -#endif + globalLedBrightness = device::FrontPanelIndicator::getInstance("Power").getBrightness(); LOGINFO("Power light brightness, %d, power status %d", globalLedBrightness, powerStatus); @@ -215,6 +208,22 @@ namespace WPEFramework return s_instance; } + + void CFrontPanel::deinitialize() + { + + s_instance->stop(); + + if (_powerManagerPlugin) { + _powerManagerPlugin.Reset(); + } + if (s_instance) { + delete s_instance; + s_instance = nullptr; + } + initDone = 0; + } + bool CFrontPanel::start() { LOGWARN("Front panel start"); @@ -230,7 +239,7 @@ namespace WPEFramework auto it = std::find(m_lights.begin(), m_lights.end(), IndicatorNameIarm); if (m_lights.end() == it) - m_lights.push_back(IndicatorNameIarm); + m_lights.push_back(std::move(IndicatorNameIarm)); } } catch (...) @@ -263,7 +272,7 @@ namespace WPEFramework return lastError_; } - void CFrontPanel::addEventObserver(FrontPanel* o) + void CFrontPanel::addEventObserver(FrontPanelImplementation* o) { auto it = std::find(observers_.begin(), observers_.end(), o); @@ -272,7 +281,7 @@ namespace WPEFramework observers_.push_back(o); } - void CFrontPanel::removeEventObserver(FrontPanel* o) + void CFrontPanel::removeEventObserver(FrontPanelImplementation* o) { observers_.remove(o); } @@ -313,29 +322,6 @@ namespace WPEFramework return globalLedBrightness; } -#ifdef CLOCK_BRIGHTNESS_ENABLED - bool CFrontPanel::setClockBrightness(int brightness) - { - clockBrightness = brightness; - powerOnLed(FRONT_PANEL_INDICATOR_CLOCK); - return true; - } - - int CFrontPanel::getClockBrightness() - { - try - { - clockBrightness = device::FrontPanelTextDisplay::getInstance("Text").getTextBrightness(); - } - catch (...) - { - LOGERR("FrontPanel Exception Caught during [%s]\r\n", __func__); - } - - return clockBrightness; - } -#endif - bool CFrontPanel::powerOnLed(frontPanelIndicator fp_indicator) { stopBlinkTimer(); @@ -345,12 +331,6 @@ namespace WPEFramework { switch (fp_indicator) { - case FRONT_PANEL_INDICATOR_CLOCK: -#ifdef CLOCK_BRIGHTNESS_ENABLED - isClockOn = true; - device::FrontPanelTextDisplay::getInstance("Text").setTextBrightness(clockBrightness); -#endif - break; case FRONT_PANEL_INDICATOR_MESSAGE: isMessageLedOn = true; device::FrontPanelIndicator::getInstance("Message").setState(true); @@ -376,6 +356,8 @@ namespace WPEFramework //LOGWARN("CFrontPanel::powerOnLed() - FRONT_PANEL_INDICATOR_POWER not handled"); device::FrontPanelIndicator::getInstance("Power").setState(true); break; + default: + LOGERR("Invalid Indicator %d", fp_indicator); } } } @@ -394,12 +376,6 @@ namespace WPEFramework { switch (fp_indicator) { - case FRONT_PANEL_INDICATOR_CLOCK: -#ifdef CLOCK_BRIGHTNESS_ENABLED - isClockOn = false; - device::FrontPanelTextDisplay::getInstance("Text").setTextBrightness(0); -#endif - break; case FRONT_PANEL_INDICATOR_MESSAGE: isMessageLedOn = false; device::FrontPanelIndicator::getInstance("Message").setState(false); @@ -426,6 +402,8 @@ namespace WPEFramework //LOGWARN("CFrontPanel::powerOffLed() - FRONT_PANEL_INDICATOR_POWER not handled"); device::FrontPanelIndicator::getInstance("Power").setState(false); break; + default: + LOGERR("Invalid Indicator %d", fp_indicator); } } catch (...) @@ -461,7 +439,7 @@ namespace WPEFramework getNumberParameter("brightness", brightness); unsigned int color = 0; - if (parameters.HasLabel("color")) //color mode 2 + if (parameters.HasLabel("color") && !parameters["color"].String().empty()) //color mode 2 { string colorString = parameters["color"].String(); try @@ -476,7 +454,7 @@ namespace WPEFramework } else if (parameters.HasLabel("red")) //color mode 1 { - unsigned int red,green,blue; + unsigned int red = 0, green = 0, blue = 0; getNumberParameter("red", red); getNumberParameter("green", green); @@ -515,7 +493,7 @@ namespace WPEFramework stopBlinkTimer(); m_blinkList.clear(); string ledIndicator = svc2iarm(blinkInfo["ledIndicator"].String()); - int iterations; + int iterations = 0; getNumberParameterObject(blinkInfo, "iterations", iterations); JsonArray patternList = blinkInfo["pattern"].Array(); for (int i = 0; i < patternList.Length(); i++) @@ -527,7 +505,7 @@ namespace WPEFramework if (frontPanelBlinkHash.HasLabel("brightness")) getNumberParameterObject(frontPanelBlinkHash, "brightness", brightness); - int duration; + int duration = 0; getNumberParameterObject(frontPanelBlinkHash, "duration", duration); LOGWARN("setBlink ledIndicator: %s iterations: %d brightness: %d duration: %d", ledIndicator.c_str(), iterations, brightness, duration); frontPanelBlinkInfo.brightness = brightness; @@ -536,12 +514,12 @@ namespace WPEFramework if (frontPanelBlinkHash.HasLabel("color")) //color mode 2 { string color = frontPanelBlinkHash["color"].String(); - frontPanelBlinkInfo.colorName = color; + frontPanelBlinkInfo.colorName = std::move(color); frontPanelBlinkInfo.colorMode = 2; } else if (frontPanelBlinkHash.HasLabel("red")) //color mode 1 { - unsigned int red,green,blue; + unsigned int red = 0, green = 0, blue = 0; getNumberParameterObject(frontPanelBlinkHash, "red", red); getNumberParameterObject(frontPanelBlinkHash, "green", green); @@ -554,46 +532,11 @@ namespace WPEFramework { frontPanelBlinkInfo.colorMode = 0; } - m_blinkList.push_back(frontPanelBlinkInfo); + m_blinkList.push_back(std::move(frontPanelBlinkInfo)); } startBlinkTimer(iterations); } - JsonObject CFrontPanel::getPreferences() - { - return m_preferencesHash; - } - - void CFrontPanel::setPreferences(const JsonObject& preferences) - { - m_preferencesHash = preferences; - - Core::File file; - file = FP_SETTINGS_FILE_JSON; - - file.Open(false); - if (!file.IsOpen()) - file.Create(); - - m_preferencesHash.IElement::ToFile(file); - - file.Close(); - Utils::syncPersistFile (FP_SETTINGS_FILE_JSON); - } - - void CFrontPanel::loadPreferences() - { - m_preferencesHash.Clear(); - - Core::File file; - file = FP_SETTINGS_FILE_JSON; - - file.Open(); - m_preferencesHash.IElement::FromFile(file); - - file.Close(); - } - void CFrontPanel::startBlinkTimer(int numberOfBlinkRepeats) { LOGWARN("startBlinkTimer numberOfBlinkRepeats: %d m_blinkList.length : %zu", numberOfBlinkRepeats, m_blinkList.size()); @@ -673,41 +616,6 @@ namespace WPEFramework //if not blink again then the led color should stay on the LAST element in the array as stated in the spec } - void CFrontPanel::set24HourClock(bool is24Hour) - { - try - { - int newFormat = is24Hour ? device::FrontPanelTextDisplay::kModeClock24Hr : device::FrontPanelTextDisplay::kModeClock12Hr; - device::FrontPanelTextDisplay &textDisplay = device::FrontPanelConfig::getInstance().getTextDisplay("Text"); - int currentFormat = textDisplay.getCurrentTimeFormat(); - LOGINFO("set24HourClock - Before setting %d - Time zone read from DS is %d", newFormat, currentFormat); - textDisplay.setTimeFormat(newFormat); - currentFormat = textDisplay.getCurrentTimeFormat(); - LOGINFO("set24HourClock - After setting %d - Time zone read from DS is %d", newFormat, currentFormat); - } - catch (...) - { - LOGERR("Exception Caught during set24HourClock"); - } - } - - bool CFrontPanel::is24HourClock() - { - bool is24Hour = false; - try - { - device::FrontPanelTextDisplay &textDisplay = device::FrontPanelConfig::getInstance().getTextDisplay("Text"); - int currentFormat = textDisplay.getCurrentTimeFormat(); - LOGINFO("is24HourClock - Time zone read from DS is %d", currentFormat); - is24Hour = currentFormat == device::FrontPanelTextDisplay::kModeClock24Hr; - } - catch (...) - { - LOGERR("Exception Caught during is24HourClock"); - } - return is24Hour; - } - uint64_t BlinkInfo::Timed(const uint64_t scheduledTime) { diff --git a/helpers/frontpanel.h b/helpers/frontpanel.h index d9b441ca..5fb1b82c 100644 --- a/helpers/frontpanel.h +++ b/helpers/frontpanel.h @@ -40,7 +40,7 @@ namespace WPEFramework namespace Plugin { - class FrontPanel; + class FrontPanelImplementation; class CFrontPanel; class BlinkInfo @@ -98,30 +98,23 @@ namespace WPEFramework { public: static CFrontPanel* instance(PluginHost::IShell *service = nullptr); + static void deinitialize(); bool start(); bool stop(); std::string getLastError(); - void addEventObserver(FrontPanel* o); - void removeEventObserver(FrontPanel* o); + void addEventObserver(FrontPanelImplementation* o); + void removeEventObserver(FrontPanelImplementation* o); bool setBrightness(int fp_brighness); int getBrightness(); -#ifdef CLOCK_BRIGHTNESS_ENABLED - bool setClockBrightness(int brightness); - int getClockBrightness(); -#endif bool powerOffLed(frontPanelIndicator fp_indicator); bool powerOnLed(frontPanelIndicator fp_indicator); bool powerOffAllLed(); bool powerOnAllLed(); void setPowerStatus(bool powerStatus); - JsonObject getPreferences(); - void setPreferences(const JsonObject& preferences); bool setLED(const JsonObject& blinkInfo); void setBlink(const JsonObject& blinkInfo); void loadPreferences(); void stopBlinkTimer(); - void set24HourClock(bool is24Hour); - bool is24HourClock(); void onBlinkTimer(); static int initDone; @@ -136,7 +129,7 @@ namespace WPEFramework BlinkInfo m_blinkTimer; bool m_isBlinking; std::vector m_blinkList; - std::list observers_; + std::list observers_; std::string lastError_; }; diff --git a/services.cmake b/services.cmake index 660c9891..deabe8ed 100644 --- a/services.cmake +++ b/services.cmake @@ -45,7 +45,6 @@ option(PLUGIN_STORAGE_MANAGER "PLUGIN_STORAGE_MANAGER" OFF) option(PLUGIN_DEVICEDIAGNOSTICS "PLUGIN_DEVICEDIAGNOSTICS" ON) option(PLUGIN_SOUNDPLAYER "PLUGIN_SOUNDPLAYER" OFF) option(PLUGIN_TELEMETRY "PLUGIN_TELEMETRY" ON) -option(PLUGIN_LEDCONTROL "PLUGIN_LEDCONTROL" ON) option(PLUGIN_CONTINUEWATCHING "PLUGIN_CONTINUEWATCHING" ON)