Permalink
Browse files

Merge pull request #206 from tarasfrompir/master

Мелкие исправления по выводу данных об устройстве
  • Loading branch information...
T-REX-XP committed Jul 11, 2018
2 parents 369c7cc + da3ba4f commit f215875e802a5932281d690cde44bf6e546fe63b
@@ -6,7 +6,6 @@
require('upnp/vendor/autoload.php');
use jalder\Upnp\Upnp;
global $session;
if ($this->owner->name == 'panel') {
$out['CONTROLPANEL'] = 1;
@@ -38,28 +37,39 @@
function Scan(){
$upnp = new Upnp();
#print('searching...' . PHP_EOL);
$everything = $upnp->discover();
$result = [];
$table_name='ssdp_devices';
foreach ($everything as $deviceInfo) {
$device= $deviceInfo['description']['device'];
// print_r($device);
$uuid = $device["UDN"];
$existed = SQLSelectOne("SELECT * FROM $table_name WHERE UUID='".$uuid."'");
$control_url = $deviceInfo['location'];
// for microsoft devices - не доведено
if (substr($deviceInfo['location'], 0, 9) == "Location:") {
$control_url = str_ireplace("Location:", "", $deviceInfo['location']);
$deviceout = file_get_contents($control_url);
Debmes ($deviceout);
}
// .. to do end
// иногда вместо serialNumber есть modelNumber
$serialnumber = $device["serialNumber"];
if (!$serialnumber){
$serialnumber = $device["modelNumber"];
}
// иногда presentationURL отсутствует
$presenturl = $device["presentationURL"];
//todo: fix impl
$control_url = str_ireplace("Location:", "", $deviceInfo['location']);
if (!$device["presentationURL"]){
$presenturl='http://'.getIp($control_url,false);
}
//end todo
if (!array_search_result($result, 'UUID', $uuid) && !is_null($uuid) && !($existed)) {
// print($device["iconList"]);
$logo= getDefImg($deviceInfo["location"],$device);
// print($device["iconList"]);
$logo= getDefImg($deviceInfo["location"],$device);
$result[] = [
"ID" => $existed["ID"], //existed id Majordomo
"TITLE" => $device["friendlyName"],//friendly name
@@ -68,7 +78,7 @@ function Scan(){
"LOGO" => $logo,//Logo
"DESCRIPTION" => $device["modelDescription"] ,//. $deviceInfo['server'],//description get from xml or field "server"
"TYPE" => explode(":", $device["deviceType"])[3],//DeviceType
"SERIAL" => $device["serialNumber"],//serialnumber
"SERIAL" => $serialnumber, //serialnumber
"MANUFACTURERURL" => $device["manufacturerURL"],//manufacturer url
"UPDATED" => '',
"MODEL" => $device["modelName"],//model
@@ -25,7 +25,7 @@ public function search($st = 'ssdp:all', $mx = 2, $man = 'ssdp:discover', $from
$socket = socket_create(AF_INET, SOCK_DGRAM, 0);
socket_set_option($socket, SOL_SOCKET, SO_BROADCAST, true);
socket_sendto($socket, $request, strlen($request), 0, '239.255.255.250', 1900);
socket_sendto($socket, $request, strlen($request), 0, '255.255.255.255', 1900);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec'=>$sockTimout, 'usec'=>'50'));
$response = array();
do {

0 comments on commit f215875

Please sign in to comment.