Difference between revisions of "Developer:LPEC"

From LinnDocs
Jump to: navigation, search
Line 32: Line 32:
  
 
In order to subscribe to a service's events, issue a SUBSCRIBE message of the following form:
 
In order to subscribe to a service's events, issue a SUBSCRIBE message of the following form:
 +
<blockquote>SUBSCRIBE [id]/[type] [version]</blockquote>
 +
The device will respond with:<br>
  
 
<br>
 
<br>
<blockquote>SUBSCRIBE [id]/[type] [version]</blockquote>  
+
<blockquote>SUBSCRIBE [subscription-id]<br></blockquote>
 +
and will then send an initial event message, which contains the current state of all the service's evented variables:<br>
 +
<blockquote>EVENT [subscription-id] 0 [var1-name] "[var1]" [var2-name] "[var2]" ... [varn-name] "[varn]"<br></blockquote>
 +
e.g<br>
 +
<blockquote>SUBSCRIBE Ds/Product<br>SUBSCRIBE 49<br>EVENT 49 0 ProductName "Sneaky Music DS" ProductRoom "Main Room" ProductStandby "true" ProductSourceIndex "0"</blockquote>
 +
Subsequent changes to the service's evented variables will cause unsolicited messages to be sent from the device of the form:
 +
<blockquote>
 +
EVENT [subscription-id] [sequence-no] [var1-name] "[var1]" [var2-name] "[var2]" ... [varn-name] "[varn]"
 +
</blockquote>
 +
Only those variables that have changed value are reported.
 +
 
 +
The sequence number is a 32-bit unsigned number which increments with each event message and wraps around to 1.
 +
 
 +
A sequence number of 0 is reserved for the initial EVENT message, which contains the current state of all the service's evented variables (see above)
 +
 
 
= Discovery =
 
= Discovery =
  

Revision as of 12:24, 17 June 2008

Introduction

Linn's UPnP products can be controlled over a home network in an ever increaing number of ways. The primary means of control is, of course, UPnP itself, which subdivides product control into smaller units called services. A DS product, for instance, will provide some standard UPnP AV services:

AVTransport

RenderingControl

ConnectionManager

and additional Linn-specific services, such as:

Ds

Volkano

Product

Ui

It is possible in Bute and later software releases to control a Linn UPnP product using an alternative mechanism known as the Linn Protocol for Eventing and Control.

This is a basic Telnet-like protocol, which relies on the developer knowing in advance, or having discovered by some means, the TCP/IP of the device to be controlled. Knowing this, LPEC can be accessed by creating a raw socket session to port 23 of the device.

The rest of this document describes the format of the messages that LPEC expects and delivers.


Control

Each service contains actions, which are like methods that can be called on the device with input and output arguments.

An action can be perfomed by sending a message of the following form:

ACTION [id]/[type] [version] [action] "[inarg1]" "[inarg2]" ... "[inargn]"

e.g.

ACTION MediaRenderer/RenderingControl 1 SetVolume "0" "Master" "50"

All messages sent using LPEC get a response. The response to an ACTION message will be a RESPONSE message that reports the values of all the output arguments:

RESPONSE "[outarg1]" "[outarg2]" ... "[inargn]"

The SetVolume example given above has no output arguments, so the message received will simply be a <CR><LF> terminated RESPONSE message.

The following subsequent interaction better illustrates the RESPONSE message:

ACTION MediaRenderer/RenderingControl 1 GetVolume "0" "Master"

RESPONSE "50"

It should be mentioned that all input and output arguments are escaped according to XML escaping rules and enclosed in double-quotes.

Eventing

In order to subscribe to a service's events, issue a SUBSCRIBE message of the following form:

SUBSCRIBE [id]/[type] [version]

The device will respond with:


SUBSCRIBE [subscription-id]

and will then send an initial event message, which contains the current state of all the service's evented variables:

EVENT [subscription-id] 0 [var1-name] "[var1]" [var2-name] "[var2]" ... [varn-name] "[varn]"

e.g

SUBSCRIBE Ds/Product
SUBSCRIBE 49
EVENT 49 0 ProductName "Sneaky Music DS" ProductRoom "Main Room" ProductStandby "true" ProductSourceIndex "0"

Subsequent changes to the service's evented variables will cause unsolicited messages to be sent from the device of the form:

EVENT [subscription-id] [sequence-no] [var1-name] "[var1]" [var2-name] "[var2]" ... [varn-name] "[varn]"

Only those variables that have changed value are reported.

The sequence number is a 32-bit unsigned number which increments with each event message and wraps around to 1.

A sequence number of 0 is reserved for the initial EVENT message, which contains the current state of all the service's evented variables (see above)

Discovery

Although LPEC does not include a mechanism for discovering devices across a home network, it does contain a mechanism for knowing about the sub-devices within a single product.

When an LPEC connection is made the device sends ALIVE messages to describe thesub-devices that are currently available:

ALIVE <id> <udn>

e.g.

ALIVE Ds 4c494e4e-0050-c221-71e5-df000003013f
ALIVE Preamp 4c494e4e-0050-c221-71e5-df0000030133
ALIVE MediaRenderer 4c494e4e-0050-c221-71e5-df0000030171

It is possible for these sub-devices to be disabled and enabled during the normal operation of a product. if this occurs, BYEBYE messages and ALIVE are issued accordingly.

If a device is rebooted, the appropriate BYEBYE messages are sent and the LPEC connection is closed by the device.


Errors

After sending an ACTION, SUBSCRIBE, or UNSUBSCRIBE message, it is possible to receive an ERROR message of the form:

ERROR [code] "[description]"

The following errors are defined:

ERROR 101 "Command not recognised"
ERROR 102 "Service not specified"
ERROR 103 "Service not found"
ERROR 104 "Version invalid"
ERROR 105 "Version not specified"
ERROR 106 "Version not supported"
ERROR 107 "Method not specified"
ERROR 108 "Method execution exception"
ERROR 201 "Boolean argument invalid"
ERROR 202 "String argument invalid"
ERROR 203 "Unsigned numeric argument invalid"
ERROR 204 "Signed numeric invalid"
ERROR 205 "Binary argument invalid"
ERROR 206 "Invalid argument escaping"
ERROR 301 "Argument list incomplete"
ERROR 302 "Argument not quoted"
ERROR 303 "Argument incomplete"
ERROR 401 "Already subscribed"
ERROR 402 "Client has too many subscriptions"
ERROR 403 "Service has too many subscriptions"
ERROR 404 "Subscription not found"
ERROR 405 "Service not subscribed"
ERROR 406 "Invalid XML escaping"

Action-specific error messages may also be received.