UPnP

DESCRIPTION:

An implementation of the UPnP 1.0 protocol for devices, services and control points. UPnP allows automatic configuration of networked devices. It is an open protocol including device discovery using SSDP and service control using SOAP.

FEATURES/PROBLEMS:

SYNOPSIS:

See UPnP::Device for instructions on creating a UPnP device.

See UPnP::Service for instructinos on creating a UPnP service.

Print out information about UPnP devices nearby:

upnp_discover

Listen for UPnP resource notifications:

upnp_listen

Search for root UPnP devices and print out their description URLs:

require 'UPnP/SSDP'

resources = UPnP::SSDP.new.search :root
locations = resources.map { |resource| resource.location }
puts locations.join("\n")

Create a UPnP::Control::Device from the first discovered root device:

require 'UPnP/control/device'

device = UPnP::Control::Device.create locations.first

Enumerate actions on all services on the device:

service_names = device.services.map do |service|
  service.methods(false)
end

puts service_names.sort.join("\n")

Assuming the root device is an InternetGatewayDevice with a WANIPConnection service, print out the external IP address for the gateway:

wic = device.services.find { |service| service.type =~ %rWANIPConnection/ }
puts wic.GetExternalIPAddress

REQUIREMENTS:

INSTALL:

sudo gem install UPnP

LICENSE:

Original code copyright 2008 Eric Hodel. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the names of the authors nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.