'GPRS_MSG.ACQUIRING' => 'aquiring',
'GPRS_MSG.WWBEAR_GPRS' => 'GPRS',
'GPRS_MSG.WWBEAR_UMTS' => 'UMTS',
+ 'GPRS_MSG.None' => null,
'GPRS_MSG.GOOD' => 'good',
'GPRS_MSG.EXCELLENT' => 'excellent',
'GPRS_MSG.CTIME' => 'connection time',
* - card revision
* - card firmware
* - IMSI
- *
- * @todo FIXME implement "connection" value as index_wstatus2() does it
*/
public function status_noauth($body)
{
$doc->loadHtml($body);
$xpath = new DOMXPath($doc);
$trs = $xpath->query('//table//table/tbody/tr');
- $arRaw = array();
+ $arRaw = array('connection' => null);
+ $bAquiring = false;
foreach ($trs as $tr) {
$titleItems = $xpath->query('td[@width=125]/text()', $tr);
$valueItems = $xpath->query('td[@width=296]/*[1]', $tr);
$value = trim(strip_tags($value));
if (substr($value, 0, 8) == 'Capture(') {
$value = self::$arTranslations[substr($value, 8, -1)];
+ if ($value == 'aquiring') {
+ $bAquiring = true;
+ $value = null;
+ }
}
}
unset($value);
+ if ($bAquiring) {
+ $arRaw['connection'] = 'connecting';
+ } else if ($arRaw['type'] != null) {
+ $arRaw['connection'] = 'connected';
+ } else {
+ $arRaw['connection'] = 'disconnected';
+ }
+
if (isset($arRaw['connection time'])) {
$arRaw['connection time'] = str_replace(
array(
'TX = ',
str_replace('RX = ', '', $arRaw['session usage'])
);
- $arRaw['session usage'] = array(
- 'received' => $arS[0],
- 'sent' => $arS[1]
- );
+ if (count($arS) > 1) {
+ $arRaw['session usage'] = array(
+ 'received' => $arS[0],
+ 'sent' => $arS[1]
+ );
+ }
}
return $arRaw;
--- /dev/null
+--TEST--
+test Wrt3g_HtmlParser::status_noauth() when we have no conection
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+require_once dirname(__FILE__) . '/../Wrt3g/HtmlParser.php';
+$p = new Wrt3g_HtmlParser();
+var_dump(
+ $p->status_noauth(
+ file_get_contents('status_noauth-aquiring.htm')
+ )
+);
+--EXPECT--
+array(10) {
+ ["connection"]=>
+ string(10) "connecting"
+ ["type"]=>
+ NULL
+ ["network"]=>
+ NULL
+ ["signal strength"]=>
+ NULL
+ ["connection time"]=>
+ NULL
+ ["session usage"]=>
+ NULL
+ ["card model"]=>
+ string(29) "GlobeTrotter Fusion Quad Lite"
+ ["card revision"]=>
+ string(3) "4.1"
+ ["card firmware"]=>
+ string(42) "1.5.5 (Date: May 17 2005, Time: 14:55:44)"
+ ["IMSI"]=>
+ string(15) "262032010984707"
+}
\ No newline at end of file