Class: RUPNP::CP::RemoteDevice

Inherits:
Base
  • Object
show all
Defined in:
lib/rupnp/cp/remote_device.rb

Overview

A device is a UPnP service provider.

Author:

  • Sylvain Daubert.

Constant Summary

Constants inherited from Base

Base::HTTP_COMMON_CONFIG

Constants included from LogMixin

LogMixin::LOG_LEVEL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#get_description, #inspect

Methods included from LogMixin

#log

Methods included from Tools

#build_url, #snake_case, #urn_are_equivalent?, #usn2udn

Constructor Details

#initialize(control_point, notification) ⇒ RemoteDevice

Returns a new instance of RemoteDevice.

Parameters:



96
97
98
99
100
101
102
103
104
# File 'lib/rupnp/cp/remote_device.rb', line 96

def initialize(control_point, notification)
  super()
  @control_point = control_point
  @notification = notification

  @icons = []
  @services = []
  @devices = []
end

Instance Attribute Details

#cache_controlString (readonly)

Contains max-age directive used to specify advertisement validity

Returns:

  • (String)


33
34
35
# File 'lib/rupnp/cp/remote_device.rb', line 33

def cache_control
  @cache_control
end

#control_pointControlPoint (readonly)

Get control point which controls this device

Returns:



12
13
14
# File 'lib/rupnp/cp/remote_device.rb', line 12

def control_point
  @control_point
end

#dateString (readonly)

Date when response was generated

Returns:

  • (String)


30
31
32
# File 'lib/rupnp/cp/remote_device.rb', line 30

def date
  @date
end

#devicesArray<Device> (readonly)

List of embedded devices

Returns:

  • (Array<Device>)


91
92
93
# File 'lib/rupnp/cp/remote_device.rb', line 91

def devices
  @devices
end

#expirationTime (readonly)

Expiration time for the advertisement

Returns:

  • (Time)


36
37
38
# File 'lib/rupnp/cp/remote_device.rb', line 36

def expiration
  @expiration
end

#extString (readonly)

Returns:

  • (String)


27
28
29
# File 'lib/rupnp/cp/remote_device.rb', line 27

def ext
  @ext
end

#friendly_nameString (readonly)

Short description for end users

Returns:

  • (String)


52
53
54
# File 'lib/rupnp/cp/remote_device.rb', line 52

def friendly_name
  @friendly_name
end

#iconsArray<OpenStruct> (readonly)

Array of icons to depict device in control point UI

Returns:

  • (Array<OpenStruct>)


85
86
87
# File 'lib/rupnp/cp/remote_device.rb', line 85

def icons
  @icons
end

#locationString (readonly)

URL to the UPnP description of the root device

Returns:

  • (String)


25
26
27
# File 'lib/rupnp/cp/remote_device.rb', line 25

def location
  @location
end

#manufacturerString (readonly)

Manufacturer’s name

Returns:

  • (String)


55
56
57
# File 'lib/rupnp/cp/remote_device.rb', line 55

def manufacturer
  @manufacturer
end

#manufacturer_urlString (readonly)

Web site for manufacturer

Returns:

  • (String)


58
59
60
# File 'lib/rupnp/cp/remote_device.rb', line 58

def manufacturer_url
  @manufacturer_url
end

#model_descriptionString (readonly)

Long decription for end user

Returns:

  • (String)


61
62
63
# File 'lib/rupnp/cp/remote_device.rb', line 61

def model_description
  @model_description
end

#model_nameString (readonly)

Model name

Returns:

  • (String)


64
65
66
# File 'lib/rupnp/cp/remote_device.rb', line 64

def model_name
  @model_name
end

#model_numberString (readonly)

Model number

Returns:

  • (String)


67
68
69
# File 'lib/rupnp/cp/remote_device.rb', line 67

def model_number
  @model_number
end

#model_urlString (readonly)

Web site for model

Returns:

  • (String)


70
71
72
# File 'lib/rupnp/cp/remote_device.rb', line 70

def model_url
  @model_url
end

#presentation_urlString (readonly)

URL to presentation for device

Returns:

  • (String)


82
83
84
# File 'lib/rupnp/cp/remote_device.rb', line 82

def presentation_url
  @presentation_url
end

#serial_umberString (readonly)

Serial number

Returns:

  • (String)


73
74
75
# File 'lib/rupnp/cp/remote_device.rb', line 73

def serial_umber
  @serial_umber
end

#serverString (readonly)

Get SERVER string

Returns:

  • (String)


22
23
24
# File 'lib/rupnp/cp/remote_device.rb', line 22

def server
  @server
end

#servicesArray<Service> (readonly)

List of device’s services

Returns:

  • (Array<Service>)


88
89
90
# File 'lib/rupnp/cp/remote_device.rb', line 88

def services
  @services
end

#stString (readonly)

Get search target.

Returns:

  • (String)


16
17
18
# File 'lib/rupnp/cp/remote_device.rb', line 16

def st
  @st
end

#typeString (readonly)

Device type

Returns:

  • (String)


49
50
51
# File 'lib/rupnp/cp/remote_device.rb', line 49

def type
  @type
end

#udnString (readonly)

Unique Device Name

Returns:

  • (String)


76
77
78
# File 'lib/rupnp/cp/remote_device.rb', line 76

def udn
  @udn
end

#upcString (readonly)

Universal Product Code

Returns:

  • (String)


79
80
81
# File 'lib/rupnp/cp/remote_device.rb', line 79

def upc
  @upc
end

#upnp_versionString (readonly)

UPnP version used by the device

Returns:

  • (String)


40
41
42
# File 'lib/rupnp/cp/remote_device.rb', line 40

def upnp_version
  @upnp_version
end

#url_baseString (readonly)

URL base for device access

Returns:

  • (String)


46
47
48
# File 'lib/rupnp/cp/remote_device.rb', line 46

def url_base
  @url_base
end

#usnString (readonly)

Get Unique Service Name

Returns:

  • (String)


19
20
21
# File 'lib/rupnp/cp/remote_device.rb', line 19

def usn
  @usn
end

#xmlnsString (readonly)

XML namespace for device description

Returns:

  • (String)


43
44
45
# File 'lib/rupnp/cp/remote_device.rb', line 43

def xmlns
  @xmlns
end

Instance Method Details

#fetchvoid

This method returns an undefined value.

Get device from its description



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/rupnp/cp/remote_device.rb', line 108

def fetch
  description_getter = EM::DefaultDeferrable.new

  description_getter.errback do
    msg = "Failed getting description"
    log :error, "Fetching device: #{msg}"
    fail self, msg
  end

  extract_from_ssdp_notification description_getter

  description_getter.callback do |description|
    @description = description
    unless description
      fail self, 'Blank description returned'
      next
    end

    if bad_description?
      fail self, "Bad description returned: #@description"
      next
    end

    extract_url_base
    extract_device_info
    extract_icons

    @services_extracted = @devices_extracted = false
    extract_services
    extract_devices

    tick_loop = EM.tick_loop do
      :stop if @services_extracted and @devices_extracted
    end
    tick_loop.on_stop { succeed self }
  end
end