2 namespace callnotifier;
10 public function parse($bytes)
12 $m = new EDSS1_Message();
13 $m->tei = ord($bytes{1}) >> 1;//1st bit is always 1 and needs to be removed
16 list($curpos, $m->callRef) = $this->readLengthDataInt($bytes, ++$curpos);
17 //var_dump($curpos, dechex($m->callRef));
18 $m->type = ord($bytes{++$curpos});
23 $curbit = $bytes{++$curpos};
24 if ($curbit == "\xFF" && $bytes{$curpos + 1} == "\n") {
28 $param = new EDSS1_Parameter();
29 $m->parameters[] = $param;
30 $param->type = ord($curbit);
33 $curbit = $bytes{++$curpos};
34 $param->length = ord($curbit);
37 $param->data = substr($bytes, $curpos + 1, $param->length);
38 $curpos += $param->length;
39 } while ($curpos < strlen($bytes) - 1);
45 * Read a datablock preceded with a length byte.
47 * @return array Array with new cursor position, data and data length
49 public function readLengthData($bytes, $curpos)
51 //var_dump('old' . $curpos);
52 $length = ord($bytes{$curpos});
53 $data = substr($bytes, $curpos + 1, $length);
54 return array($curpos + $length, $data, $length);
58 * Read a datablock preceded with a length byte, return integer data.
60 * @return array Array with new cursor position, integer data and data length
62 public function readLengthDataInt($bytes, $curpos)
64 $ld = $this->readLengthData($bytes, $curpos);