Howto:DECT Graphical Real Time Display

From innovaphone wiki
Jump to navigation Jump to search
3rd party input
this is 3rd party content not provided by innovaphone, see history for authors.

Applies To

This information applies to

  • IP1200

Build 70300.35 and earlier.


In multicell network, it's useful to have a map of all the cells in a single view with all the sync link state in real time display.


System Requirements

For that you will need an apache server with PHP 5 at least.

You will have to activate the following extensions :

php_http, php_gd2

You must have an access to the cells from the apache server.

You must have a map of your building in jpg format with the name myDECTcoverage.jpg, and you will need a txt file with a description of each cells point with the name myDECTcoverage.txt.


PHP scripts

You will need four php script to get this map. Put these following scripts in the same directory.

The first one, named index.php, is to be called by the browser with the site ID in http GET format, for example : http://mysite/index.php?site=myDECTcoverage content="5" for the refresh time <?php echo '<HTML><HEAD>'; echo '<META HTTP-EQUIV="refresh" content="5"; url="index.php">'; echo '</HEAD><BODY>'; echo "<img src='draw.php?site=".$_GET['site']."'/>"; echo '</BODY></html>'; ?>

The second one, named draw.php, provides the jpg with the map and each cells point drawn on and the link state.


include 'getsync.php'; include 'getlevel.php'; header("Content-type: image/jpg");

function drawBorne($img,$nom,$x,$y) { // Choix de la couleur de l'ellipse $col_ellipse = imagecolorallocate($img, 30, 30, 255); // On dessine l'ellipse imagefilledellipse($img, $x, $y, 20, 20, $col_ellipse); imagestring($img,3,($x+8),($y+8),$nom,$col_ellipse); }

function drawRepeater($img,$nom,$x,$y) { // Choix de la couleur de l'ellipse $col_ellipse = imagecolorallocate($img, 200, 0, 0); // On dessine l'ellipse imagefilledellipse($img, $x, $y, 15, 15, $col_ellipse); imagestring($img,3,($x+6),($y+6),$nom,$col_ellipse); }

function drawFlecheRepeater($img,$x1,$y1,$x2,$y2,$col) { // Choix de la couleur de la fleche //$col_fleche = imagecolorallocate($img, 0, 0, 0); imagesetthickness($img, 2); imageline($img, $x1, $y1, $x2, $y2, $col); }

function drawFlechePrimBorne($img,$x1,$y1,$x2,$y2,$col) { // Choix de la couleur de la fleche //$col_fleche = imagecolorallocate($img, 0, 255, 0); imagesetthickness($img, 3); imageline($img, $x1, $y1, $x2, $y2, $col); }

function drawFlecheAltBorne($img,$x1,$y1,$x2,$y2,$col) { // Choix de la couleur de la fleche //$col_fleche = imagecolorallocate($img, 255, 0, 0); imagesetthickness($img, 4); $style = Array(


imagesetstyle($img, $style); imageline($img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED); }

// pour définir les différentes couleurs d'alarme sur les synchro function definecolor($level,$img,$f) { if ($level=="") $col = imagecolorallocate($img, 0, 0, 0); else { if (($level)<=27) $col = imagecolorallocate($img, 255, 0, 0); if (($level>27)And($level<=30)) $col = imagecolorallocate($img, 255, 153, 51); if (($level>30)And($level<35)) $col = imagecolorallocate($img, 200, 255, 50); if (($level)>=35) $col = imagecolorallocate($img, 0, 153, 0); } //$f=fopen ('debug.txt','a+'); fwrite ($f,'Level'.$level."\r\n"); //fclose ($f); return ($col); }

//création de l'image $im=imagecreatefromjpeg($_GET['site'].".jpg"); $cartouche=imagecreatefromjpeg("cartouche.jpg"); imagecopymerge($im,$cartouche,0,0,0,0,300,100,100); //initialisation du tableau qui recevra la lecture du fichier de conf 00000_000.txt $valeur=array(); // lecture des ID présent et des positions $filename=$_GET['site'].".txt"; $file=fopen($filename,'r');

while (!feof($file)) { list($nom,$x,$y,$id,$ip,$port,)= explode(";",fgets($file, 8192)); $valeur[$id]=array($nom,$x,$y,$id,$ip,$port); } fclose ($file);

// pour debug $f=fopen ('debug.txt','w+');

// on récupères les levels de toutes les bornes dans un tableau de tableau $level=array(); foreach ($valeur as $val) { if ($val[4]!="") $level=getlevel($level,$val[3],$val[4],$val[5]); if ($val[3]==1) $sync=getsync(strval($val[4]),intval($val[5])); } unset($val);

//Pour toute les valeurs du fichier de conf : on récupère et trace les synchro borne et répéteur foreach ($valeur as $val) { if ($val[4]=="") { if ($val[3]>8) $borne=$val[3]-(64*(int)($val[3]/64)); else $borne=1; foreach ($level as $testlevel) { $levelprim=""; if ($testlevel[0]==$borne && $testlevel[1]==$val[3]) { $levelprim=$testlevel[2]; break 1; } } unset ($testlevel); drawFlecheRepeater($im,$val[1],$val[2],$valeur[strval($borne)][1],$valeur[strval($borne)][2],definecolor($levelprim,$im,$f)); } else { foreach ($sync as $b) { if ($val[3]==$b[0]) { foreach ($level as $testlevel) { $levelprim=""; if ($testlevel[0]==$val[3] And $testlevel[1]==$b[1]) { $levelprim=$testlevel[2]; break 1; } } unset ($testlevel); foreach ($level as $testlevel) { $levelalt=""; if ($testlevel[0]==$val[3] And $testlevel[1]==$b[2]) { $levelalt=$testlevel[2]; break 1; } } fwrite ($f,"B=".$b[0]." pri=".$b[1]." alt=".$b[2]." levelprim=".$levelprim." levelalt=".$levelalt."\r\n"); if ($b[1]<>$b[2]) { drawFlechePrimBorne($im,$valeur[$b[0]][1],$valeur[$b[0]][2],$valeur[$b[1]][1],$valeur[$b[1]][2],definecolor($levelprim,$im,$f)); drawFlecheAltBorne($im,$valeur[$b[0]][1],$valeur[$b[0]][2],$valeur[$b[2]][1],$valeur[$b[2]][2],definecolor($levelalt,$im,$f)); } else { if ((abs(intval($valeur[$b[1]][1])-intval($valeur[$b[0]][1])))<(abs((intval($valeur[$b[1]][2]))-intval($valeur[$b[0]][2])))) { drawFlechePrimBorne($im,$valeur[$b[0]][1]+2,$valeur[$b[0]][2],$valeur[$b[1]][1]+2,$valeur[$b[1]][2],definecolor($levelprim,$im,$f)); drawFlecheAltBorne($im,$valeur[$b[0]][1]-2,$valeur[$b[0]][2],$valeur[$b[2]][1]-2,$valeur[$b[2]][2],definecolor($levelalt,$im,$f)); } else { drawFlechePrimBorne($im,$valeur[$b[0]][1],$valeur[$b[0]][2]+2,$valeur[$b[1]][1],$valeur[$b[1]][2]+2,definecolor($levelprim,$im,$f)); drawFlecheAltBorne($im,$valeur[$b[0]][1],$valeur[$b[0]][2]-2,$valeur[$b[2]][1],$valeur[$b[2]][2]-2,definecolor($levelalt,$im,$f)); } } } } } } unset ($val);

//fclose ($f); foreach ($valeur as $val) { if ($val[0][0]=="B"||$val[0][0]=="b") drawBorne($im,$val[0],$val[1],$val[2]); if ($val[0][0]=="R"||$val[0][0]=="r") drawRepeater($im,$val[0],$val[1],$val[2]); } imagejpeg($im); imagedestroy($im); imagedestroy ($cartouche); ?>

You will also need the two following scripts, one to get get the sync map and one to get the sync level between each cells.

getsync.php <?php //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // la fonction getsync permet de récupérer le chemin de synchro entre les bornes // les paramètres passés sont l'adresse ip de la borne master IP (B1) // et le port pour se connecter en http et récupérer les infos sur la B1 Master IP // cette fonction retourne un tableau orgénisé de la façon suivante // (id(id,primaire, secondaire, synchro sur, perte totale desynchro),id(...)) //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ function getsync($ip,$port) { $user="myuser"; $password="mypass"; $authHeader = ('Basic ' . base64_encode($user . ':' . $password)); $r = new HttpRequest('http://'.$ip.'/GW-DECT/MASTER/mod_cmd.xml?cmd=xml-radios&xsl=dectmaster_radios.xsl', HttpRequest::METH_GET); $r->addHeaders(array('Authorization' => $authHeader)); $r->setOptions(array('port'=>$port)); try { $r->send(); if ($r->getResponseCode()=="200") $xmlreply=$r->getResponseBody(); else echo "NOK"; } catch (HttpException $ex) {} unset ($r); $xml = new SimpleXMLElement($xmlreply); $retour=array(); foreach ($xml->radio as $radio) { //if (isset($radio->sync)) { $id=strval($radio['id']); $prim=strval($radio->sync['prim']); $alt=strval($radio->sync['alt']); $state=strval($radio->sync['state']); $lostcount=strval($radio->sync['lost-count']); if ($prim<>"") $retour[$id]=array($id,$prim,$alt,$state,$lostcount); unset ($id); unset ($prim); unset ($alt); unset ($state); unset ($lostcount); } } return ($retour); } ?>

getlevel.php <?php function getlevel($tab,$id,$ip,$port) { $user="myuser"; $password="mypass"; $authHeader = ('Basic ' . base64_encode($user . ':' . $password)); $r = new HttpRequest('http://'.$ip.'/DECT/mod_cmd.xml?cmd=xml-other-bases', HttpRequest::METH_GET); $r->addHeaders(array('Authorization' => $authHeader)); $r->setOptions(array('port'=>$port)); try { $r->send(); if ($r->getResponseCode()=="200") { $xmlreply=$r->getResponseBody(); $xmlreply=str_replace("r-b","rb",$xmlreply); } else echo "NOK"; } catch (HttpException $ex) {} unset ($r); if ($xmlreply=="<dect error=\"Dect system is not ready.\"/>") return ($tab); else { $xml = new SimpleXMLElement($xmlreply); foreach ($xml->otherbases->base as $base) { $rpn=intval($base['rpn']); $rssi=intval($base['rssi']); $tab[]=(array($id,$rpn,$rssi)); } return ($tab); } } ?>

Don't forget to change the user/password in these two scripts.

Additional files

For the caption on the map you will need the files cartouche.jpg Exemple.jpg

As mention at the beginning you will need two files, one for the map and one for cells positionning on the map.

So here is an example of the text file myDECTcoverage.txt.

B1 Master IP;111;222;1;;80;



Each line represents one radio point. For Base Stations, the line begins with Bxxx For Repeater, the line begins with Rxxx. You can add information after the R or B, it will be drawn to the map.

Each field is separated by ';', the first field is the name, second is the X position on the jpg (in pixel), the third is the Y position, then you will find the real ID of the access point, then the IP address, and at the end the http port.

Note that for repeater IP address and port have no sense ! leave it empty. You must have one ';' at the end of each line.

You must specify the http port because I use NAT feature of the PBX on my network and cells are only reachable through the IPBX.

Known Problems

  • It's important to respect the repeater ID as described in the documentation. For example repeater 1 on B1 must have ID 65.
  • If you have repeater attached to another repeater, it will be drawn as attach to the same cell.
  • The master IP address must have the ID 1.
  • It works in single cell solution.
  • You must have basic authentication on DECT Cells.

Related Articles