Permalink
Browse files

Merge pull request #276 from tarasfrompir/master

Update Core.php
  • Loading branch information...
T-REX-XP committed Sep 12, 2018
2 parents 35b6627 + c935616 commit 4ec77a010658f8e053a731b4db1dc77080dbcec8
@@ -96,11 +96,13 @@ function Scan(){
$dev = (array)json_decode($json, true);
$device= $dev['device'];
}
// need for chek device type
$device_type = explode(":", $device["deviceType"])[3];//DeviceType
// получаем логотип на устройство
$logo= getDefImg($control_url,$device);
// проверяем на наличие в базе для запрета вывода
$uuid = $device["UDN"];
$existed = SQLSelectOne("SELECT * FROM $table_name WHERE UUID='".$uuid."'");
$existed = SQLSelectOne("SELECT * FROM $table_name WHERE UUID='".$uuid."' AND TYPE='".$device_type."'");
// иногда вместо serialNumber есть modelNumber
$serialnumber = $device["serialNumber"];
if (!$serialnumber){
@@ -116,14 +118,7 @@ function Scan(){
if (!$device["modelDescription"]){
$descript = $deviceInfo["server"];
}
// need for chek device type
$device_type = explode(":", $device["deviceType"])[3];//DeviceType
// если устройство имеет modelName Eureka Dongl тогда это Chromecast устройство
if (!$device["modelName"]=="Eureka Dongle"){
$device_type='Chromecast';
};
// проверяем на наличие модуля в системе
$mod_cheked = SQLSelectOne("SELECT * FROM plugins WHERE MODULE_NAME LIKE '".$modules[$device_type]."'");
if (!array_search_result($result, 'UUID', $uuid) && !is_null($uuid) && !($existed)) {
@@ -15,14 +15,14 @@ public function __construct()
public function search($st = 'ssdp:all', $mx = 2, $man = 'ssdp:discover', $from = null, $port = null, $sockTimout = '2')
{
//milight, MagicHome
// поиск устройств milight, MagicHome
$request = 'HF-A11ASSISTHREAD'."\r\n";
$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', 48899);
//yeelight
//поиск устройств yeelight
$request = 'M-SEARCH * HTTP/1.1'."\r\n";
$request .= 'HOST: 239.255.255.250:1982'."\r\n";
$request .= 'MAN: "'.$man.'"'."\r\n";
@@ -43,8 +43,10 @@ public function search($st = 'ssdp:all', $mx = 2, $man = 'ssdp:discover', $from
$request .= "\r\n";
$socket = socket_create(AF_INET, SOCK_DGRAM, 0);
socket_set_option($socket, SOL_SOCKET, SO_BROADCAST, true);
// search device of other net
socket_sendto($socket, $request, strlen($request), 0, '239.255.255.250', 1900);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec'=>$sockTimout, 'usec'=>'50'));
// search device of you PC
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();
Binary file not shown.

0 comments on commit 4ec77a0

Please sign in to comment.