diff --git a/apis/LEDControl/ILEDControl.h b/apis/LEDControl/ILEDControl.h index 1043808b..c4a9bcbf 100644 --- a/apis/LEDControl/ILEDControl.h +++ b/apis/LEDControl/ILEDControl.h @@ -33,26 +33,37 @@ namespace WPEFramework using IStringIterator = RPC::IIteratorType; - struct EXTERNAL LEDControlState { - string state; + virtual ~ILEDControl() = default; + + enum LEDControlState : uint8_t { + LEDSTATE_NONE = 0 /* @text NONE */, + LEDSTATE_ACTIVE /* @text ACTIVE */, + LEDSTATE_STANDBY /* @text STANDBY */, + LEDSTATE_WPS_CONNECTING /* @text WPS_CONNECTING */, + LEDSTATE_WPS_CONNECTED /* @text WPS_CONNECTED */, + LEDSTATE_WPS_ERROR /* @text WPS_ERROR */, + LEDSTATE_FACTORY_RESET /* @text FACTORY_RESET */, + LEDSTATE_USB_UPGRADE /* @text USB_UPGRADE */, + LEDSTATE_DOWNLOAD_ERROR /* @text DOWNLOAD_ERROR */, + LEDSTATE_MAX /* @text MAX */ }; // @text getSupportedLEDStates - // @brief Returns all the LED states supported by the platform - // @param supportedLEDStates - out - string [] of supported LED states - // @param success - out - boolean + // @details Returns the list of LED states that are actually supported by the platform at runtime. Possible values include `NONE`, `ACTIVE`, `STANDBY`, `WPS_CONNECTING`, `WPS_CONNECTED`, `WPS_ERROR`, `FACTORY_RESET`, `USB_UPGRADE` and `DOWNLOAD_ERROR`. + // @param supportedLEDStates: string [] of supported LED states. e.g. "['ACTIVE', 'STANDBY', 'WPS_CONNECTING', 'WPS_CONNECTED', 'WPS_ERROR', 'FACTORY_RESET', 'USB_UPGRADE', 'DOWNLOAD_ERROR']" + // @param success: boolean virtual Core::hresult GetSupportedLEDStates(IStringIterator*& supportedLEDStates /* @out */, bool& success /* @out */) = 0; // @text getLEDState - // @brief Returns current LED state. - // @param LEDControlState - out - virtual Core::hresult GetLEDState(LEDControlState& ledState /* @out */) = 0; + // @brief Retrieves current state of the LED. e.g. "WPS_CONNECTING" + // @param state: LEDControlState + virtual Core::hresult GetLEDState(LEDControlState& state /* @out */) = 0; // @text setLEDState - // @brief Change the device LED state to one mentioned in the input argument. - // @param state - in - string - // @param success - out - boolean - virtual Core::hresult SetLEDState(const string& state, bool& success /* @out */) = 0; + // @brief Sets the device LED to a requested state from those available in `GetSupportedLEDStates`. + // @param state: LEDControlState. e.g. "FACTORY_RESET" + // @param success: boolean + virtual Core::hresult SetLEDState(const LEDControlState& state, bool& success /* @out */) = 0; }; } // namespace Exchange } // namespace WPEFramework diff --git a/docs/apis/LEDControlPlugin.md b/docs/apis/LEDControlPlugin.md index d5f85a67..86cb66dc 100644 --- a/docs/apis/LEDControlPlugin.md +++ b/docs/apis/LEDControlPlugin.md @@ -1,191 +1,174 @@ - - -# LEDControl Plugin - -A org.rdk.LEDControl plugin for Thunder framework. - -### Table of Contents - -- [Abbreviation, Acronyms and Terms](#Abbreviation,_Acronyms_and_Terms) -- [Description](#Description) -- [Configuration](#Configuration) -- [Methods](#Methods) - - -# Abbreviation, Acronyms and Terms - -[[Refer to this link](overview/aat.md)] - - -# Description - -The `LEDControl` plugin allows you to control brightness and power state for LEDs on a device. - -The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [[Thunder](#Thunder)]. - - -# Configuration - -The table below lists configuration options of the plugin. - -| Name | Type | Description | -| :-------- | :-------- | :-------- | -| callsign | string | Plugin instance name (default: *org.rdk.LEDControl*) | -| classname | string | Class name: *org.rdk.LEDControl* | -| locator | string | Library name: *libWPEFrameworkLEDControl.so* | -| autostart | boolean | Determines if the plugin shall be started automatically along with the framework | - - -# Methods - -The following methods are provided by the org.rdk.LEDControl plugin: - -LEDControl interface methods: - -| Method | Description | -| :-------- | :-------- | -| [getSupportedLEDStates](#getSupportedLEDStates) | Returns all the LED states supported by the platform | -| [getLEDState](#getLEDState) | Returns current LED state | -| [setLEDState](#setLEDState) | Change the device LED state to one mentioned in the input argument | - - - -## *getSupportedLEDStates* - -Returns all the LED states supported by the platform. - -### Events - -No Events - -### Parameters - -This method takes no parameters. - -### Result - -| Name | Type | Description | -| :-------- | :-------- | :-------- | -| result | object | | -| result.supportedLEDStates | array | Returns all the LED states available on the platform | -| result.supportedLEDStates[#] | string | | -| result.success | boolean | Whether the request succeeded | - -### Example - -#### Request - -```json -{ - "jsonrpc": "2.0", - "id": 42, - "method": "org.rdk.LEDControl.getSupportedLEDStates" -} -``` - -#### Response - -```json -{ - "jsonrpc": "2.0", - "id": 42, - "result": { - "supportedLEDStates": [ - "`ACTIVE`, `STANDBY`, `WPS_CONNECTING`, `WPS_CONNECTED`, `WPS_ERROR`, `FACTORY_RESET', 'USB_UPGRADE', 'DOWNLOAD_ERROR'" - ], - "success": true - } -} -``` - - -## *getLEDState* - -Returns current LED state. - -### Events - -No Events - -### Parameters - -This method takes no parameters. - -### Result - -| Name | Type | Description | -| :-------- | :-------- | :-------- | -| result | object | | -| result.state | string | Indicates a platform supported LED state | - -### Example - -#### Request - -```json -{ - "jsonrpc": "2.0", - "id": 42, - "method": "org.rdk.LEDControl.getLEDState" -} -``` - -#### Response - -```json -{ - "jsonrpc": "2.0", - "id": 42, - "result": { - "state": "ACTIVE" - } -} -``` - - -## *setLEDState* - -Change the device LED state to one mentioned in the input argument. - -### Events - -No Events - -### Parameters - -| Name | Type | Description | -| :-------- | :-------- | :-------- | -| params | object | | -| params.state | string | Indicates a platform supported LED state | - -### Result - -| Name | Type | Description | -| :-------- | :-------- | :-------- | -| result | boolean | Whether the request succeeded | - -### Example - -#### Request - -```json -{ - "jsonrpc": "2.0", - "id": 42, - "method": "org.rdk.LEDControl.setLEDState", - "params": { - "state": "ACTIVE" - } -} -``` - -#### Response - -```json -{ - "jsonrpc": "2.0", - "id": 42, - "result": true -} -``` - + + +# ILEDControl Plugin + +A org.rdk.LEDControl plugin for Thunder framework. + +### Table of Contents + +- [Abbreviation, Acronyms and Terms](#head.Abbreviation,_Acronyms_and_Terms) +- [Description](#head.Description) +- [Configuration](#head.Configuration) +- [Methods](#head.Methods) + + +# Abbreviation, Acronyms and Terms + +[[Refer to this link](userguide/aat.md)] + + +# Description + +The `LEDControl` plugin allows you to control brightness and power state for LEDs on a device. + +The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [[Thunder](#ref.Thunder)]. + + +# Configuration + +The table below lists configuration options of the plugin. + +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| callsign | string | Plugin instance name (default: *org.rdk.LEDControl*) | +| classname | string | Class name: *org.rdk.LEDControl* | +| locator | string | Library name: *libWPEFrameworkILEDControl.so* | +| autostart | boolean | Determines if the plugin shall be started automatically along with the framework | + + +# Methods + +The following methods are provided by the LEDControl plugin: + +ILEDControl interface methods: + +| Method | Description | +| :-------- | :-------- | +| [GetLEDState](#method.GetLEDState) | Retrieves current state of the LED. e.g. "WPS_CONNECTING" | +| [GetSupportedLEDStates](#method.GetSupportedLEDStates) | Returns the list of LED states that are actually supported by the platform at runtime. Possible values include `NONE`, `ACTIVE`, `STANDBY`, `WPS_CONNECTING`, `WPS_CONNECTED`, `WPS_ERROR`, `FACTORY_RESET`, `USB_UPGRADE` and `DOWNLOAD_ERROR`. | +| [SetLEDState](#method.SetLEDState) | Changes the device LED state to mentioned input state. | + + +## *GetLEDState [method](#head.Methods)* + +Retrieves current state of the LED. e.g. "WPS_CONNECTING" + +### Events +No events are associated with this method. +### Parameters +This method takes no parameters. +### Results +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| result.state | LEDControlState | LEDControlState | + +### Examples + + +#### Request + +```json +{ + "jsonrpc": "2.0", + "id": 42, + "method": "org.rdk.LEDControl.GetLEDState" +} +``` + +#### Response + +```json +{ + "jsonrpc": "2.0", + "id": 42, + "result": { + "state": "FACTORY_RESET" + } +} +``` + +## *GetSupportedLEDStates [method](#head.Methods)* + +Returns the list of LED states that are actually supported by the platform at runtime. Possible values include `NONE`, `ACTIVE`, `STANDBY`, `WPS_CONNECTING`, `WPS_CONNECTED`, `WPS_ERROR`, `FACTORY_RESET`, `USB_UPGRADE` and `DOWNLOAD_ERROR`. + +### Events +No events are associated with this method. +### Parameters +This method takes no parameters. +### Results +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| result.supportedLEDStates | IStringIterator | string [] of supported LED states. | +| result.supportedLEDStates[#] | string | | +| result.success | bool | boolean | + +### Examples + + +#### Request + +```json +{ + "jsonrpc": "2.0", + "id": 42, + "method": "org.rdk.LEDControl.GetSupportedLEDStates" +} +``` + +#### Response + +```json +{ + "jsonrpc": "2.0", + "id": 42, + "result": { + "supportedLEDStates": [ + "ACTIVE", "STANDBY", "WPS_CONNECTING", "WPS_CONNECTED", "WPS_ERROR", "FACTORY_RESET", "USB_UPGRADE", "DOWNLOAD_ERROR" + ], + "success": "true" + } +} +``` + +## *SetLEDState [method](#head.Methods)* + +Sets the device LED to a requested state from those available in `GetSupportedLEDStates`. + +### Events +No events are associated with this method. +### Parameters +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| params.state | LEDControlState | LEDControlState | +### Results +| Name | Type | Description | +| :-------- | :-------- | :-------- | +| result.success | bool | boolean | + +### Examples + + +#### Request + +```json +{ + "jsonrpc": "2.0", + "id": 42, + "method": "org.rdk.LEDControl.SetLEDState", + "params": { + "state": "FACTORY_RESET" + } +} +``` + +#### Response + +```json +{ + "jsonrpc": "2.0", + "id": 42, + "result": { + "success": "true" + } +} +```