Convert Java.Byte.Array to "normal" Arrays to send Binary Data via Cirrus Link MQTT

Hi everyone, I’m hoping to get your opinions on an issue that I faced

I have 2 gateways (A and B). Gateway A needs to send a file to B via Cirrus Link MQTT, so I create a Byte Array tag since Binary Data is not supported by Cirrus Link yet.

So Gateway A wrote to the tag, Gateway B read the tag, but when trying to do system.file.writeFile, it fails with:

TypeError(“writeFile(): 2nd arg can’t be coerced to String, byte”,)

I found out that it’s because Byte Array tags are type “Java.Byte.Array” and Binary Data tags are type “Array.Array”. And system.file.writeFile needs the latter.

So to fix the problem, I changed the receiving tags on Gateway B to Binary Data and left the Gateway A as Byte Array.

So far it’s working but I’m hoping to get some opinions on is it a good solution, or will it cause problem down the line?

If so, are there ways to convert a “Java.Byte.Array” to “Array.Array”? And will Cirrus Link support Binary Data tags soon?

Thanks :thinking:

Google Jython’s jarray module. That can create objects that are low-level java byte[] datatype.

You may need a special hammer to fit an arbitrary Python byte string into a jarray that writeFile likes:

Although, are you aware that MQTT Transmission and MQTT Engine have a general purpose file-transmission mechanism:

Hi thanks guys for the help, in the end we went with the jarray module to convert java arrays to normal arrays.

And we took at the look at the file transfer mechanism, looks really good we weren’t aware of that. But in the end since we were using satelite data we decided not to go with that as it looks like a lot of overhead.

We went for the simple Byte over tag method, and therefore 0 overhead :grin: