RDK Resources
[*RDK Preferred*]
Code Management Facility
RDK Forums
[RDK Conferences]
RDK Support
Archives
Papers & Presentations Archive
...
Ex:-
Code Block | ||
---|---|---|
| ||
{ "$schema": "plugin.schema.json", "info": { "title": "Plugin Name Plugin", "callsign": "PluginName", "locator": "libWPEFrameworkPluginName.so", "status": "production", "description": "The PluginName plugin allows retrieving of various plugin-related information.", "version": "1.0" }, "interface": { "$ref": "{interfacedir}/PluginName.json#" } } |
...
Ex:- Declare the class in the following name space with constructor and destructor:
namespace WPEFramework {
namespace Plugin {
...
Code Block | ||
---|---|---|
| ||
namespace WPEFramework { namespace Plugin { class PluginName : public PluginHost::IPlugin, public PluginHost::IWeb, public PluginHost::JSONRPC |
...
public:
PluginName()
...
{ public: PluginName() : _skipURL(0) |
...
, _service(nullptr) |
...
, _subSystem(nullptr) |
...
{
...
{ RegisterAll(); |
...
}
virtual ~PluginName()
{
UnregisterAll();
}
...
}
virtual ~PluginName()
{
UnregisterAll();
}
} |
Declare the methods in the above class, required to implement the functionality of the plugin
...
Code Block | ||
---|---|---|
| ||
void |
...
RegisterAll(); |
...
void UnregisterAll(); |
...
Code Block |
---|
virtual const string Initialize(PluginHost::IShell* service); |
...
virtual void Deinitialize(PluginHost::IShell* service); |
Code Block |
---|
...
uint32_t get_method(JsonData::Plugin::ClassName& response) const; |
...
uint32_t set_method(JsonData::Plugin::ClassName& response) const; |
This method is used to process the REST APIs request such as GET/POST/SET and return the response
Code Block |
---|
virtual Core::ProxyType<Web::Response> Process(const Web::Request& request) override; |
2.7) <PluginName>.cpp: This class does contains all the definitions for the methods declared in the Plugin.h and those definitions should be defined inside the below namespace.
The plugin should register using service registration MACRO as declared below:
Code Block |
---|
...
namespace WPEFramework |
...
namespace Plugin {
...
{ namespace Plugin { SERVICE_REGISTRATION(Plugin, 1, 0); |
...
//All the methods declared in Plugin.h should be defined |
...
here } } |
}
2.8) <PluginName>JsonRpc.cpp: This class is used to register the methods with JSON RPC interface as below
Ex:-
namespace WPEFramework {
namespace Plugin {
...
Code Block | ||
---|---|---|
| ||
namespace WPEFramework { namespace Plugin { using namespace JsonData::PluginName; void Plugin::RegisterAll() |
...
{ |
...
//Can register any number of methods in this |
...
way Property<className>(_T("parameter1"), &PluginName::get_method, nullptr, this); |
...
Property<className>(_T("parameter2"), &PluginName::set_method, nullptr, this); |
...
}
...
} void Plugin::UnregisterAll() |
...
{ |
...
Unregister(_T("parameter1")); |
...
Unregister(_T("parameter2")); |
...
}
}
} |
}
}
}
The registered (get / set ) methods are defined in the same file
...
Code Block | ||
---|---|---|
| ||
uint32 |
...
_t Plugin::get_method(ClassName& response) const |
...
{ |
...
//body of the method |
...
}
...
} uint32_t Plugin::set_method(ClassName& response) const |
...
{ |
...
//body of the method |
...
} |
Please refer any existing plugin (rdkv_4.0_beta/build-raspberrypi-rdk-hybrid-thunder/tmp/work/cortexa7t2hf-neon-vfpv4-rdk-linux-gnueabi/wpeframework-plugins/3.0+gitrAUTOINC+886f9025b3-r1/git/) for further clarifications
...