Beispiel #1
0
include '_includes/eib-functions.php';
System_Daemon::info("######    KNX sniffer -> make and update knxtrace.json   #####");
/* 
Requette permettant de lister les equipement d'etzt et non d'action
*/
$req_sel_eq = "SELECT group_addr,name,dpt,id,is_track FROM knx_equipement where knx_type_equipement_id=2";
//System_Daemon::info("Requete SQL -> ".$req_sel_eq);
//$knx_eq     = mysql_query($req_sel_eq) or die (mysql_error());
$knx_eq = $db->query($req_sel_eq) or die($mysqli->error);
$sniffed = array();
$oldSniffedValue = array();
/*
Mise en forme des donnees dans un tableau pour les manipuler facilement
*/
while ($data = $knx_eq->fetch_array()) {
    $sniffed[$data['group_addr']] = array("id" => $data['id'], "name" => $data['name'], "dpt" => $data['dpt'], "value" => "", "unite" => getDptUnite($data['dpt']), "is_track" => $data['is_track']);
}
/*
Initialisation du fichier knxtrace.json
*/
System_Daemon::info("Init :: Recuperation des valeurs dans les groupes d'ecoute");
foreach ($sniffed as $grpaddr => $value) {
    $cmd = 'eibread -s 127.0.0.1 ' . $grpaddr;
    // System_Daemon::info($cmd);
    $hexa = exec($cmd);
    $dec = hexdec($hexa);
    $sniffed[$grpaddr]['value'] = dptSelectDecode($sniffed[$grpaddr]['dpt'], $dec);
    $oldSniffedValue[$grpaddr] = $sniffed[$grpaddr]['value'];
    if ($sniffed[$grpaddr]['is_track'] == 1) {
        //Inseetion en base de données car l'eqt is_track=true
        //System_Daemon::notice("SAVE");
Beispiel #2
0
echo "<br>";
print_r($now);
echo "<br>";
/* 
test si equipement déja connu doit etre suivi
*/
$req_sel_eq = "SELECT group_addr,name,dpt FROM knx_equipement where knx_type_equipement_id=2";
//System_Daemon::info("Requete SQL -> ".$req_sel_eq);
$knx_eq = mysql_query($req_sel_eq) or die(mysql_error());
$sniffed = array();
/*
Mise en forme des données dans un tableau pour les manipuler facilement
*/
//System_Daemon::notice("A");
while ($data = mysql_fetch_array($knx_eq)) {
    $sniffed[$data['group_addr']] = array("name" => $data['name'], "dpt" => $data['dpt'], "value" => "", "unite" => getDptUnite($data['dpt']));
}
var_dump($sniffed);
var_dump(json_encode($sniffed, JSON_UNESCAPED_SLASHES));
var_dump(decodeState('9.017', 1447));
echo ":::::::<br>";
echo "<br>";
/* DPT 1 */
echo 'DPT  1.xxx - OK -';
//$data = 0x0; //-> bin : 0 -> Off
$data = 0x80;
//-> bin 1 -> on
echo ' Decode : ' . $data . " - binaire : " . decbin($data) . " - ";
$res = $data;
var_dump($res);
echo dptSelectDecode('1.000', $data);