@@ -440,6 +440,7 @@ def publish(self, topic, msg, retain=False, qos=0):
440
440
msg = str (msg ).encode ("ascii" )
441
441
elif isinstance (msg , str ):
442
442
msg = str (msg ).encode ("utf-8" )
443
+ print (type (msg ))
443
444
else :
444
445
raise MMQTTException ("Invalid message data type." )
445
446
if len (msg ) > MQTT_MSG_MAX_SZ :
@@ -464,9 +465,7 @@ def publish(self, topic, msg, retain=False, qos=0):
464
465
remaining_length += 2 + len (qos )
465
466
466
467
# Remaining length calculation
467
- large_rel_length = False
468
468
if remaining_length > 0x7f :
469
- large_rel_length = True
470
469
# Calculate Remaining Length [2.2.3]
471
470
while remaining_length > 0 :
472
471
encoded_byte = remaining_length % 0x80
@@ -475,11 +474,9 @@ def publish(self, topic, msg, retain=False, qos=0):
475
474
if remaining_length > 0 :
476
475
encoded_byte |= 0x80
477
476
pub_hdr_fixed .append (encoded_byte )
478
- if large_rel_length :
479
- pub_hdr_fixed .append (0x00 )
480
477
else :
478
+ print ('remaining_length' , remaining_length )
481
479
pub_hdr_fixed .append (remaining_length )
482
- #pub_hdr_fixed()
483
480
484
481
485
482
self ._sock .send (pub_hdr_fixed )
0 commit comments