Skip to content

Commit 207d195

Browse files
committed
Add #90 real-time debug output
1 parent 6841740 commit 207d195

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

decode-config.py

+13
Original file line numberDiff line numberDiff line change
@@ -4280,6 +4280,8 @@ def on_message(client, userdata, msg):
42804280
base64_data = ""
42814281
rcv_id = 0
42824282

4283+
if ARGS.debug:
4284+
print("{}: on_message - payload {}".format(datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"), msg.payload.decode(STR_CODING)))
42834285
try:
42844286
root = json.loads(msg.payload.decode(STR_CODING))
42854287
if root:
@@ -4325,6 +4327,9 @@ def on_message(client, userdata, msg):
43254327
except:
43264328
pass
43274329

4330+
if ARGS.debug:
4331+
print("{}: on_message - use_base64={}, file_id={}, rcv_id={}, file_type={}, file_size={}, file_md5={}, in_hash_md5={}".format(datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"), use_base64, file_id, rcv_id, file_type, file_size, file_md5, in_hash_md5.hexdigest()))
4332+
43284333
if dobj is None and file_id == 0 and rcv_id > 0 and file_size > 0 and file_type > 0 and file_name:
43294334
file_id = rcv_id
43304335
dobj = bytearray()
@@ -4422,19 +4427,27 @@ def wait_for_connect():
44224427
in_hash_md5 = hashlib.md5()
44234428

44244429
data = {"Password":tasmota_mqtt_password, "Type":MQTT_FILETYPE}
4430+
if ARGS.debug:
4431+
data_dbg = {"Password":HIDDEN_PASSWORD, "Type":MQTT_FILETYPE}
44254432
if not use_base64:
44264433
data["Binary"] = 1
44274434
client.publish(topic_publish, json.dumps(data))
4435+
if ARGS.debug:
4436+
print("{}: client.publish({}, {})".format(datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"), topic_publish, json.dumps(data_dbg)))
44284437

44294438
ack_flag = True
44304439
run_flag = True
44314440
while run_flag:
44324441
if wait_for_ack(): # We use Ack here
44334442
client.publish(topic_publish, "0") # Abort any failed download
4443+
if ARGS.debug:
4444+
print('{}: client.publish({}, "0")'.format(datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"), topic_publish))
44344445
run_flag = False
44354446
else:
44364447
if file_md5 == "": # Request chunk
44374448
client.publish(topic_publish, "?")
4449+
if ARGS.debug:
4450+
print('{}: client.publish({}, "?")'.format(datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"), topic_publish))
44384451
ack_flag = True
44394452
else:
44404453
run_flag = False

0 commit comments

Comments
 (0)