aboutsummaryrefslogtreecommitdiff
path: root/src/callnotifier/EDSS1/Parser.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2012-07-20 07:45:53 +0200
committerChristian Weiske <cweiske@cweiske.de>2012-07-20 07:45:53 +0200
commit2039373b7d60786e5b92a79520cecfcfce34c044 (patch)
treed30dac6fa8c58cd5990c6abfa4fc533f890bfaf3 /src/callnotifier/EDSS1/Parser.php
parent0073743d7518e5899f0cd075a1c7755a9d603bbd (diff)
downloadauerswald-callnotifier-2039373b7d60786e5b92a79520cecfcfce34c044.tar.gz
auerswald-callnotifier-2039373b7d60786e5b92a79520cecfcfce34c044.zip
read TEI and call reference
Diffstat (limited to 'src/callnotifier/EDSS1/Parser.php')
-rw-r--r--src/callnotifier/EDSS1/Parser.php33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/callnotifier/EDSS1/Parser.php b/src/callnotifier/EDSS1/Parser.php
index 5a298e5..64a072e 100644
--- a/src/callnotifier/EDSS1/Parser.php
+++ b/src/callnotifier/EDSS1/Parser.php
@@ -10,9 +10,13 @@ class EDSS1_Parser
public function parse($bytes)
{
$m = new EDSS1_Message();
- $m->type = ord($bytes{7});
+ $m->tei = ord($bytes{1}) >> 1;//1st bit is always 1 and needs to be removed
+
+ $curpos = 4;
+ list($curpos, $m->callRef) = $this->readLengthDataInt($bytes, ++$curpos);
+ //var_dump($curpos, dechex($m->callRef));
+ $m->type = ord($bytes{++$curpos});
- $curpos = 7;
$complete = false;
do {
//parameter type
@@ -36,6 +40,31 @@ class EDSS1_Parser
return $m;
}
+
+ /**
+ * Read a datablock preceded with a length byte.
+ *
+ * @return array Array with new cursor position, data and data length
+ */
+ public function readLengthData($bytes, $curpos)
+ {
+ //var_dump('old' . $curpos);
+ $length = ord($bytes{$curpos});
+ $data = substr($bytes, $curpos + 1, $length);
+ return array($curpos + $length, $data, $length);
+ }
+
+ /**
+ * Read a datablock preceded with a length byte, return integer data.
+ *
+ * @return array Array with new cursor position, integer data and data length
+ */
+ public function readLengthDataInt($bytes, $curpos)
+ {
+ $ld = $this->readLengthData($bytes, $curpos);
+ $ld[1] = ord($ld[1]);
+ return $ld;
+ }
}
?>