Closed hypexr closed 11 years ago
Ah, I need to fix the docs! I changed services
to service_list
(for some reason)...
Fixed in 240fb465f538082c2aae25ee8a3f8d6c2c51fba1
Also, take a look at https://github.com/turboladen/upnp/blob/master/tasks/search.thor for a working example. The docs will probably get outdated until I tidy them up for the release. Hoping that's sooner than later...
Or for even more craziness, check out https://github.com/turboladen/upnp_cp_on_sinatra, which sits on top of this and should let you make calls to your service via the web interface. It's been a while since I've used that, but it's my sort of acceptance test that this whole ball of wax actually works.
Thanks, I had checked out service_list, but I overlooked that it contained methods and not just data.
I'm trying to execute action calls on a Belkin WeMo.
It finds the device using it uuid and looks like it extracts the needed services and actions in the output:
D, [2013-01-29T21:56:06.727160 #79850] DEBUG -- : UPnP::ControlPoint::Service Defining methods; action list: [{:name=>"SetBinaryState", :argumentList=>{:argument=>{:retval=>nil, :name=>"BinaryState", :relatedStateVariable=>"BinaryState", :direction=>"in"}}}, {:name=>"SetLogLevelOption", :argumentList=>{:argument=>[{:retval=>nil, :name=>"Level", :relatedStateVariable=>"Level", :direction=>"in"}, {:retval=>nil, :name=>"Option", :relatedStateVariable=>"Option", :direction=>"in"}]}}, {:name=>"GetFriendlyName", :argumentList=>{:argument=>{:retval=>nil, :name=>"FriendlyName", :relatedStateVariable=>"FriendlyName", :direction=>"in"}}}, {:name=>"ReSetup", :argumentList=>{:argument=>{:retval=>nil, :name=>"Reset", :relatedStateVariable=>"Reset", :direction=>"in"}}}, {:name=>"SetHomeId", :argumentList=>{:argument=>{:retval=>nil, :name=>"SetHomeId", :relatedStateVariable=>"HomeId", :direction=>"in"}}}, {:name=>"GetHomeId"}, {:name=>"SetDeviceId", :argumentList=>{:argument=>{:retval=>nil, :name=>"SetDeviceId", :relatedStateVariable=>"DeviceId", :direction=>"in"}}}, {:name=>"GetDeviceId"}, {:name=>"GetMacAddr"}, {:name=>"GetSerialNo"}, {:name=>"GetPluginUDN"}, {:name=>"GetSmartDevInfo"}, {:name=>"ShareHWInfo", :argumentList=>{:argument=>[{:retval=>nil, :name=>"Mac", :relatedStateVariable=>"Mac", :direction=>"in"}, {:retval=>nil, :name=>"Serial", :relatedStateVariable=>"Serial", :direction=>"in"}, {:retval=>nil, :name=>"Udn", :relatedStateVariable=>"Udn", :direction=>"in"}, {:retval=>nil, :name=>"RestoreState", :relatedStateVariable=>"RestoreState", :direction=>"in"}, {:retval=>nil, :name=>"HomeId", :relatedStateVariable=>"HomeId", :direction=>"in"}, {:retval=>nil, :name=>"PluginKey", :relatedStateVariable=>"PluginKey", :direction=>"in"}]}}, {:name=>"ChangeFriendlyName", :argumentList=>{:argument=>{:retval=>nil, :name=>"FriendlyName", :relatedStateVariable=>"FriendlyName", :direction=>"in"}}}, {:name=>"SetSmartDevInfo", :argumentList=>{:argument=>{:retval=>nil, :name=>"SmartDevURL", :relatedStateVariable=>"SmartDevURL", :direction=>"in"}}}, {:name=>"GetRuleOverrideStatus", :argumentList=>{:argument=>{:retval=>nil, :name=>"RuleOverrideStatus", :relatedStateVariable=>"RuleOverrideStatus", :direction=>"in"}}}, {:name=>"GetDeviceIcon", :argumentList=>{:argument=>{:retval=>nil, :name=>"DeviceIcon", :relatedStateVariable=>"DeviceIcon", :direction=>"in"}}}, {:name=>"GetIconURL", :argumentList=>{:argument=>{:retval=>nil, :name=>"URL", :relatedStateVariable=>"URL", :direction=>"out"}}}, {:name=>"GetLogFileURL", :argumentList=>{:argument=>{:retval=>nil, :name=>"LOGURL", :relatedStateVariable=>"LOGURL", :direction=>"out"}}}, {:name=>"ChangeDeviceIcon", :argumentList=>{:argument=>[{:retval=>nil, :name=>"PictureSize", :relatedStateVariable=>"PictureSize", :direction=>"in"}, {:retval=>nil, :name=>"PictureHeight", :relatedStateVariable=>"PictureWidth", :direction=>"in"}, {:retval=>nil, :name=>"PictureColorDeep", :relatedStateVariable=>"PictureColorDeep", :direction=>"in"}]}}, {:name=>"GetBinaryState", :argumentList=>{:argument=>{:retval=>nil, :name=>"BinaryState", :relatedStateVariable=>"BinaryState", :direction=>"out"}}}, {:name=>"SetMultiState", :argumentList=>{:argument=>[{:retval=>nil, :name=>"state", :relatedStateVariable=>"StateList", :direction=>"in"}, {:retval=>nil, :name=>"state", :relatedStateVariable=>"StateList", :direction=>"in"}, {:retval=>nil, :name=>"state", :relatedStateVariable=>"StateList", :direction=>"in"}]}}] D, [2013-01-29T21:56:06.727292 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: SetBinaryState D, [2013-01-29T21:56:06.727342 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: SetLogLevelOption D, [2013-01-29T21:56:06.727384 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetFriendlyName D, [2013-01-29T21:56:06.727422 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: ReSetup D, [2013-01-29T21:56:06.727457 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: SetHomeId D, [2013-01-29T21:56:06.727495 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetHomeId D, [2013-01-29T21:56:06.727533 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: SetDeviceId D, [2013-01-29T21:56:06.727569 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetDeviceId D, [2013-01-29T21:56:06.727604 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetMacAddr D, [2013-01-29T21:56:06.727638 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetSerialNo D, [2013-01-29T21:56:06.727677 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetPluginUDN D, [2013-01-29T21:56:06.727712 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetSmartDevInfo D, [2013-01-29T21:56:06.727747 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: ShareHWInfo D, [2013-01-29T21:56:06.727782 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: ChangeFriendlyName D, [2013-01-29T21:56:06.727821 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: SetSmartDevInfo D, [2013-01-29T21:56:06.727855 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetRuleOverrideStatus D, [2013-01-29T21:56:06.727891 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetDeviceIcon D, [2013-01-29T21:56:06.727928 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetIconURL D, [2013-01-29T21:56:06.727963 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetLogFileURL D, [2013-01-29T21:56:06.727998 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: ChangeDeviceIcon D, [2013-01-29T21:56:06.728033 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: GetBinaryState D, [2013-01-29T21:56:06.728070 #79850] DEBUG -- : UPnP::ControlPoint::Service Defined method: SetMultiState
but when I try to access device.services as shown in the documentation I get:
light.rb:21:in
block (2 levels) in <main>': undefined method
services' for #UPnP::ControlPoint::Device:0x007fcd44f6c728 (NoMethodError)The code is basically:
EM.run do searcher = UPnP::SSDP.search 'uuid:Socket-1_0-221248K010243A' device_controller = EventMachine::DefaultDeferrable.new device_controller.callback do |device| pp device.services ...