function Scan() { $upnp = new Upnp(); print 'searching...' . PHP_EOL; $everything = $upnp->discover(); $result = []; foreach ($everything as $device) { //print_r($device); //uncomment to see all available array elements for a device. $info = $device['description']['device']; // print array_search(, array_column( $result, 'ADDRESS')); if (!array_search_result($result, 'UUID', $info["UDN"])) { $result[] = ["ID" => $info["UDN"], "TITLE" => $info["friendlyName"], "ADDRESS" => $info["presentationURL"], "UUID" => $info["UDN"], "DESCRIPTION" => is_array($info["modelDescription"]) ? implode(',', $info["modelDescription"]) : $info["modelDescription"], "TYPE" => explode(":", $info["deviceType"])[3], "LOGO" => getDefImg($info), "SERIAL" => $info["serialNumber"], "MANUFACTURERURL" => $info["manufacturerURL"], "UPDATED" => '', "MODEL" => $info["modelName"], "MANUFACTURER" => $info["manufacturer"], "IP" => getIp($info)]; } } /* print("<pre>"); print_r($result); print("</pre>"); */ return $result; }
public function testUpnp() { $upnp = new Upnp(); $this->assertTrue($upnp->alive()); }
<?php require 'vendor/autoload.php'; use jalder\Upnp\Upnp; $upnp = new Upnp(); print 'searching...' . PHP_EOL; $everything = $upnp->discover(); if (!count($everything)) { print_r('no upnp devices found' . PHP_EOL); } foreach ($everything as $device) { //print_r($device); //uncomment to see all available array elements for a device. $info = $device['description']['device']; $summary = $info['friendlyName'] . ', ' . $info['modelName'] . ', ' . $info['UDN']; print $summary . PHP_EOL; }