Msg_Id Generation algorithm of CMPP Protocol

I really don"t know how to generate this MsgId.
I have tried to write the following words incorrectly

.
public function msgId($spid, $sqid)
    {
        $timeStr = time();
        echo sprintf("%02d%02d%02d%02d%02d%07d%05d", date("m", $timeStr), date("d", $timeStr), date("H", $timeStr), date("i", $timeStr), date("s", $timeStr), $spid, $sqid) , "\n";
        return sprintf("%02d%02d%02d%02d%02d%07d%05d", date("m", $timeStr), date("d", $timeStr), date("H", $timeStr), date("i", $timeStr), date("s", $timeStr), $spid, $sqid);
    }
    pack("N2C", $this->msgId($Msg_src,$header["sequence_number"]), 0)

    public function msgId($spid, $sqid)
    {
        $timeStr = time();
        //echo bindec(sprintf("%04s%05s%05s%06s%06s%022s%016s",decbin(date('m', $timeStr)),decbin(date('d', $timeStr)),decbin(date('H', $timeStr)),decbin(date('i', $timeStr)),decbin(date('s', $timeStr)),decbin($spid), decbin($sqid)));
        return bindec(sprintf("%04s%05s%05s%06s%06s%022s%016s",decbin(date('m', $timeStr)),decbin(date('d', $timeStr)),decbin(date('H', $timeStr)),decbin(date('i', $timeStr)),decbin(date('s', $timeStr)),decbin($spid), decbin($sqid)));
    }

    $this->msgId('600010','2');

correct your thinking here
first: 64 bits can only store values between 0 and 1, that is to say, they are all binary data
, so just splice binary data

.
month (1-12) ([0001-1100]) interval 4-digit) decbin (date ('mm, $timeStr))
day (1-31) ([00001-11111] interval 5-digit) decbin (date ('dice, $timeStr))
time (1-24) ([00001-11000] interval 5-digit) decbin (date ('ha), $timeStr))
score (1-59) ([000001-111011] interval 6-digit) decbin (date ('i), $timeStr))
seconds (1-59) ([000001-111011] interval 6-bit) decbin (date ('s codes, $timeStr))
gateway code ([0,0-1q1] 22-bit) decbin ($spid1)
/ / (if the gateway code is composed of 22 bits 0 and 1, no decbin, is used It is binary itself, and if not, it becomes binary)
sequence number (interval 16-bit) decbin ($spid2)

how many digits of the gateway code I haven't washed, serial number, etc. You can adjust the number of digits by yourself % 04d%06d%05d%06d%06d [% 021d%016d] <-here if the calculation is correct, it should be 64 bits, then this 64 bit is a binary string, converted into a decimal value with bindec (), and stored in the database, then the binary data stored in the database meets the requirements you want. And decimal data, 8 bits, 64 bytes, perfect

variable name with dim sum $spid, $sqid I thought it was a

the following method is also simple and logically difficult to understand, but it is quite simple. I have learned

$messageId = 0;
$messageId | = $m < < 60;
$messageId | = $d < < 55;
$messageId | = $h < < 50;
$messageId | = $I < < 44;
$messageId | = $s < < 38;
$messageId | = $spid < < 16;
$messageId | = $sqid & 0xfft;
echo $messageId
Menu