Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In case we post the date in hexadecimal format

function f(p){

  this.p = p;

}

f.prototype.calculate = function(mes){

let intValue = parseInt(mes, 16);

let sign = 1;

if(intValue & 0x8000) {

    intValue = (~intValue + 1) & 0xFFFF;

    sign = -1;

}

intValue = sign * intValue / Math.pow(2, this.p);

return intValue;

}

let res = new f(8);

return (res.calculate(value));

Our first table Both tables will display the value in the hexadecimal format as "0x192a17f9" (raw value as we've sent it from the KNOT → the javascript for the table did not convert it to a decimal value yet) and our second table will display the value in a decimal format as "6442" (the javascript used for the table did convert the value from "0x192a" to "6442").

Because of the fact that the values in our tag's payload are in signed 8.8 fixed point format (keeping in mind the twos-complement format), we will need to divide the result by "256"to add additional javascript code to "convert" the data to the decimal value.

Enter the "Edit" mode and click on the "Edit widget" button:

...