+ /**
+ * 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 = array();
+
+ $strUrlBase = $this->getAuthBaseUrl();
+
+ $url = $strUrlBase . '/Status_NoAuth.asp';
+ $this->log('Connecting to ' . $url, 1);
+
+ $r = new HTTP_Request2();
+ $r->setMethod(HTTP_Request2::METHOD_GET);
+ $r->setUrl($url);
+ $resp = $r->send();
+ $this->log($resp->getStatus() . ' ' . $resp->getReasonPhrase(), 1);
+ //FIXME: check status
+
+ $parser = new Wrt3g_HtmlParser();
+ $arRetval = $parser->status_noauth($resp->getBody());
+
+ return array_intersect_key(
+ $arRetval,
+ array(
+ 'card model' => 0,
+ 'card revision' => 0,
+ 'card firmware' => 0,
+ 'IMSI' => 0
+ )
+ );
+ }
+
+
+
/**
* Log a message to stdout.
*
*
* @return void
*/
- protected function log($msg, $level = 1)
+ public function log($msg, $level = 1)
{
if ($this->verbosity >= $level) {
echo $msg . "\n";
)
);
-$parser->addCommand(
+$stCmd = $parser->addCommand(
'status',
array(
'aliases' => array('s', 'st'),
'description' => 'Show the router status'
)
);
+$stCmd = $parser->addCommand(
+ 'cardstatus',
+ array(
+ 'aliases' => array('c', 'cs'),
+ 'description' => 'Show the card/SIM status'
+ )
+);
+
+
$parser->addCommand(
'reboot',
array(
$router->user = $result->options['user'];
$router->password = $result->options['password'];
+ $router->log('Command: ' . $result->command_name, 2);
+
switch ($result->command_name) {
case 'reboot':
$resp = $router->reboot();
}
break;
+ case 'cardstatus':
case 'status':
default:
- $arStatus = $router->getStatus();
+ if ($result->command_name == 'cardstatus') {
+ $arStatus = $router->getCardStatus();
+ } else {
+ $arStatus = $router->getStatus();
+ }
foreach ($arStatus as $key => $value) {
echo $key . ': ' . $value . "\n";
}