BLOB Payload on Custom Namespace Topic

Hi there,

MQTT Engine is set up to Subscribe to a Custom Name Space Topic and a Ignition Gateway Script is writing the message payload into a binary file.
Everything works fine, except the content of the file looks nothing like the file of which content what was published.
I suspect this is due to the MQTT Engine wanting to handle the payload as a Encoding Formatted String but I don’t know how to encode the payload before publishing it so that it works.
Any help would be appreciated!

Could you just read the file into a String and publish the String? Something like this: Python - Read File as String

Just in case anyone else is wondering how to achieve this, here is how I was able to do it in the Ignition Script Console:

#make sure that in MQTT Engine Settings you create a new Custom Namespace, then configure it like this:
#Subscriptions = 'm/Test' - change this to whatever you need
#Root Tag Folder = '' - change this to whatever you need
#Tag Name = 'imageFile' - change this to whatever you need
#JSON Payload = False
#Encoding Charset = 'ISO_8859_1'

import time

#change the send file to whatever you need
with open('C:/Users/user/Pictures/send.jpg', 'rb') as sendFile:
	sendFileData = sendFile.read()
mqttPayload = sendFileData.decode('iso8859_1')
system.cirruslink.transmission.publish('MQTT Transmission Server Name', 'm/Test', mqttPayload, 2, True)

#give the MQTT Engine some time to process the received MQTT message
time.sleep(3)

mqttQVs = system.tag.readBlocking(['[MQTT Engine]m/Test/imageFile'])
#change the received file to whatever you need
with open('C:/Users/user/Pictures/received.jpg', 'wb') as recvFile:
	recvFile.write((mqttQVs[0].value.encode('iso8859_1')))
2 Likes