But when I am sending the same data to device and trying to print it. It is printing text instead of image.
But when printing the same data locally written in device, then I am successfully able to print.
So I guess the problem is from sending and receiving end while encoding or decoding. Is there an example where I can take a loot at it. Or what is the way to do it?
How are you handling the incoming JSON on the agent side? I would call http.jsondecode() to convert the incoming JSON (a string) to a Squirrel table, which in this case will have one key, text, which has your binary string as its value. You can then send that value to the device.
What you appear to be doing is just sending the incoming JSON string right through to the device without decoding it manually to extract the bytes you want, ie. your code is trying to print the incoming data as a complete string.
You can see your data bytes as the last 18 pairs in the “local raster data”.
This is a Latin-1 to UTF-8 conversion. JSON strings are required to be encoded in UTF-8, which you raw binary data isn’t. I’m not sure exactly where in the process things are going wrong, but you can fix it by ensuring that your JSON string is valid UTF-8 – e.g., by Base64-encoding it in your Python server and Base64-decoding it in the agent code before sending it to the device.