How to convert Hexadecimal to ASCII using cumulocity Event proceeding script

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.

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;

insert into UplinkUpdateEvent
    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)

@Mariela_Dim, I don’t see any question here. Are you try to share the code snippet /solution with community?

Just a quick note as a reminder that CEL (Esper) used in this post is no longer being supported after 2020.
See this note - CEL (Esper) End-of-Support
Cumulocity now uses Apama to provide streaming analytics - and this provides many new benefits and improvements.

1 Like