Ejemplo n.º 1
0
 /**
  * Decode the property by inspecting the nibbles of each blob, checking the control, and adding up the results into
  * a final value.
  *
  * @param string $hex
  * @param bool $string Whether or not this is simple string data.
  * @return string
  */
 protected function decodePropValue($hex, $string = false)
 {
     $decodePropValue = '';
     $blobs = str_split($hex, 6);
     foreach ($blobs as $blob) {
         $bin = decbin(hexdec($blob));
         $controlY = substr($bin, 4, 6);
         $nibbleY = substr($bin, 10, 4);
         $controlX = substr($bin, 14, 6);
         $nibbleX = substr($bin, 20, 4);
         $byte = $this->nibbleControl($nibbleX, $controlX) . $this->nibbleControl($nibbleY, $controlY);
         if ($string) {
             $decodePropValue .= MBString::chr(bindec($byte));
         } else {
             $decodePropValue = $this->dec2hex(bindec($byte)) . $decodePropValue;
         }
     }
     return $decodePropValue;
 }
Ejemplo n.º 2
0
 /**
  * Decode and parse the binary dial-in data from the userParameters attribute (the data between 44 and 96 bytes).
  * 
  * @param string $binary
  */
 protected function decode($binary)
 {
     $hex = bin2hex($binary);
     $this->signature = MBString::chr(hexdec(substr($hex, 0, 2)));
     $this->userPrivilege = hexdec(substr($hex, 2, 2));
     $this->callbackPhoneNumber = substr($hex, 4, 48);
 }