Hello everyone,
I have some data in database that I need to sand on mqtt.
My data looks like this : 50C0E54373C3B68
First thing I need to do is converting this string to hex to look like this:
0x50 0xC0 0xE0...
I tried to read every byte and save it to array with this code:
var desKey = msg.payload[0].desKey;;
var raw = new Buffer(26);
raw [0] = desKey[0];
raw [1] = desKey[1];
raw [2] = desKey[2];
raw [3] = desKey[3];
raw [4] = desKey[4];
raw [5] = desKey[5];
msg.payload = raw;
retrun msg;
but if character is not number array is empty.
how can I get 0xA 0xB 0xC... values to my array?