This commit is contained in:
Chris 2017-03-31 16:45:52 +02:00
parent 01f6f960dc
commit 116233d81a
4 changed files with 14 additions and 4 deletions

View File

@ -245,7 +245,7 @@ function show_device_long(Device $device, $level=0) {
);
printf("{$indent} \e[32m%s\e[0m\n", $device->getUrl());
foreach ($device->getServices() as $service) {
printf("{$indent} + \e[36m%s\e[0m\n{$indent} \e[32m%s\e[0m\n", $service->getServiceType(), $service->getServiceUrl());
printf("{$indent} + \e[36m%s\e[0m\n{$indent} \e[32m%s\e[0m\n", $service->getServiceType(), $service->getUrl());
}
foreach ($device->getDevices() as $subdevice) {
show_device_long($subdevice, $level+1);
@ -253,5 +253,5 @@ function show_device_long(Device $device, $level=0) {
}
function show_results_json(Discovery $discovery) {
echo json_encode($discovery, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)."\n";
echo json_encode($discovery->jsonSerialize())."\n";
}

View File

@ -133,6 +133,11 @@ class Device implements JsonSerializable
return $this->modelDescription;
}
/**
* Get the device description URL
*
* @return string
*/
public function getUrl()
{
return $this->specUrl;

View File

@ -72,7 +72,7 @@ class Discovery implements IteratorAggregate, JsonSerializable
public function jsonSerialize()
{
return $this->devices;
return array_values($this->devices);
}
}

View File

@ -54,7 +54,12 @@ class Service implements JsonSerializable
return $this->scpdUrl;
}
public function getServiceUrl()
/**
* Get the service description URL
*
* @return string
*/
public function getUrl()
{
if (strpos($this->scpdUrl,"://")!==false) {
return $this->scpdUrl;