Das sind die GerÀte:
ID â Name â Address â Serial Number â Type â Type String â Firmware â Config Pending â Unreach â Low Bat
23 â FEFK â 3C71DB â MEQ0716440 â 00C7 â HM-Sec-SCo â 1.0 â Yes â No â No
271 â FESHK â 4CF042 â NEQ0875801 â 0095 â HM-CC-RT-DN â 1.4 â No â No â No
272 â FEWT â 4DE926 â NEQ0939649 â 00AD â HM-TC-IT-WM-W-EU â 1.3 â Yes â No â No
273 â FESFK â 5D05B9 â OEQ1433713 â 00C7 â HM-Sec-SCo â 1.0 â No â No â No
274 â FEWHK â 4CE90A â NEQ0873954 â 0095 â HM-CC-RT-DN â 1.4 â No â No â No
Das ist der relevante Teil des Skripts.
function relink($hg,$names,$p1,$c1,$p2,$c2)
{
try
{
$hg->removeLink($p1,$c1,$p2,$c2);
}
catch(Exception $e)
{
echo $names[$p1] . "/" . $names[$p2] . ": " . $e;
}
$name = $names[$p1] . ":" . $c1 . " -> " . $names[$p2] . ":" . $c2;
$desc = substr($names[$p1],0,2) . ": " . substr($names[$p1],-2) . " an " . substr($names[$p2],-2) . ".";
$hg->addLink($p1,$c1,$p2,$c2,$name,$desc);
sleep(3);
}
function linkWTHK($hg,$names,$wt,$hk)
{
relink($hg, $names, $wt, 2, $hk, 2);
relink($hg, $names, $wt, 1, $hk, 1);
}
function linkFKWT($hg,$names,$fk,$wt)
{
relink($hg, $names, $fk, 1, $wt, 3);
}
function linkFKHK($hg,$names,$fk,$hk)
{
relink($hg, $names, $fk, 1, $hk, 3);
}
function linkFK($hg, $names, $peers, $fkn, $xxn)
{
$fk = $peers[ $fkn ];
$xx = $peers[ $xxn ];
linkFKWT($hg, $names, $fk, $xx);
}
function linkH($hg, $names, $peers, $fkn, $wtn, $hkn)
{
$fk = $peers[ $fkn ];
$wt = $peers[ $wtn ];
$hk = $peers[ $hkn ];
linkFKWT($hg, $names, $fk, $wt);
linkFKHK($hg, $names, $fk, $hk);
linkWTHK($hg, $names, $wt, $hk);
}
function linkHK($hg, $names, $peers, $fkn, $hkn)
{
$fk = $peers[ $fkn ];
$hk = $peers[ $hkn ];
linkFKHK($hg, $names, $fk, $hk);
}
linkH($hg,$names,$peers,"FEFK","FEWT","FESHK");
linkH($hg,$names,$peers,"FEFK","FEWT","FEWHK");
linkFK($hg,$names,$peers,"FESFK","FEWT");
linkFK($hg,$names,$peers,"FESFK","FEWHK");
linkFK($hg,$names,$peers,"FESFK","FESHK");
$names & $peers sind einfach arrays in der Form:
$names = [<id> => "<name>", ...];
$peers = ["<name>" => <id>, ...];