mqtt/pdu.py
def decode(self, packet):
        '''
        Decode a PUBLISH control packet. 
        '''
        self.encoded = packet
        lenLen = 1
        while packet[lenLen] & 0x80:
            lenLen += 1
        packet_remaining = packet[lenLen+1:]
        self.dup    = (packet[0] & 0x08) == 0x08
        self.qos    = (packet[0] & 0x06) >> 1
        self.retain = (packet[0] & 0x01) == 0x01
        self.topic, _  = decodeString(packet_remaining)
        topicLen       = decode16Int(packet_remaining)
        if self.qos:
            self.msgId = decode16Int( packet_remaining[topicLen+2:topicLen+4] )
            self.payload =  packet_remaining[topicLen+4:]
        else:
            self.msgId = None
            self.payload = packet_remaining[topicLen+2:]
def decode(self, packet):
        '''
        Decode a PUBLISH control packet. 
        '''
        self.encoded = packet
        lenLen = 1
        while packet[lenLen] & 0x80:
            lenLen += 1
        packet_remaining = packet[lenLen+1:]
        self.dup    = (packet[0] & 0x08) == 0x08
        self.qos    = (packet[0] & 0x06) >> 1
        self.retain = (packet[0] & 0x01) == 0x01
        self.topic, _  = decodeString(packet_remaining)
        topicLen       = decode16Int(packet_remaining)
        if self.qos:
            self.msgId = decode16Int( packet_remaining[topicLen+2:topicLen+4] )
            self.payload =  packet_remaining[topicLen+4:]
        else:
            self.msgId = None
            self.payload = packet_remaining[topicLen+2:]
def decode ( self , packet ) : self . encoded = packet lenLen = 1 while packet [ lenLen ] & 0x80 : lenLen += 1 packet_remaining = packet [ lenLen + 1 : ] self . dup = ( packet [ 0 ] & 0x08 ) == 0x08 self . qos = ( packet [ 0 ] & 0x06 ) >> 1 self . retain = ( packet [ 0 ] & 0x01 ) == 0x01 self . topic , _ = decodeString ( packet_remaining ) topicLen = decode16Int ( packet_remaining ) if self . qos : self . msgId = decode16Int ( packet_remaining [ topicLen + 2 : topicLen + 4 ] ) self . payload = packet_remaining [ topicLen + 4 : ] else : self . msgId = None self . payload = packet_remaining [ topicLen + 2 : ]
Decode a PUBLISH control packet.
Decode a PUBLISH control packet .