@@ -440,6 +440,7 @@ def publish(self, topic, msg, retain=False, qos=0):
440440 msg = str (msg ).encode ("ascii" )
441441 elif isinstance (msg , str ):
442442 msg = str (msg ).encode ("utf-8" )
443+ print (type (msg ))
443444 else :
444445 raise MMQTTException ("Invalid message data type." )
445446 if len (msg ) > MQTT_MSG_MAX_SZ :
@@ -464,9 +465,7 @@ def publish(self, topic, msg, retain=False, qos=0):
464465 remaining_length += 2 + len (qos )
465466
466467 # Remaining length calculation
467- large_rel_length = False
468468 if remaining_length > 0x7f :
469- large_rel_length = True
470469 # Calculate Remaining Length [2.2.3]
471470 while remaining_length > 0 :
472471 encoded_byte = remaining_length % 0x80
@@ -475,11 +474,9 @@ def publish(self, topic, msg, retain=False, qos=0):
475474 if remaining_length > 0 :
476475 encoded_byte |= 0x80
477476 pub_hdr_fixed .append (encoded_byte )
478- if large_rel_length :
479- pub_hdr_fixed .append (0x00 )
480477 else :
478+ print ('remaining_length' , remaining_length )
481479 pub_hdr_fixed .append (remaining_length )
482- #pub_hdr_fixed()
483480
484481
485482 self ._sock .send (pub_hdr_fixed )
0 commit comments