+ }//public function getConnectionStatus()
+
+
+
+ /**
+ * Loads "Status_NoAuth.asp" page and parses the body.
+ *
+ * @return array Associative array with connection status.
+ *
+ * @throws Exception When something goes wrong, i.e. router not
+ * reachable
+ */
+ protected function loadStatus_NoAuth()
+ {
+ $strUrlBase = $this->getAnonBaseUrl();
+
+ $url = $strUrlBase . '/Status_NoAuth.asp';
+ $this->log('Connecting to ' . $url, 1);
+
+ $r = $this->createRequest();
+ $r->setMethod(HTTP_Request2::METHOD_GET);
+ $r->setUrl($url);
+ $resp = $r->send();
+ $this->checkResponseStatus($resp);
+
+ $parser = new Wrt3g_HtmlParser();
+
+ return $parser->status_noauth(
+ $resp->getBody()
+ );
+ }
+
+
+
+ /**
+ * Checks the HTTP response code and throws an exception if it
+ * is not in the 200 range.
+ *
+ * @param HTTP_Request2_Response $resp HTTP response object
+ *
+ * @return void
+ *
+ * @throws Exception When the status is not 200-299
+ */
+ protected function checkResponseStatus(HTTP_Request2_Response $resp)
+ {
+ $nStatus = $resp->getStatus();
+ $this->log($nStatus . ' ' . $resp->getReasonPhrase(), 1);
+ if (intval($nStatus / 100) == 2) {
+ //2xx status is fine
+ return;
+ }
+
+ throw new Exception(
+ 'HTTP Error: ' . $nStatus . ' ' . $resp->getReasonPhrase()
+ );
+ }
+
+
+
+ /**
+ * Retrieves pc card/SIM status information
+ *
+ * @return array Array with several key-value pairs
+ * connection => connecting, disconnected, connected
+ *
+ * @throws Exception When the router can't be reached
+ */
+ public function getCardStatus()
+ {
+ $arRetval = $this->loadStatus_NoAuth();
+
+ return array_intersect_key(
+ $arRetval,
+ array(
+ 'card model' => 0,
+ 'card revision' => 0,
+ 'card firmware' => 0,
+ 'IMSI' => 0
+ )
+ );
+ }
+
+
+
+ /**
+ * Retrieves all status information one can get.
+ *
+ * @return array Array with several key-value pairs
+ * connection => connecting, disconnected, connected
+ *
+ * @throws Exception When the router can't be reached
+ */
+ public function getFullStatus()
+ {
+ return $this->loadStatus_NoAuth();
+ }
+
+
+
+ /**
+ * Log a message to stdout.
+ *
+ * @param string|object $msg Message to display. May even be a response
+ * object
+ * @param integer $level Log level, see $verbosity
+ *
+ * @return void
+ */
+ public function log($msg, $level = 1)
+ {
+ if ($this->verbosity >= $level) {
+ echo $msg . "\n";
+ }
+ }