Trouble with - def device = devices.find { it?.key?.contains(body?.device?.UDN?.text()) }


(Mark Bateman) #1

Hello,

Wonder if someone can help me, trying to get a raspberry pi to discover with the generic UPNP example, I have the Pi running an ssdp server and it is responding to the hub and providing the location of the description.xml file problem is the body of the xml file seems to be reformatted by the hub so the UDN key text is missing.

So log.debug in the function below…

void deviceDescriptionHandler(physicalgraph.device.HubResponse hubResponse) {
	def body = hubResponse.xml
        log.debug "${body}"
	def devices = getDevices()
	def device = devices.find { it?.key?.contains(body?.device?.UDN?.text()) }
	if (device) {
		device.value << [name: body?.device?.roomName?.text(), model:body?.device?.modelName?.text(), serialNumber:body?.device?.serialNum?.text(), verified: true]
	}
}

Returns this debug…

10urn:schemas-upnp-org:device:RasPiMB:1RasPi MBmarkabRasPiMBuuid:b8:27:eb:7d:58:42

This is the xml file I am serving, but you can see there is no key for UDN in the above body!!

<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:dlna="urn:schemas-dlna-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:RasPiMB:1</deviceType>
<friendlyName>RasPi MB</friendlyName>
<manufacturer>markab</manufacturer>
<modelName>RasPiMB</modelName>
<UDN>uuid:b8:27:eb:7d:58:42</UDN>
</device>
</root>

(Mark Bateman) #2

Never mind found it, my node ssdp implementation wasn’t returning the UDN with uuid: at the beginning like the description.xml file

Server = require('node-ssdp').Server
    , server = new Server({location: 'http://' + require('ip').address() + ':3000/upnp/description.xml', udn: 'uuid:b827eb7d5842'})
;

    server.addUSN('urn:schemas-upnp-org:device:RasPiMB:1');

    server.on('advertise-alive', function (headers) {
          // Expire old devices from your cache.
          // Register advertising device somewhere (as designated in http headers heads)
    });

    server.on('advertise-bye', function (headers) {
          // Remove specified device from cache.
    });

    // start the server
    server.start();

    process.on('exit', function(){
          server.stop() // advertise shutting down and stop listening
    })

(Marc Lennox) #3

Hi there, I’m using the same node-ssdp server library to try and create a service manager, but unlike you, I don’t see any evidence that it is responding to the hub. Can you post the working service manager code that you used. I started from the example code and only changed the USN but still no luck.

Thanks.