diff --git a/bin/upnp-discover b/bin/upnp-discover index 27a9c73..134575f 100755 --- a/bin/upnp-discover +++ b/bin/upnp-discover @@ -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"; } diff --git a/src/SSDP/Device.php b/src/SSDP/Device.php index db22b8a..92e70c2 100644 --- a/src/SSDP/Device.php +++ b/src/SSDP/Device.php @@ -133,6 +133,11 @@ class Device implements JsonSerializable return $this->modelDescription; } + /** + * Get the device description URL + * + * @return string + */ public function getUrl() { return $this->specUrl; diff --git a/src/SSDP/Discovery.php b/src/SSDP/Discovery.php index 9061095..83218b0 100644 --- a/src/SSDP/Discovery.php +++ b/src/SSDP/Discovery.php @@ -72,7 +72,7 @@ class Discovery implements IteratorAggregate, JsonSerializable public function jsonSerialize() { - return $this->devices; + return array_values($this->devices); } } diff --git a/src/SSDP/Service.php b/src/SSDP/Service.php index 5dc5297..7091e4b 100644 --- a/src/SSDP/Service.php +++ b/src/SSDP/Service.php @@ -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;