Announcement

Collapse
No announcement yet.

IP and Serial Plugin

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • IP and Serial Plugin

    This is a new plugin that supersedes my earlier TCP Trigger (http://forums.homeseer.com/showthread.php?t=151068).

    The plugin can send and receive messages, or commands over TCP, UDP or serial. Like the previous plugin, you can configure events that trigger on receipt of strings. You can also send predefined command strings or the status/value of a homeseer device to tcp, udp or serial targets.

    At the heart of the plugin is the concept of a connection.
    Click image for larger version

Name:	ip1.jpg
Views:	1
Size:	104.4 KB
ID:	1204861

    A connection can be of type TCP, UDP, Serial or HTTP (HTTP is still experimental at the moment). TCP and UDP connections can be defined as either Hosts or Clients. A Host connection will wait for a remote device to connect to it and a client connection will go ahead and establish a session to a remote device. In the case of a TCP or serial connection, once a session is established, that connection can be used to both receive and send data.

    The address field is used with TCP and UCP connections to define either a client connection's target ip address, or in the case of a host connection, a range of remote addresses that the connection will accept incoming requests from. For serial connections this is the number of the COM port.

    You can also define a connection as a proxy. This allows you to have all data arriving on one connection be sent to another connection, possibly as a different type. As an example, I have a tcp host connection that receives data from iRule running on an iPad and forwards/proxies it to a Samsung TV over a serial connection.

    Commands can be predefined and used in Events as Actions.
    Click image for larger version

Name:	ip2.jpg
Views:	1
Size:	164.2 KB
ID:	1204862

    Serial parameters are setup here:
    Click image for larger version

Name:	ip3.jpg
Views:	1
Size:	75.2 KB
ID:	1204863

    My main driver for creating this plugin is integration with iRule but I've tried to keep things generic so that it can work with as many other things as possible. For iRule use, I particularly wanted to support what iRule calls "Feedbacks." I wanted to able to see in real time the status of my Homeseer devices in the iRule app on my iPad. Using the plugin I can have a slider in iRule that controls the brightness of a light for instance. The slider also gets updated if the light is controlled directly, or from another source.

    I think the best way to figure out the plugin is to give it a try. Inevitably there will be a few bugs and wrinkles. Please post your findings, comments and questions and I will try my best to help.

    David

    8/23/2012 - AM
    New update includes support for persistent/non-persistent tcp clients and "pass-thru" scripts.

    8/23/2012 - PM
    Second update of the day. Fixes bug reported by jayman13 reading the ini file at startup and adds a "Threshold" option to the serial configuration.

    8/24/2012 - AM
    Change to allow larger [Commands] section in ini file. Modified TCP close function for non-persistent connections.

    8/24/2012 - PM
    Non-persistent TCP clients no longer instantiate a new receiver class.

    8/25/2012
    Fix for plugin initialization when [Commands] is empty.

    8/27/2012
    Added additional check for TcpClient is connected before sending data. Moved non-persistent TCP client stop routine further down the code.

    12/05/2012
    Triggers match using encoding types, not just plain text
    Persistent TCP Clients will restart if connection drops, initial attempt immediate, subsequent attempt
    determined by Watchdog timer, configurable, defaults to 10 seconds
    Scripting Access:
    Send(Command, Connection)
    Send("stuff", Encoding, Connection)
    Persistent TcpClient connect/disconnect events

    12/06/2012
    Fixed bug when reading commands containing an '=' symbol from the ini file.

    HSPI_DRHSIPPLUGIN.zip
    Last edited by drule; December 11th, 2012, 06:09 AM.

  • #2
    HS3 version of IP/Serial Plugin now posted

    With drule's go-ahead I have posted the HS3 version of his IP/Serial plugin

    The plugin can be found here and the discussion thread here
    cheeryfool

    Comment

    Working...
    X