dummy callref support
authorChristian Weiske <cweiske@cweiske.de>
Tue, 24 Jul 2012 05:47:44 +0000 (07:47 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 24 Jul 2012 05:47:44 +0000 (07:47 +0200)
src/callnotifier/EDSS1/Parser.php
tests/callnotifier/EDSS1/ParserTest.php

index f3ebebafd8035ea95ce2b2a24fba4ab7308bd0f0..b5a906d07408566970fb745d5bc3a60e94d5396a 100644 (file)
@@ -19,16 +19,17 @@ class EDSS1_Parser
         if ($crLen == 0xFF) {
             return $m;
         }
-        $m->callRefType = ord($cCallRef{0}) >> 7;
-        $nCallRef = ord($cCallRef{0}) & 127;
-        if ($crLen > 1) {
-            $nCallRef = ord($cCallRef{1}) + ($nCallRef << 8);
-            if ($crLen > 2) {
-                $nCallRef = ord($cCallRef{2}) + ($nCallRef << 8);
+        if ($crLen > 0) {
+            $m->callRefType = ord($cCallRef{0}) >> 7;
+            $nCallRef = ord($cCallRef{0}) & 127;
+            if ($crLen > 1) {
+                $nCallRef = ord($cCallRef{1}) + ($nCallRef << 8);
+                if ($crLen > 2) {
+                    $nCallRef = ord($cCallRef{2}) + ($nCallRef << 8);
+                }
             }
+            $m->callRef = $nCallRef;
         }
-        $m->callRef = $nCallRef;
-        //var_dump($curpos, dechex($m->callRef));
         $m->type = ord($bytes{++$curpos});
 
         $complete = false;
index e31367d3a482795d4cd710b1b6a6f025c61a7fe7..78347bea20849ebf5e5621ffe836dd61938f4aa2 100644 (file)
@@ -78,6 +78,13 @@ class EDSS1_ParserTest extends \PHPUnit_Framework_TestCase
         self::assertEquals(0x050607, $msg->callRef, 'Call reference is wrong');
         self::assertEquals(1, $msg->callRefType, 'Call reference type is wrong');
     }
+
+    public function testParseCallRefDummy()
+    {
+        $msg = $this->parseMsg(
+            '02 FF FF 03 08 00 62 1C 12 91 A1 0F 02 02 41 06 06 06 04 00 82 67 01 0A 02 01 01 70 0B A1 33 34 32 36 31 34 30 38 36 32 FF 0A'
+        );
+    }
 }
 
 ?>