Class: RUPNP::CP::RemoteDevice
- Defined in:
- lib/rupnp/cp/remote_device.rb
Overview
A device is a UPnP service provider.
Constant Summary collapse
- DEFAULT_MAX_AGE =
Number of seconds the advertisement is valid. Used when
ssdp:update
advertisement is received but no previuousssdp:alive
was received. 600
Constants inherited from Base
Constants included from LogMixin
Instance Attribute Summary collapse
-
#boot_id ⇒ Integer
readonly
BOOTID.UPNP.ORG field value.
-
#cache_control ⇒ String
readonly
Contains
max-age
directive used to specify advertisement validity. -
#config_id ⇒ nil, Integer
readonly
CONFIGID.UPNP.ORG field value.
-
#control_point ⇒ ControlPoint
readonly
Get control point which controls this device.
-
#date ⇒ String
readonly
Date when response was generated.
-
#devices ⇒ Array<Device>
readonly
List of embedded devices.
-
#expiration ⇒ Time
readonly
Expiration time for the advertisement.
- #ext ⇒ String readonly
-
#friendly_name ⇒ String
readonly
Short description for end users.
-
#icons ⇒ Array<OpenStruct>
readonly
Array of icons to depict device in control point UI.
-
#location ⇒ String
readonly
URL to the UPnP description of the root device.
-
#manufacturer ⇒ String
readonly
Manufacturer’s name.
-
#manufacturer_url ⇒ String
readonly
Web site for manufacturer.
-
#model_description ⇒ String
readonly
Long decription for end user.
-
#model_name ⇒ String
readonly
Model name.
-
#model_number ⇒ String
readonly
Model number.
-
#model_url ⇒ String
readonly
Web site for model.
-
#presentation_url ⇒ String
readonly
URL to presentation for device.
-
#serial_umber ⇒ String
readonly
Serial number.
-
#server ⇒ String
readonly
Get SERVER string.
-
#services ⇒ Array<Service>
readonly
List of device’s services.
-
#st ⇒ String
readonly
Get search target.
-
#type ⇒ String
readonly
Device type.
-
#udn ⇒ String
readonly
Unique Device Name.
-
#upc ⇒ String
readonly
Universal Product Code.
-
#upnp_version ⇒ String
readonly
UPnP version used by the device.
-
#url_base ⇒ String
readonly
URL base for device access.
-
#usn ⇒ String
readonly
Get Unique Service Name.
-
#xmlns ⇒ String
readonly
XML namespace for device description.
Instance Method Summary collapse
-
#fetch ⇒ void
Get device from its description.
-
#initialize(control_point, notification) ⇒ RemoteDevice
constructor
A new instance of RemoteDevice.
-
#update(notification) ⇒ void
Update a device from a ssdp:update notification.
Methods inherited from Base
Methods included from LogMixin
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.
108 109 110 111 112 113 114 115 116 |
# File 'lib/rupnp/cp/remote_device.rb', line 108 def initialize(control_point, notification) super() @control_point = control_point @notification = notification @icons = [] @services = [] @devices = [] end |
Instance Attribute Details
#boot_id ⇒ Integer (readonly)
BOOTID.UPNP.ORG field value
45 46 47 |
# File 'lib/rupnp/cp/remote_device.rb', line 45 def boot_id @boot_id end |
#cache_control ⇒ String (readonly)
Contains max-age
directive used to specify advertisement validity
39 40 41 |
# File 'lib/rupnp/cp/remote_device.rb', line 39 def cache_control @cache_control end |
#config_id ⇒ nil, Integer (readonly)
CONFIGID.UPNP.ORG field value
48 49 50 |
# File 'lib/rupnp/cp/remote_device.rb', line 48 def config_id @config_id end |
#control_point ⇒ ControlPoint (readonly)
Get control point which controls this device
18 19 20 |
# File 'lib/rupnp/cp/remote_device.rb', line 18 def control_point @control_point end |
#date ⇒ String (readonly)
Date when response was generated
36 37 38 |
# File 'lib/rupnp/cp/remote_device.rb', line 36 def date @date end |
#devices ⇒ Array<Device> (readonly)
List of embedded devices
103 104 105 |
# File 'lib/rupnp/cp/remote_device.rb', line 103 def devices @devices end |
#expiration ⇒ Time (readonly)
Expiration time for the advertisement
42 43 44 |
# File 'lib/rupnp/cp/remote_device.rb', line 42 def expiration @expiration end |
#ext ⇒ String (readonly)
33 34 35 |
# File 'lib/rupnp/cp/remote_device.rb', line 33 def ext @ext end |
#friendly_name ⇒ String (readonly)
Short description for end users
64 65 66 |
# File 'lib/rupnp/cp/remote_device.rb', line 64 def friendly_name @friendly_name end |
#icons ⇒ Array<OpenStruct> (readonly)
Array of icons to depict device in control point UI
97 98 99 |
# File 'lib/rupnp/cp/remote_device.rb', line 97 def icons @icons end |
#location ⇒ String (readonly)
URL to the UPnP description of the root device
31 32 33 |
# File 'lib/rupnp/cp/remote_device.rb', line 31 def location @location end |
#manufacturer ⇒ String (readonly)
Manufacturer’s name
67 68 69 |
# File 'lib/rupnp/cp/remote_device.rb', line 67 def manufacturer @manufacturer end |
#manufacturer_url ⇒ String (readonly)
Web site for manufacturer
70 71 72 |
# File 'lib/rupnp/cp/remote_device.rb', line 70 def manufacturer_url @manufacturer_url end |
#model_description ⇒ String (readonly)
Long decription for end user
73 74 75 |
# File 'lib/rupnp/cp/remote_device.rb', line 73 def model_description @model_description end |
#model_name ⇒ String (readonly)
Model name
76 77 78 |
# File 'lib/rupnp/cp/remote_device.rb', line 76 def model_name @model_name end |
#model_number ⇒ String (readonly)
Model number
79 80 81 |
# File 'lib/rupnp/cp/remote_device.rb', line 79 def model_number @model_number end |
#model_url ⇒ String (readonly)
Web site for model
82 83 84 |
# File 'lib/rupnp/cp/remote_device.rb', line 82 def model_url @model_url end |
#presentation_url ⇒ String (readonly)
URL to presentation for device
94 95 96 |
# File 'lib/rupnp/cp/remote_device.rb', line 94 def presentation_url @presentation_url end |
#serial_umber ⇒ String (readonly)
Serial number
85 86 87 |
# File 'lib/rupnp/cp/remote_device.rb', line 85 def serial_umber @serial_umber end |
#server ⇒ String (readonly)
Get SERVER string
28 29 30 |
# File 'lib/rupnp/cp/remote_device.rb', line 28 def server @server end |
#services ⇒ Array<Service> (readonly)
List of device’s services
100 101 102 |
# File 'lib/rupnp/cp/remote_device.rb', line 100 def services @services end |
#st ⇒ String (readonly)
Get search target.
22 23 24 |
# File 'lib/rupnp/cp/remote_device.rb', line 22 def st @st end |
#type ⇒ String (readonly)
Device type
61 62 63 |
# File 'lib/rupnp/cp/remote_device.rb', line 61 def type @type end |
#udn ⇒ String (readonly)
Unique Device Name
88 89 90 |
# File 'lib/rupnp/cp/remote_device.rb', line 88 def udn @udn end |
#upc ⇒ String (readonly)
Universal Product Code
91 92 93 |
# File 'lib/rupnp/cp/remote_device.rb', line 91 def upc @upc end |
#upnp_version ⇒ String (readonly)
UPnP version used by the device
52 53 54 |
# File 'lib/rupnp/cp/remote_device.rb', line 52 def upnp_version @upnp_version end |
#url_base ⇒ String (readonly)
URL base for device access
58 59 60 |
# File 'lib/rupnp/cp/remote_device.rb', line 58 def url_base @url_base end |
#usn ⇒ String (readonly)
Get Unique Service Name
25 26 27 |
# File 'lib/rupnp/cp/remote_device.rb', line 25 def usn @usn end |
#xmlns ⇒ String (readonly)
XML namespace for device description
55 56 57 |
# File 'lib/rupnp/cp/remote_device.rb', line 55 def xmlns @xmlns end |
Instance Method Details
#fetch ⇒ void
This method returns an undefined value.
Get device from its description
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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/rupnp/cp/remote_device.rb', line 120 def fetch upnp_minor_ver = @notification['server'].match(/UPnP\/1\.(\d)/)[1].to_i if @notification['nextbootid.upnp.org'] @boot_id = @notification['nextbootid.upnp.org'].to_i elsif @notification['bootid.upnp.org'] @boot_id = @notification['bootid.upnp.org'].to_i elsif upnp_minor_ver > 0 fail self, 'no BOOTID.UPNP.ORG field. Message discarded.' return end @config_id = @notification['configid.upnp.org'] @config_id = @config_id.to_i if @config_id description_getter = EM::DefaultDeferrable.new description_getter.errback do msg = "Failed getting description" log :error, "Fetching device: #{msg}" fail self, msg next end extract_from_ssdp_notification description_getter description_getter.callback do |description| @description = description if bad_description? fail self, "Bad description returned: #@description" next else 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 end |
#update(notification) ⇒ void
This method returns an undefined value.
Update a device from a ssdp:update notification
169 170 171 172 173 174 175 |
# File 'lib/rupnp/cp/remote_device.rb', line 169 def update(notification) update_expiration notification @boot_id = notification['nextbootid.upnp.org'].to_i if notification['configid.upnp.org'] @config_id = notification['configid.upnp.org'].to_i end end |