Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

<< Work in progress >>

Most of the up-to-data examples, definitely with the new JSONRPC, can be found here: https://github.com/WebPlatformForEmbedded/ThunderNanoServices/tree/master/examples

...

This file contains the plugin's information like schema, information and interface json file etc.,

            Ex:-

{code}

                        {

                                       "$schema": "plugin.schema.json",

...

                                        }

                        }

{code}

2.5) <PluginName>.config: This file is used to set some configurations of the Plug-in 

...

Declare the plugin class in this which should contains all the structures, variables and methods which are needed for plugin implementation. The interface header auto-generated earlier will be used here,

            Ex:-   Declare the class in the following name space with constructor and destructor: 

...

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: 

                        namespace WPEFramework {

                                     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 {

                                    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

 uint32_t Plugin::get_method(ClassName& response) const

 {

//body of the method

}

 uint32_t Plugin::set_method(ClassName& response) const

     {

//body of the method

}