I have a simulator and it’s working like an IoT device. This device sends hexdecimal values to c8y UI application and before sending hexadecimal, we need to convert ASCII values on c8y UI screen.
@Name("createdSchema")
create schema UplinkUpdateEvent (
msg Number,
time Date,
msgid string
);
create expression string hexToNum(value)[
function format(hexValue){
var hex = hexValue.toString();
var str = '';
for (var n = 0; n < hex.length; n += 2) {
str += parseInt(hex.substr(n, 2), 16);
}
return str;
};
format(value);
];
@Name("UplinkUpdateEvent")``
insert into UplinkUpdateEvent
select
event.event.source.value as msgid,
event.event.time as time,
hexToNum(getString(event, "objectResourceValue")) as msg
from EventCreated event
where event.event.type.startsWith("c8y_UpLin");
The expected result will be 9(Hex)–>36(ASCII)