Access Keys:
Skip to content (Access Key - 0)

Developer How To - Add Your Own Protocol to OpenRemote 2.0 Designer

Adding a new protocol to OpenRemote 2.0 Designer does not require code level changes under normal circumstances. A new protocol is deployed by submitting an XML configuration file that defines the required protocol details.

<?xml version="1.0" encoding="UTF-8"?>
<openremote xmlns="http://www.openremote.org" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.openremote.org protocol.xsd">

  <protocol displayName="My Protocol" tagName="mine">

    <attr name="command-name" label="Command Name">
      <validations>
        <allowBlank>false</allowBlank>
        <regex message="Command must be A, B or C">[ABC]</regex>
      </validations>
    </attr>

    <attr name="command-value" label="Value for Command">
      <validations>
        <allowBlank>false</allowBlank>
        <maxLength>1</maxLength>
        <regex message="Only numbers allowed">[0-9]</regex>
      </validations>
    </attr>
  </protocol>
</openremote> 
Listing 1: Example protocol definition for OpenRemote 2.0 Designer

In Listing 1 above, the protocol elements "tagName" attribute should match your protocol ID (as defined by the CommandBuilder in the Controller's controller.xml file.

For each command property, define an attribute element. For each attribute, a simple regex validation can be defined and a message which is shown to the user if their input does not match.

An attribute field is mandatory or optional depending on the value of the "allowBlank" element in the validations section. A maximum length of the input field can also be specified.

The protocol definition shown in Listing 1 will be used to create an input dialog for the user in Designer. When configured, it will generate a matching <command> entries in the controller.xml. The protocol definition in this example would yield:

<command protocol = "mine" >
  <property name = "command-name" value = "A"/>
  <property name = "command-value" value = "1"/>
</command>
Listing 2: Command declaration using custom protocol in Controller's controller.xml file

See Also

Added by Administrator , last edit by Marc Fleury on Oct 07, 2010 14:44

© 2008-2011 OpenRemote Inc. OpenRemote is a trademark of OpenRemote, Inc.
Adaptavist Theme Builder (3.3.3-conf210) Powered by Atlassian Confluence 2.10.3, the Enterprise Wiki.
Free theme builder license