add support for disconnected state in index_wstatus1
authorChristian Weiske <cweiske@cweiske.de>
Fri, 17 Dec 2010 07:49:56 +0000 (08:49 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 17 Dec 2010 07:49:56 +0000 (08:49 +0100)
Wrt3g/HtmlParser.php
tests/index_wstatus1-aquiring.phpt

index ac4db350a799090b5698fba62f5e1c350c6c3630..d420f4d07234c08a3c6a66fbae8b9fed47c77d88 100644 (file)
@@ -33,13 +33,14 @@ class Wrt3g_HtmlParser
 
     /**
      * Parses the body of /index_wstatus1.asp and returns extracted values.
 
     /**
      * Parses the body of /index_wstatus1.asp and returns extracted values.
+     * If no connection is established, the values are NULL.
      *
      * @param string $body HTML document to parse
      *
      * @return array Array of key-value pairs, probably with
      *
      * @param string $body HTML document to parse
      *
      * @return array Array of key-value pairs, probably with
-     *               - "type"
-     *               - "network"
-     *               - "signal strength"
+     *               - "type"            - i.e. "GPRS"
+     *               - "network"         - Carrier network name, i.e. "BASE DE"
+     *               - "signal strength" - good, excellent, poor
      */
     public function index_wstatus1($body)
     {
      */
     public function index_wstatus1($body)
     {
@@ -82,6 +83,9 @@ class Wrt3g_HtmlParser
             if (isset(self::$arTranslations[$value])) {
                 $value = self::$arTranslations[$value];
             }
             if (isset(self::$arTranslations[$value])) {
                 $value = self::$arTranslations[$value];
             }
+            if ($value == 'aquiring') {
+                $value = null;
+            }
             $arRetval[$key] = $value;
             next($arMatches);
         }
             $arRetval[$key] = $value;
             next($arMatches);
         }
index 1435fcdee0ad2b53b5711769f047cea469c2373d..6efd48ab60dc9dbd52dc627a94ba202395b5373c 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
 --TEST--
-test Wrt3g_HtmlParser::index_wstatus1() when aquiring
+test Wrt3g_HtmlParser::index_wstatus1() when we have no connection
 --FILE--
 <?php
 chdir(dirname(__FILE__));
 --FILE--
 <?php
 chdir(dirname(__FILE__));
@@ -13,9 +13,9 @@ var_dump(
 --EXPECT--
 array(3) {
   ["type"]=>
 --EXPECT--
 array(3) {
   ["type"]=>
-  string(8) "aquiring"
+  NULL
   ["network"]=>
   ["network"]=>
-  string(8) "aquiring"
+  NULL
   ["signal strength"]=>
   ["signal strength"]=>
-  string(8) "aquiring"
+  NULL
 }
 }