From: Christian Weiske Date: Fri, 20 Jul 2012 20:29:51 +0000 (+0200) Subject: separation of parameter types. numbers are highlighted in red now X-Git-Tag: v1.0.0~81 X-Git-Url: https://git.cweiske.de/auerswald-callnotifier.git/commitdiff_plain/706f3104305337ecf582897bcc42499fa6623178 separation of parameter types. numbers are highlighted in red now --- diff --git a/src/callnotifier/EDSS1/Message.php b/src/callnotifier/EDSS1/Message.php index 4c3bd68..d490005 100644 --- a/src/callnotifier/EDSS1/Message.php +++ b/src/callnotifier/EDSS1/Message.php @@ -11,6 +11,7 @@ class EDSS1_Message const DISCONNECT = "\x45"; const RELEASE = "\x4D"; const RELEASE_COMPLETE = "\x5A"; + const FACILITY = "\x62"; const INFORMATION = "\x7B"; /** @@ -28,24 +29,40 @@ 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 * diff --git a/src/callnotifier/EDSS1/Parameter.php b/src/callnotifier/EDSS1/Parameter.php index ded3030..9c1a99c 100644 --- a/src/callnotifier/EDSS1/Parameter.php +++ b/src/callnotifier/EDSS1/Parameter.php @@ -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 index 0000000..cb627cb --- /dev/null +++ b/src/callnotifier/EDSS1/Parameter/28.php @@ -0,0 +1,12 @@ + diff --git a/src/callnotifier/EDSS1/Parameter/2C.php b/src/callnotifier/EDSS1/Parameter/2C.php new file mode 100644 index 0000000..06c2f4c --- /dev/null +++ b/src/callnotifier/EDSS1/Parameter/2C.php @@ -0,0 +1,12 @@ + diff --git a/src/callnotifier/EDSS1/Parameter/4C.php b/src/callnotifier/EDSS1/Parameter/4C.php new file mode 100644 index 0000000..bf89379 --- /dev/null +++ b/src/callnotifier/EDSS1/Parameter/4C.php @@ -0,0 +1,12 @@ + diff --git a/src/callnotifier/EDSS1/Parameter/6C.php b/src/callnotifier/EDSS1/Parameter/6C.php new file mode 100644 index 0000000..2acdebd --- /dev/null +++ b/src/callnotifier/EDSS1/Parameter/6C.php @@ -0,0 +1,24 @@ +number = substr($data, 2); + } +} + +?> diff --git a/src/callnotifier/EDSS1/Parameter/70.php b/src/callnotifier/EDSS1/Parameter/70.php new file mode 100644 index 0000000..0127d43 --- /dev/null +++ b/src/callnotifier/EDSS1/Parameter/70.php @@ -0,0 +1,23 @@ +number = substr($data, 1); + } + +} + +?> diff --git a/src/callnotifier/EDSS1/Parser.php b/src/callnotifier/EDSS1/Parser.php index fb70749..0c9b86a 100644 --- a/src/callnotifier/EDSS1/Parser.php +++ b/src/callnotifier/EDSS1/Parser.php @@ -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); } } diff --git a/src/callnotifier/Logger/Echo.php b/src/callnotifier/Logger/Echo.php index f0a1a41..688eaaf 100644 --- a/src/callnotifier/Logger/Echo.php +++ b/src/callnotifier/Logger/Echo.php @@ -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 {