I have an MQTT gateway for Modbus that needs to receive in hexadecimal. How can I do this?
No-one seems to have an answer for this. Have you made any progress ?
Maybe you could encode it to base64 and then decode it at other end. I have done it in my tutorial, I encoded and decoded the image to base64 and sent it through MQTT.
<!DOCTYPE html>
<html>
<head>
<title>
How to convert image into base64 string using JavaScript ?
</title>
</head>
<body>
<input type = "file" name = "" id = "fileId" onchange = "imageUploaded()" >
<br><br>
<button onclick = "displayString()" >
Display String
</button>
<script>
let base64String = "";
function imageUploaded() {
let file = document.querySelector(
'input[type=file]')['files'][0];
let reader = new FileReader();
console.log("next");
reader.onload = function () {
base64String = reader.result.replace("data:", "")
.replace(/^.+,/, "");
imageBase64Stringsep = base64String;
// alert(imageBase64Stringsep);
console.log(base64String);
}
reader.readAsDataURL(file);
}
function displayString() {
console.log("Base64String about to be printed");
alert(base64String);
}
</script>
</body>
</html>
Please do you have a video that explain How can I send and receive data from MQTT machine to my app inventor?