cvs: pear /Net_Wifi/Net Wifi.php /Net_Wifi/tests Wifi_testcase.php

From: Date: Fri, 27 Oct 2006 21:49:32 +0000
Subject: cvs: pear /Net_Wifi/Net Wifi.php /Net_Wifi/tests Wifi_testcase.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42838@lists.php.net to get a copy of this message
cweiske Fri Oct 27 21:49:32 2006 UTC Modified files: /pear/Net_Wifi/Net Wifi.php /pear/Net_Wifi/tests Wifi_testcase.php Log: Adding support for new iwlist output format http://cvs.php.net/viewvc.cgi/pear/Net_Wifi/Net/Wifi.php?r1=1.4&r2=1.5&diff_format=u Index: pear/Net_Wifi/Net/Wifi.php diff -u pear/Net_Wifi/Net/Wifi.php:1.4 pear/Net_Wifi/Net/Wifi.php:1.5 --- pear/Net_Wifi/Net/Wifi.php:1.4 Fri Oct 27 21:16:14 2006 +++ pear/Net_Wifi/Net/Wifi.php Fri Oct 27 21:49:32 2006 @@ -16,7 +16,7 @@ * @category Net * @package Net * @license http://www.php.net/license/3_0.txt PHP License 3.0 -* @version CVS: $Id: Wifi.php,v 1.4 2006/10/27 21:16:14 cweiske Exp $ +* @version CVS: $Id: Wifi.php,v 1.5 2006/10/27 21:49:32 cweiske Exp $ */ require_once 'Net/Wifi/Cell.php'; @@ -227,6 +227,9 @@ return array(); } + //if bit rates are alone on lines + $bStandaloneRates = false; + //split into cells $arCells = array(); $nCurrentCell = -1; @@ -277,10 +280,16 @@ case 'bit rate': $nRate = floatval(substr($strValue, 0, strpos($strValue, 'Mb/s'))); - $arCells[$nCurrentCell]->rate = $nRate; + $arCells[$nCurrentCell]->rate = $nRate; $arCells[$nCurrentCell]->rates[] = $nRate; break; + case 'bit rates': + $bStandaloneRates = true; + $arLines[$nA] = $strValue; + $nA--;//go back one so that this line is re-parsed + break; + case 'protocol': $arCells[$nCurrentCell]->protocol = $strValue; break; @@ -359,6 +368,16 @@ break; default: + if ($bStandaloneRates) { + if (preg_match_all('|([0-9.]+) Mb/s|', $strLine, $arMatches) > 0) { + foreach ($arMatches[1] as $nRate) { + $nRate = floatval($nRate); + $arCells[$nCurrentCell]->rate = $nRate; + $arCells[$nCurrentCell]->rates[] = $nRate; + } + break; + } + } echo 'unknown iwconfig information: ' . $strId . "\r\n"; break; } http://cvs.php.net/viewvc.cgi/pear/Net_Wifi/tests/Wifi_testcase.php?r1=1.3&r2=1.4&diff_format=u Index: pear/Net_Wifi/tests/Wifi_testcase.php diff -u pear/Net_Wifi/tests/Wifi_testcase.php:1.3 pear/Net_Wifi/tests/Wifi_testcase.php:1.4 --- pear/Net_Wifi/tests/Wifi_testcase.php:1.3 Fri Oct 27 21:16:14 2006 +++ pear/Net_Wifi/tests/Wifi_testcase.php Fri Oct 27 21:49:32 2006 @@ -366,6 +366,36 @@ $this->assertEquals( false , $arCells[0]->encryption); + //ipw2200 kernel 2.18.1 (probably version 1.1.3) + $arLines = explode("\n", <<<EOD +eth1 Scan completed : + Cell 01 - Address: 00:12:D9:AC:BD:00 + ESSID:"<hidden>" + Protocol:IEEE 802.11bg + Mode:Master + Channel:1 + Encryption key:off + Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 6 Mb/s; 9 Mb/s + 11 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s + 48 Mb/s; 54 Mb/s + Quality=89/100 Signal level=-40 dBm + Extra: Last beacon: 1472ms ago +EOD + ); + $arCells = $this->wls->parseScan($arLines); + + $this->assertEquals( 1 , count($arCells)); + $this->assertEquals( '00:12:D9:AC:BD:00' , $arCells[0]->mac); + $this->assertEquals( '<hidden>' , $arCells[0]->ssid); + $this->assertEquals( 'master' , $arCells[0]->mode); + $this->assertEquals( -40 , $arCells[0]->rssi); + $this->assertEquals( null , $arCells[0]->frequency); + $this->assertEquals( 54 , $arCells[0]->rate); + $this->assertEquals( array(1.,2.,5.5,6.,9.,11., + 12.,18.,24.,36.,48.,54.), $arCells[0]->rates); + $this->assertEquals( false , $arCells[0]->encryption); + $this->assertEquals( 1472 , $arCells[0]->beacon); + }//function testParseScan() }//class Net_Wifi_Test extends PHPUnit_TestCase

« previous php.pear.cvs (#42838) next »