User Tools

Site Tools


protocol_plug_manager_for_linux

Protocol Plug-in Manager

Overview

This guide will help you create your own protocol plug-in for IoTivity. By installing the plug-in at runtime, your device can communicate with IoTivity applications.

Overall flows

Using the Plugin Manager API, an application can start plugins located in a specific folder. After starting, the plugin will try to find it’s device using it's own protocol and will create a resource server when the device is found. Then the application can find and communicate with the resource using the base API as a normal IoTivity resource, as shown in the following diagram.

Using Plugin Manager

The following sections describe how to start plugins using Plugin Manager.

Setting plugin configuration

For plugin configuration, the PluginManager.xml file should be located in the folder with the application's executable file. Then, Plugin Manager can load the config information when the application creates Plugin Manager instance. By editing the configuration file, the application developer can change the plugins folder, the max number of plugins in the following:

<?xml version="1.0" encoding="utf-8"?>
<pluginManager>
    <pluginInfo    	
       PluginPath="./plugins"        
       MaxPlugin="50" >
    </pluginInfo>
</pluginManager>

Locating plugin and manifest file

Before starting plugins, you should locate the plugin binary in the path specified in the plugin configuration. Plugins should be in the path with separated folder

/sample-app
   - sample-executable
   - pluginmanager.xml
   - libpmimpl.so
/ sample-app /plugins
/ sample-app /plugins/mqtt-fan
- mqttfanplugin.so
- plugin.xml 
/ sample-app /plugins/hue
- hueplugin.so
- plugin.xml 

Each plugin should have a manifest XML file describing it’s information in the same folder and will have following information:

Key Name Description
id Unique id of the plugin
version Version of the plugin
name Name of the plugin
resourcetype Supported OIC resource type by the plugin
provider-name Provider name of the plugin

The following XML description is a plugin manifest file for Philips Hue Plugin.

<?xml version="1.0" encoding="UTF-8"?>
<plugin
id="oic.plugin.hue"  
version="0.1"
name="hue plugin"
resourcetype="oic.light"
provider-name="wallace">
  <runtime library="libplugin-hue-light" funcs="hue_light"/>
</plugin>

Starting plugins with attribute

With the plugin information described in the manifest file, the application can start plugins.

PluginManager *m_pm = new PluginManager();
std::vector<Plugin> plugins = m_pm->getPlugins();
std::string name = plugins[0].getName();
std::string id = plugins[0].getId();

Using plugin resources

This guide describes how to communicate with non-oic devices using plugins and the IoTivity API.

Hue plugin

Applications can find the Hue device with “device.light” resource type and communicate the following attributes:

Attribute Key Attribute Value Type Description
power “on”, “off” String Turn on/off Hue bulb
brightness 0~125 Integer Change brightness of the bulb
color 0~65,535 Integer Change color of the bulb

MQTT FAN plugin

Applications can find the MQTT FAN device using “oic.fan” resource type and communicate the following attributes:

Attribute Key Attribute Value Type Description
power “on”, “off” String Turn on/off the fan
protocol_plug_manager_for_linux.txt · Last modified: 2015/04/21 10:20 by Myungjae Lee