private function createHeader($cmd, $bytes)
    {
        $retval = chr($cmd);

        $bytes_left = $bytes;
        do {
            $byte = $bytes_left % 128;
            $bytes_left >>= 7;

            if($bytes_left>0) {
              $byte = $byte | 0x80;
            }

            $retval.=chr($byte);

        } while($bytes_left>0);

        return $retval;
    }
private function createHeader($cmd, $bytes)
    {
        $retval = chr($cmd);

        $bytes_left = $bytes;
        do {
            $byte = $bytes_left % 128;
            $bytes_left >>= 7;

            if($bytes_left>0) {
              $byte = $byte | 0x80;
            }

            $retval.=chr($byte);

        } while($bytes_left>0);

        return $retval;
    }
private function createHeader ( $ cmd , $ bytes ) { $ retval = chr ( $ cmd ) ; $ bytes_left = $ bytes ; do { $ byte = $ bytes_left % 128 ; $ bytes_left >>= 7 ; if ( $ bytes_left > 0 ) { $ byte = $ byte | 0x80 ; } $ retval .= chr ( $ byte ) ; } while ( $ bytes_left > 0 ) ; return $ retval ; }
Create MQTT header, with command and length

@param int $cmd Command to send
@param int $bytes Number of bytes in the package

@return string Header to send
Create MQTT header with command and length