PHP RSSI 距离计算

    本文地址:http://tongxinmao.com/Article/Detail/id/476

    <?php


    function doit_rssi($txPower,$rssi)

    {

    $refDistance = 1.0;

    $pathLoss = 3.2;


    $c1=$txPower;

    $c2=$pathLoss;


    $fm=($c1-$rssi)/(10*$c2);

    echo "fm".$fm."\r\n";

    $fp=pow(10,$fm);


    $ret=$refDistance*$fp/100;



    return $ret;

    }





    function doit_to_rssi($txPower,$distance)

    {

    $refDistance = 1.0;

    $pathLoss = 3.5;


    $c1=$txPower;

    $c2=$pathLoss;



    $distanceDiff = $distance*100 / $refDistance;


    $ret=$c1 - 10 * $c2 * log10($distanceDiff);


    return $ret;


    }



    //$tx=19.5;

    $tx=21;

    $rssi=-41;

    echo "txPower=$tx \r\n";


    $ret=doit_rssi($tx,$rssi);

    echo $ret."\r\n";

    echo "Distance"."     "."    RSSI"."\r\n";

    for($i=2;$i<=10;$i++){


    $rssi=(-1)*$i*10;


    $ret=doit_rssi($tx,$rssi);


    echo $ret."          ".$rssi."\r\n";


    }


    return ;

    echo $ret."\r\n";

    echo "Distance"."     "."RSSI"."\r\n";


    return;

    for($i=1;$i<=10;$i++){


    $d=$i*3;


    $ret=doit_to_rssi($tx,$d);



    echo $d."          ".$ret."\r\n";




    }





    ?>


    上一篇:VCB自动保存加载输入控件内容
    下一篇:WIFI QR Code Format