const DISCONNECT = "\x45";
const RELEASE = "\x4D";
const RELEASE_COMPLETE = "\x5A";
+ const FACILITY = "\x62";
const INFORMATION = "\x7B";
/**
/**
* 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
*
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;
+ }
}
?>
--- /dev/null
+<?php
+namespace callnotifier;
+
+/**
+ * Display
+ */
+class EDSS1_Parameter_28 extends EDSS1_Parameter
+{
+ public $title = 'Display';
+}
+
+?>
--- /dev/null
+<?php
+namespace callnotifier;
+
+/**
+ * Information element: Keypad
+ */
+class EDSS1_Parameter_2C extends EDSS1_Parameter
+{
+ public $title = 'Keypad';
+}
+
+?>
--- /dev/null
+<?php
+namespace callnotifier;
+
+/**
+ * Information element: Connected number
+ */
+class EDSS1_Parameter_4C extends EDSS1_Parameter_6C
+{
+ public $title = 'Connected number';
+}
+
+?>
--- /dev/null
+<?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);
+ }
+}
+
+?>
--- /dev/null
+<?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);
+ }
+
+}
+
+?>
$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);
}
/**
- * 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);
}
}
$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 {