separation of parameter types. numbers are highlighted in red now
authorChristian Weiske <cweiske@cweiske.de>
Fri, 20 Jul 2012 20:29:51 +0000 (22:29 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 20 Jul 2012 20:29:51 +0000 (22:29 +0200)
src/callnotifier/EDSS1/Message.php
src/callnotifier/EDSS1/Parameter.php
src/callnotifier/EDSS1/Parameter/28.php [new file with mode: 0644]
src/callnotifier/EDSS1/Parameter/2C.php [new file with mode: 0644]
src/callnotifier/EDSS1/Parameter/4C.php [new file with mode: 0644]
src/callnotifier/EDSS1/Parameter/6C.php [new file with mode: 0644]
src/callnotifier/EDSS1/Parameter/70.php [new file with mode: 0644]
src/callnotifier/EDSS1/Parser.php
src/callnotifier/Logger/Echo.php

index 4c3bd68..d490005 100644 (file)
@@ -11,6 +11,7 @@ class EDSS1_Message
     const DISCONNECT = "\x45";
     const RELEASE = "\x4D";
     const RELEASE_COMPLETE = "\x5A";
+    const FACILITY = "\x62";
     const INFORMATION = "\x7B";
 
     /**
@@ -28,25 +29,41 @@ class EDSS1_Message
 
     /**
      * Service AccessPoint Identifier
+     *
+     * @var integer
      */
     public $sapi;
 
     /**
      * Call/Response bit
      *
-     * Is 1 when the message contains a command or
-     * the answer to a command.
+     * Is 1 when the message contains a command to the TE or
+     * the answer to a command from the TE.
+     *
+     * 0 when it it is a request from the TE to the network,
+     * or the answer to a TE request.
+     *
+     * @var integer
      */
     public $callResponse;
 
     /**
      * Terminal Endpoint Identifier (internal Telephone ID)
+     * TEI=127 means broadcast
      *
      * @var integer
      */
     public $tei;
 
     /**
+     * Type of the block
+     * 0 - information block
+     * 1 - control block
+     * @var integer
+     */
+    public $blockType;
+
+    /**
      * Array of EDSS1_Parameter objects
      *
      * @var array
index ded3030..9c1a99c 100644 (file)
@@ -11,6 +11,21 @@ class EDSS1_Parameter
     public $type;
     public $length;
     public $data;
+
+    /**
+     * Internal title of the parameter type
+     */
+    public $title;
+
+    public function __construct($type = null)
+    {
+        $this->type = $type;
+    }
+
+    public function setData($data)
+    {
+        $this->data = $data;
+    }
 }
 
 ?>
diff --git a/src/callnotifier/EDSS1/Parameter/28.php b/src/callnotifier/EDSS1/Parameter/28.php
new file mode 100644 (file)
index 0000000..cb627cb
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+namespace callnotifier;
+
+/**
+ * Display
+ */
+class EDSS1_Parameter_28 extends EDSS1_Parameter
+{
+    public $title = 'Display';
+}
+
+?>
diff --git a/src/callnotifier/EDSS1/Parameter/2C.php b/src/callnotifier/EDSS1/Parameter/2C.php
new file mode 100644 (file)
index 0000000..06c2f4c
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+namespace callnotifier;
+
+/**
+ * Information element: Keypad
+ */
+class EDSS1_Parameter_2C extends EDSS1_Parameter
+{
+    public $title = 'Keypad';
+}
+
+?>
diff --git a/src/callnotifier/EDSS1/Parameter/4C.php b/src/callnotifier/EDSS1/Parameter/4C.php
new file mode 100644 (file)
index 0000000..bf89379
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+namespace callnotifier;
+
+/**
+ * Information element: Connected number
+ */
+class EDSS1_Parameter_4C extends EDSS1_Parameter_6C
+{
+    public $title = 'Connected number';
+}
+
+?>
diff --git a/src/callnotifier/EDSS1/Parameter/6C.php b/src/callnotifier/EDSS1/Parameter/6C.php
new file mode 100644 (file)
index 0000000..2acdebd
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+namespace callnotifier;
+
+/**
+ * Information element: Calling party number
+ */
+class EDSS1_Parameter_6C extends EDSS1_Parameter
+{
+    public $title = 'Calling party number';
+
+    public $numberType;
+    public $numberingPlan;
+    public $presentationIndicator;
+    public $screeningIndicator;
+    public $number;
+
+    public function setData($data)
+    {
+        parent::setData($data);
+        $this->number = substr($data, 2);
+    }
+}
+
+?>
diff --git a/src/callnotifier/EDSS1/Parameter/70.php b/src/callnotifier/EDSS1/Parameter/70.php
new file mode 100644 (file)
index 0000000..0127d43
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+namespace callnotifier;
+
+/**
+ * Information element: Called party number
+ */
+class EDSS1_Parameter_70 extends EDSS1_Parameter
+{
+    public $title = 'Called party number';
+
+    public $numberType;
+    public $numberingPlan;
+    public $number;
+
+    public function setData($data)
+    {
+        parent::setData($data);
+        $this->number = substr($data, 1);
+    }
+
+}
+
+?>
index fb70749..0c9b86a 100644 (file)
@@ -31,16 +31,17 @@ class EDSS1_Parser
                 $complete = true;
                 break;
             }
-            $param = new EDSS1_Parameter();
+
+            $paramType = ord($curbit);
+            $param = $this->getParameterByType($paramType);
             $m->parameters[] = $param;
-            $param->type     = ord($curbit);
 
             //parameter length
             $curbit = $bytes{++$curpos};
             $param->length = ord($curbit);
 
             //parameter data
-            $param->data = substr($bytes, $curpos + 1, $param->length);
+            $param->setData(substr($bytes, $curpos + 1, $param->length));
             $curpos += $param->length;
         } while ($curpos < strlen($bytes) - 1);
 
@@ -65,15 +66,19 @@ class EDSS1_Parser
     }
 
     /**
-     * Read a datablock preceded with a length byte, return integer data.
-     *
-     * @return array Array with new cursor position, integer data and data length
+     * @param integer $type Parameter type ID
      */
-    public function readLengthDataInt($bytes, $curpos)
+    public function getParameterByType($type)
     {
-        $ld = $this->readLengthData($bytes, $curpos);
-        $ld[1] = ord($ld[1]);
-        return $ld;
+        $supported = array(0x28, 0x2C, 0x4C, 0x6C, 0x70);
+        if (!in_array($type, $supported)) {
+            return new EDSS1_Parameter($type);
+        }
+
+        $typeHex = sprintf('%02X', $type);
+        $class = 'callnotifier\EDSS1_Parameter_' . $typeHex;
+
+        return new $class($type);
     }
 }
 
index f0a1a41..688eaaf 100644 (file)
@@ -38,20 +38,29 @@ class Logger_Echo implements Logger
                 $this->purple . 'EDSS1_Message' . $this->end
                 . ' type %02X '
                 . $this->purple . '%s' . $this->end
-                . ' TEI %d, call %d'
+                . ' SAPI %d, CR %d, TEI %d, call %d'
                 . ', %d parameters',
                 $msg->type,
                 $msg->getTypeName(),
+                $msg->sapi,
+                $msg->callResponse,
                 $msg->tei,
                 $msg->callRef,
                 count($msg->parameters)
             ) . "\n";
             foreach ($msg->parameters as $param) {
                 echo sprintf(
-                    " Parameter type %02X, %d bytes: %s\n",
+                    " Parameter type %02X%s, %d bytes: %s\n",
                     $param->type,
+                    $param->title
+                    ? ' ' . $this->purple . $param->title . $this->end
+                    : '',
                     $param->length,
                     preg_replace('/[^[:print:]]/', '?', $param->data)
+                    . (isset($param->number)
+                       ? ' ' . $this->red . $param->number . $this->end
+                       : ''
+                    )
                 );
             }
         } else {